AI 应用评测体系

一、核心思想

  • 不能依赖公开 benchmark 或主观体感。上线信心应来自基于业务数据的评测体系。
  • 核心闭环:Golden Set(标准测试集) + 多维度评分 + 自动化回归 + 线上灰度验证

下面是核心闭环的整体流程:
#mermaid-svg-TEiS5JYKpHhc0FEu{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-TEiS5JYKpHhc0FEu .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-TEiS5JYKpHhc0FEu .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-TEiS5JYKpHhc0FEu .error-icon{fill:#552222;}#mermaid-svg-TEiS5JYKpHhc0FEu .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-TEiS5JYKpHhc0FEu .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-TEiS5JYKpHhc0FEu .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-TEiS5JYKpHhc0FEu .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-TEiS5JYKpHhc0FEu .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-TEiS5JYKpHhc0FEu .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-TEiS5JYKpHhc0FEu .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-TEiS5JYKpHhc0FEu .marker{fill:#333333;stroke:#333333;}#mermaid-svg-TEiS5JYKpHhc0FEu .marker.cross{stroke:#333333;}#mermaid-svg-TEiS5JYKpHhc0FEu svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-TEiS5JYKpHhc0FEu p{margin:0;}#mermaid-svg-TEiS5JYKpHhc0FEu .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-TEiS5JYKpHhc0FEu .cluster-label text{fill:#333;}#mermaid-svg-TEiS5JYKpHhc0FEu .cluster-label span{color:#333;}#mermaid-svg-TEiS5JYKpHhc0FEu .cluster-label span p{background-color:transparent;}#mermaid-svg-TEiS5JYKpHhc0FEu .label text,#mermaid-svg-TEiS5JYKpHhc0FEu span{fill:#333;color:#333;}#mermaid-svg-TEiS5JYKpHhc0FEu .node rect,#mermaid-svg-TEiS5JYKpHhc0FEu .node circle,#mermaid-svg-TEiS5JYKpHhc0FEu .node ellipse,#mermaid-svg-TEiS5JYKpHhc0FEu .node polygon,#mermaid-svg-TEiS5JYKpHhc0FEu .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-TEiS5JYKpHhc0FEu .rough-node .label text,#mermaid-svg-TEiS5JYKpHhc0FEu .node .label text,#mermaid-svg-TEiS5JYKpHhc0FEu .image-shape .label,#mermaid-svg-TEiS5JYKpHhc0FEu .icon-shape .label{text-anchor:middle;}#mermaid-svg-TEiS5JYKpHhc0FEu .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-TEiS5JYKpHhc0FEu .rough-node .label,#mermaid-svg-TEiS5JYKpHhc0FEu .node .label,#mermaid-svg-TEiS5JYKpHhc0FEu .image-shape .label,#mermaid-svg-TEiS5JYKpHhc0FEu .icon-shape .label{text-align:center;}#mermaid-svg-TEiS5JYKpHhc0FEu .node.clickable{cursor:pointer;}#mermaid-svg-TEiS5JYKpHhc0FEu .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-TEiS5JYKpHhc0FEu .arrowheadPath{fill:#333333;}#mermaid-svg-TEiS5JYKpHhc0FEu .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-TEiS5JYKpHhc0FEu .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-TEiS5JYKpHhc0FEu .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-TEiS5JYKpHhc0FEu .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-TEiS5JYKpHhc0FEu .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-TEiS5JYKpHhc0FEu .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-TEiS5JYKpHhc0FEu .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-TEiS5JYKpHhc0FEu .cluster text{fill:#333;}#mermaid-svg-TEiS5JYKpHhc0FEu .cluster span{color:#333;}#mermaid-svg-TEiS5JYKpHhc0FEu div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-TEiS5JYKpHhc0FEu .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-TEiS5JYKpHhc0FEu rect.text{fill:none;stroke-width:0;}#mermaid-svg-TEiS5JYKpHhc0FEu .icon-shape,#mermaid-svg-TEiS5JYKpHhc0FEu .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-TEiS5JYKpHhc0FEu .icon-shape p,#mermaid-svg-TEiS5JYKpHhc0FEu .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-TEiS5JYKpHhc0FEu .icon-shape .label rect,#mermaid-svg-TEiS5JYKpHhc0FEu .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-TEiS5JYKpHhc0FEu .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-TEiS5JYKpHhc0FEu .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-TEiS5JYKpHhc0FEu :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Badcase 回流
Golden Set 标准测试集
多维度评分
自动化回归
线上灰度验证

二、为什么公开 Benchmark 不够用?

局限性 说明
数据分布差异 业务数据含领域术语、错别字、多语言,与公开数据的干净规范不同。
任务类型不匹配 榜单高分不代表能遵循特定业务规则(如退货政策)。
掩盖高风险失败 平均分高可能掩盖少数但影响严重的关键错误(如医疗建议)。
  • 结论 :公开 benchmark 只用于粗筛模型,不能替代业务定制的评测集。

三、评测核心概念

概念 含义 示例
Task 一条评测任务,包含输入和成功标准 "修复空密码绕过登录校验的问题"
Trial 同一任务的一次运行 同一 Agent 对同一任务跑第 3 次
Grader 评分器(规则/LLM/人工) 单元测试、JSON Schema、LLM-as-Judge
Transcript/Trace 一次运行的完整记录 用户输入、模型回复、工具调用、参数
Outcome 任务结束后的真实状态 退款单是否创建、代码测试是否通过
  • 关键 :不能仅凭最终回复文本判断成功,要检查 Outcome(如回复"已退款"但实际未创建单据)。

四、Golden Set 的构建

数据来源

  1. 生产日志分层采样:优先采"不满意"、追问、转人工、边缘案例,避免只取高频问题。
  2. 人工构造:补足正常路径(50%)、边缘场景(25%)、对抗样本(15%)。
  3. 失败案例回填:线上真实失败案例经确认后加入(最珍贵来源)。

样本数量与分层

分层 典型内容 建议占比
正常路径 高频、清晰的主流场景 50%
边缘场景 信息缺失、多义、跨领域 25%
对抗样本 模型容易犯错的特殊输入 15%
高权重失败 业务定义的关键失败类型 10%
  • 起步建议 :早期 20-50 条即可启动,发布门禁阶段扩展至 50-200 条。分布比总量更重要

维护原则

  • 每季度复查覆盖度,失败样本持续回流,版本与模型/Prompt 一起保存。

五、三种评测方法对比

方法 准确性 速度 成本 典型场景
人工评测 最高 复杂语义、边界仲裁、LLM-as-Judge 校准
规则评测 高(规则内) 最快 格式、枚举、数值边界、引用检查
LLM-as-Judge 中(受偏差影响) 相关性、忠实度、完整性、多维度打分
  • 最佳实践:硬错误先用规则拦住 → 开放式语义判断交给 LLM-as-Judge → 高风险样本保留人工复核。

三种评测方法的分工与流转关系如下:
#mermaid-svg-y514NLlxN82LI2Bf{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-y514NLlxN82LI2Bf .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-y514NLlxN82LI2Bf .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-y514NLlxN82LI2Bf .error-icon{fill:#552222;}#mermaid-svg-y514NLlxN82LI2Bf .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-y514NLlxN82LI2Bf .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-y514NLlxN82LI2Bf .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-y514NLlxN82LI2Bf .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-y514NLlxN82LI2Bf .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-y514NLlxN82LI2Bf .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-y514NLlxN82LI2Bf .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-y514NLlxN82LI2Bf .marker{fill:#333333;stroke:#333333;}#mermaid-svg-y514NLlxN82LI2Bf .marker.cross{stroke:#333333;}#mermaid-svg-y514NLlxN82LI2Bf svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-y514NLlxN82LI2Bf p{margin:0;}#mermaid-svg-y514NLlxN82LI2Bf .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-y514NLlxN82LI2Bf .cluster-label text{fill:#333;}#mermaid-svg-y514NLlxN82LI2Bf .cluster-label span{color:#333;}#mermaid-svg-y514NLlxN82LI2Bf .cluster-label span p{background-color:transparent;}#mermaid-svg-y514NLlxN82LI2Bf .label text,#mermaid-svg-y514NLlxN82LI2Bf span{fill:#333;color:#333;}#mermaid-svg-y514NLlxN82LI2Bf .node rect,#mermaid-svg-y514NLlxN82LI2Bf .node circle,#mermaid-svg-y514NLlxN82LI2Bf .node ellipse,#mermaid-svg-y514NLlxN82LI2Bf .node polygon,#mermaid-svg-y514NLlxN82LI2Bf .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-y514NLlxN82LI2Bf .rough-node .label text,#mermaid-svg-y514NLlxN82LI2Bf .node .label text,#mermaid-svg-y514NLlxN82LI2Bf .image-shape .label,#mermaid-svg-y514NLlxN82LI2Bf .icon-shape .label{text-anchor:middle;}#mermaid-svg-y514NLlxN82LI2Bf .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-y514NLlxN82LI2Bf .rough-node .label,#mermaid-svg-y514NLlxN82LI2Bf .node .label,#mermaid-svg-y514NLlxN82LI2Bf .image-shape .label,#mermaid-svg-y514NLlxN82LI2Bf .icon-shape .label{text-align:center;}#mermaid-svg-y514NLlxN82LI2Bf .node.clickable{cursor:pointer;}#mermaid-svg-y514NLlxN82LI2Bf .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-y514NLlxN82LI2Bf .arrowheadPath{fill:#333333;}#mermaid-svg-y514NLlxN82LI2Bf .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-y514NLlxN82LI2Bf .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-y514NLlxN82LI2Bf .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-y514NLlxN82LI2Bf .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-y514NLlxN82LI2Bf .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-y514NLlxN82LI2Bf .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-y514NLlxN82LI2Bf .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-y514NLlxN82LI2Bf .cluster text{fill:#333;}#mermaid-svg-y514NLlxN82LI2Bf .cluster span{color:#333;}#mermaid-svg-y514NLlxN82LI2Bf div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-y514NLlxN82LI2Bf .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-y514NLlxN82LI2Bf rect.text{fill:none;stroke-width:0;}#mermaid-svg-y514NLlxN82LI2Bf .icon-shape,#mermaid-svg-y514NLlxN82LI2Bf .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-y514NLlxN82LI2Bf .icon-shape p,#mermaid-svg-y514NLlxN82LI2Bf .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-y514NLlxN82LI2Bf .icon-shape .label rect,#mermaid-svg-y514NLlxN82LI2Bf .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-y514NLlxN82LI2Bf .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-y514NLlxN82LI2Bf .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-y514NLlxN82LI2Bf :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 硬错误/格式/枚举
开放式语义判断
高风险/边界仲裁


评测任务
错误类型判断
规则评测
LLM-as-Judge
人工评测
自动通过
置信度足够?

六、LLM-as-Judge 的可靠使用

两种模式

  • Reference-based(有参考答案):对照标准答案核查事实、边界,适合事实型业务问答。
  • Reference-free(无参考答案):依据用户问题和评分标准判断,适合创意写作等。

四类常见偏差与缓解

偏差类型 说明 缓解措施
位置偏差 答案展示顺序影响判断 交换顺序取一致结论,或一次只评一个
冗长偏差 更长的答案易得高分 Prompt 明确约束,验证集设对照样本
自我强化偏差 同源模型互评更宽容 不同厂商模型交叉验证 + 人工抽样
有限推理能力 数学/代码可能被带偏 提供参考答案、测试结果等可验证证据

Judge Prompt 要点

  • 明确评分维度(如 Faithfulness, Relevance, Completeness),给 1-5 分及依据。
  • 允许输出 Unknownneeds_human_review,不逼 Judge 硬判。
  • 输出仅限结构化 JSON,不含长推理过程。

七、RAG 应用评测

评测必须分段:检索层 + 生成层

检索指标
指标 关注点 适合场景
Recall@k 相关文档召回覆盖率 关键信息不能漏(合规/医疗)
Hit Rate@k 是否至少命中一条 快速评估
MRR 第一条相关结果的排名 强依赖 Top-1 的场景
Precision@k 检索精准率 Token 预算紧张时
Context Precision/Recall 相关上下文排名/覆盖 无文档 ID 标注时用 LLM 评估
生成指标
  • Faithfulness:回答是否忠于检索到的上下文。
  • Answer Relevance:是否接住了用户真正的问题。
  • Completeness:是否覆盖关键要点。
  • Context Usage(自定义):检索到的内容是否被有效使用。
  • Noise Sensitivity:噪声上下文是否干扰回答。

两个常见陷阱

  1. 用检索结果直接当标准答案 → 混淆检索和生成质量。
  2. 只评最终答案,不分段 → 无法定位问题源头。

RAG 评测的分层定位思路如下:
#mermaid-svg-DY8oe0ietKJuEGfC{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-DY8oe0ietKJuEGfC .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-DY8oe0ietKJuEGfC .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-DY8oe0ietKJuEGfC .error-icon{fill:#552222;}#mermaid-svg-DY8oe0ietKJuEGfC .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-DY8oe0ietKJuEGfC .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-DY8oe0ietKJuEGfC .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-DY8oe0ietKJuEGfC .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-DY8oe0ietKJuEGfC .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-DY8oe0ietKJuEGfC .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-DY8oe0ietKJuEGfC .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-DY8oe0ietKJuEGfC .marker{fill:#333333;stroke:#333333;}#mermaid-svg-DY8oe0ietKJuEGfC .marker.cross{stroke:#333333;}#mermaid-svg-DY8oe0ietKJuEGfC svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-DY8oe0ietKJuEGfC p{margin:0;}#mermaid-svg-DY8oe0ietKJuEGfC .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-DY8oe0ietKJuEGfC .cluster-label text{fill:#333;}#mermaid-svg-DY8oe0ietKJuEGfC .cluster-label span{color:#333;}#mermaid-svg-DY8oe0ietKJuEGfC .cluster-label span p{background-color:transparent;}#mermaid-svg-DY8oe0ietKJuEGfC .label text,#mermaid-svg-DY8oe0ietKJuEGfC span{fill:#333;color:#333;}#mermaid-svg-DY8oe0ietKJuEGfC .node rect,#mermaid-svg-DY8oe0ietKJuEGfC .node circle,#mermaid-svg-DY8oe0ietKJuEGfC .node ellipse,#mermaid-svg-DY8oe0ietKJuEGfC .node polygon,#mermaid-svg-DY8oe0ietKJuEGfC .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-DY8oe0ietKJuEGfC .rough-node .label text,#mermaid-svg-DY8oe0ietKJuEGfC .node .label text,#mermaid-svg-DY8oe0ietKJuEGfC .image-shape .label,#mermaid-svg-DY8oe0ietKJuEGfC .icon-shape .label{text-anchor:middle;}#mermaid-svg-DY8oe0ietKJuEGfC .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-DY8oe0ietKJuEGfC .rough-node .label,#mermaid-svg-DY8oe0ietKJuEGfC .node .label,#mermaid-svg-DY8oe0ietKJuEGfC .image-shape .label,#mermaid-svg-DY8oe0ietKJuEGfC .icon-shape .label{text-align:center;}#mermaid-svg-DY8oe0ietKJuEGfC .node.clickable{cursor:pointer;}#mermaid-svg-DY8oe0ietKJuEGfC .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-DY8oe0ietKJuEGfC .arrowheadPath{fill:#333333;}#mermaid-svg-DY8oe0ietKJuEGfC .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-DY8oe0ietKJuEGfC .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-DY8oe0ietKJuEGfC .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-DY8oe0ietKJuEGfC .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-DY8oe0ietKJuEGfC .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-DY8oe0ietKJuEGfC .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-DY8oe0ietKJuEGfC .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-DY8oe0ietKJuEGfC .cluster text{fill:#333;}#mermaid-svg-DY8oe0ietKJuEGfC .cluster span{color:#333;}#mermaid-svg-DY8oe0ietKJuEGfC div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-DY8oe0ietKJuEGfC .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-DY8oe0ietKJuEGfC rect.text{fill:none;stroke-width:0;}#mermaid-svg-DY8oe0ietKJuEGfC .icon-shape,#mermaid-svg-DY8oe0ietKJuEGfC .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-DY8oe0ietKJuEGfC .icon-shape p,#mermaid-svg-DY8oe0ietKJuEGfC .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-DY8oe0ietKJuEGfC .icon-shape .label rect,#mermaid-svg-DY8oe0ietKJuEGfC .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-DY8oe0ietKJuEGfC .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-DY8oe0ietKJuEGfC .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-DY8oe0ietKJuEGfC :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 检索召回不足
生成忠实度不足
用户问题
检索层
Recall@k / Hit Rate@k / MRR
生成层
Faithfulness / Relevance / Completeness
问题定位
优化检索/重排
优化 Prompt/模型

八、Agent 应用评测

Agent 评测需同时看 Outcome (最终状态)和 Trace(执行过程)。

核心指标

维度 指标 说明
任务完成率 完成任务数/总任务数 检查最终状态(退款单、测试通过)
工具调用准确率 工具选择/参数准确率 是否用对工具、传对参数
轨迹准确率 实际路径与关键路径差异 高风险动作严格检查
错误恢复率 工具失败后完成/失败总数 Agent 能否从错误中恢复
多次运行一致性 至少一次 vs 连续成功率 连续成功率更接近生产稳定性

Skill 单独评测四类用例

  1. 触发用例:该触发时触发,不该触发时不触发。
  2. 核心逻辑用例:主要分支和高风险分支是否正确。
  3. 产物质量用例:输出是否满足业务格式和质量要求。
  4. 异常容错用例:输入缺失、工具失败时的表现。

Agent 评测需同时关注 Outcome 与 Trace,关系如下:
#mermaid-svg-LOxpE4TzGmktMVe5{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-LOxpE4TzGmktMVe5 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-LOxpE4TzGmktMVe5 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-LOxpE4TzGmktMVe5 .error-icon{fill:#552222;}#mermaid-svg-LOxpE4TzGmktMVe5 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-LOxpE4TzGmktMVe5 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-LOxpE4TzGmktMVe5 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-LOxpE4TzGmktMVe5 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-LOxpE4TzGmktMVe5 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-LOxpE4TzGmktMVe5 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-LOxpE4TzGmktMVe5 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-LOxpE4TzGmktMVe5 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-LOxpE4TzGmktMVe5 .marker.cross{stroke:#333333;}#mermaid-svg-LOxpE4TzGmktMVe5 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-LOxpE4TzGmktMVe5 p{margin:0;}#mermaid-svg-LOxpE4TzGmktMVe5 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-LOxpE4TzGmktMVe5 .cluster-label text{fill:#333;}#mermaid-svg-LOxpE4TzGmktMVe5 .cluster-label span{color:#333;}#mermaid-svg-LOxpE4TzGmktMVe5 .cluster-label span p{background-color:transparent;}#mermaid-svg-LOxpE4TzGmktMVe5 .label text,#mermaid-svg-LOxpE4TzGmktMVe5 span{fill:#333;color:#333;}#mermaid-svg-LOxpE4TzGmktMVe5 .node rect,#mermaid-svg-LOxpE4TzGmktMVe5 .node circle,#mermaid-svg-LOxpE4TzGmktMVe5 .node ellipse,#mermaid-svg-LOxpE4TzGmktMVe5 .node polygon,#mermaid-svg-LOxpE4TzGmktMVe5 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-LOxpE4TzGmktMVe5 .rough-node .label text,#mermaid-svg-LOxpE4TzGmktMVe5 .node .label text,#mermaid-svg-LOxpE4TzGmktMVe5 .image-shape .label,#mermaid-svg-LOxpE4TzGmktMVe5 .icon-shape .label{text-anchor:middle;}#mermaid-svg-LOxpE4TzGmktMVe5 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-LOxpE4TzGmktMVe5 .rough-node .label,#mermaid-svg-LOxpE4TzGmktMVe5 .node .label,#mermaid-svg-LOxpE4TzGmktMVe5 .image-shape .label,#mermaid-svg-LOxpE4TzGmktMVe5 .icon-shape .label{text-align:center;}#mermaid-svg-LOxpE4TzGmktMVe5 .node.clickable{cursor:pointer;}#mermaid-svg-LOxpE4TzGmktMVe5 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-LOxpE4TzGmktMVe5 .arrowheadPath{fill:#333333;}#mermaid-svg-LOxpE4TzGmktMVe5 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-LOxpE4TzGmktMVe5 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-LOxpE4TzGmktMVe5 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-LOxpE4TzGmktMVe5 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-LOxpE4TzGmktMVe5 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-LOxpE4TzGmktMVe5 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-LOxpE4TzGmktMVe5 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-LOxpE4TzGmktMVe5 .cluster text{fill:#333;}#mermaid-svg-LOxpE4TzGmktMVe5 .cluster span{color:#333;}#mermaid-svg-LOxpE4TzGmktMVe5 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-LOxpE4TzGmktMVe5 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-LOxpE4TzGmktMVe5 rect.text{fill:none;stroke-width:0;}#mermaid-svg-LOxpE4TzGmktMVe5 .icon-shape,#mermaid-svg-LOxpE4TzGmktMVe5 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-LOxpE4TzGmktMVe5 .icon-shape p,#mermaid-svg-LOxpE4TzGmktMVe5 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-LOxpE4TzGmktMVe5 .icon-shape .label rect,#mermaid-svg-LOxpE4TzGmktMVe5 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-LOxpE4TzGmktMVe5 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-LOxpE4TzGmktMVe5 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-LOxpE4TzGmktMVe5 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Agent 执行
Trace 执行过程
Outcome 最终状态
工具调用准确率
轨迹准确率
错误恢复率
任务完成率
综合评测结论

九、评测 Harness 搭建

最小可用 Harness 四件事

  1. 读取评测集。
  2. 调用被测系统。
  3. 执行评分器。
  4. 保存结果(含分数、Trace、版本信息)。

环境隔离(Agent 评测关键)

  • 每个 Trial 从干净状态启动,避免缓存/文件残留影响。
  • Harness error 和模型失败要分开记录。

十、结构化输出评测

检查层 方法 说明
格式合法率 JSON.parse() 是否为合法 JSON
Schema 通过率 JSON Schema 校验 字段完整性、类型、枚举范围
字段语义准确率 业务规则校验 分类、置信度等是否正确
  • 关键 :拆到字段级评测,关键字段错误比整体通过率更重要。

十一、完整指标体系参考(精选)

维度 指标 适用场景
检索质量 Recall@k, Hit Rate@k, MRR RAG 知识库
生成质量 Faithfulness, Relevance, Completeness 问答、客服
工具调用 选择/参数准确率, 不必要调用率 Agent
Agent 稳定性 至少一次/连续成功率 高风险生产任务
Skill 质量 触发/误触发率, 异常稳态率 Skill 路由
格式合规 JSON 合法率, Schema 通过率 结构化输出
成本与延迟 TTFT, E2E 延迟, Token 数 性能/成本控制

十二、离线评测 → Trace 回放 → 线上灰度 闭环

三个阶段

阶段 目的 数据源
离线评测 发布前快速回归 Golden Set(固定版本)
Trace 回放 覆盖真实场景 生产采样的真实请求
线上灰度 小流量验证 真实流量,对比指标
  • 灰度门槛:核心指标相对对照组下降超 3% 则暂停扩量。
  • 持续监控:每天抽 3%-5% 流量回评,核心指标连续 3 天下跌再告警。

Badcase 分析回流

每个失败样本记录:证据(Trace)→ 现象分类 → 定位责任模块 → 根因 → 修复建议 → 回流到 Golden Set 或回归集

离线评测到线上灰度的完整闭环如下:
#mermaid-svg-KixON7SGOGvUoAw4{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-KixON7SGOGvUoAw4 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-KixON7SGOGvUoAw4 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-KixON7SGOGvUoAw4 .error-icon{fill:#552222;}#mermaid-svg-KixON7SGOGvUoAw4 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-KixON7SGOGvUoAw4 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-KixON7SGOGvUoAw4 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-KixON7SGOGvUoAw4 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-KixON7SGOGvUoAw4 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-KixON7SGOGvUoAw4 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-KixON7SGOGvUoAw4 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-KixON7SGOGvUoAw4 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-KixON7SGOGvUoAw4 .marker.cross{stroke:#333333;}#mermaid-svg-KixON7SGOGvUoAw4 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-KixON7SGOGvUoAw4 p{margin:0;}#mermaid-svg-KixON7SGOGvUoAw4 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-KixON7SGOGvUoAw4 .cluster-label text{fill:#333;}#mermaid-svg-KixON7SGOGvUoAw4 .cluster-label span{color:#333;}#mermaid-svg-KixON7SGOGvUoAw4 .cluster-label span p{background-color:transparent;}#mermaid-svg-KixON7SGOGvUoAw4 .label text,#mermaid-svg-KixON7SGOGvUoAw4 span{fill:#333;color:#333;}#mermaid-svg-KixON7SGOGvUoAw4 .node rect,#mermaid-svg-KixON7SGOGvUoAw4 .node circle,#mermaid-svg-KixON7SGOGvUoAw4 .node ellipse,#mermaid-svg-KixON7SGOGvUoAw4 .node polygon,#mermaid-svg-KixON7SGOGvUoAw4 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-KixON7SGOGvUoAw4 .rough-node .label text,#mermaid-svg-KixON7SGOGvUoAw4 .node .label text,#mermaid-svg-KixON7SGOGvUoAw4 .image-shape .label,#mermaid-svg-KixON7SGOGvUoAw4 .icon-shape .label{text-anchor:middle;}#mermaid-svg-KixON7SGOGvUoAw4 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-KixON7SGOGvUoAw4 .rough-node .label,#mermaid-svg-KixON7SGOGvUoAw4 .node .label,#mermaid-svg-KixON7SGOGvUoAw4 .image-shape .label,#mermaid-svg-KixON7SGOGvUoAw4 .icon-shape .label{text-align:center;}#mermaid-svg-KixON7SGOGvUoAw4 .node.clickable{cursor:pointer;}#mermaid-svg-KixON7SGOGvUoAw4 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-KixON7SGOGvUoAw4 .arrowheadPath{fill:#333333;}#mermaid-svg-KixON7SGOGvUoAw4 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-KixON7SGOGvUoAw4 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-KixON7SGOGvUoAw4 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-KixON7SGOGvUoAw4 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-KixON7SGOGvUoAw4 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-KixON7SGOGvUoAw4 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-KixON7SGOGvUoAw4 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-KixON7SGOGvUoAw4 .cluster text{fill:#333;}#mermaid-svg-KixON7SGOGvUoAw4 .cluster span{color:#333;}#mermaid-svg-KixON7SGOGvUoAw4 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-KixON7SGOGvUoAw4 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-KixON7SGOGvUoAw4 rect.text{fill:none;stroke-width:0;}#mermaid-svg-KixON7SGOGvUoAw4 .icon-shape,#mermaid-svg-KixON7SGOGvUoAw4 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-KixON7SGOGvUoAw4 .icon-shape p,#mermaid-svg-KixON7SGOGvUoAw4 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-KixON7SGOGvUoAw4 .icon-shape .label rect,#mermaid-svg-KixON7SGOGvUoAw4 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-KixON7SGOGvUoAw4 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-KixON7SGOGvUoAw4 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-KixON7SGOGvUoAw4 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 核心指标下降超 3%
通过
离线评测 Golden Set
Trace 回放
线上灰度
暂停扩量
全量发布
Badcase 分析
回流 Golden Set

十三、接入 CI 的自动化回归

两类评测

  • 能力评测:评估能否做更难任务,不要求高分。
  • 回归评测:检查原来对的任务是否还稳,应接近 100% 通过率。

阈值设定

  • 绝对阈值:指标不低于固定值(如 Faithfulness ≥ 0.75)。
  • 相对阈值:相比上个稳定版本下降不超过 5%。
  • 组合使用:绝对守底线,相对防退步。

速度与覆盖度平衡

阶段 样本量 目标耗时
PR 阶段 50 条以内核心集 3 分钟
主分支合并 200 条以上完整集 可接受时间
重大发布 1000 条以上 Trace 回放 并发压到可接受时间

十四、面试核心问题速览

  1. 为什么不能只靠公开 benchmark? → 数据分布不同,掩盖高风险失败。
  2. Golden Set 怎么构建? → 生产日志采样 + 人工构造三类样本 + 失败案例回填。
  3. LLM-as-Judge 偏差怎么缓解? → 针对位置/冗长/自我强化/推理能力四类偏差。
  4. RAG 为什么要分段评测? → 定位问题在检索层还是生成层。
  5. Agent 评测为什么更复杂? → 多轮决策+工具调用,需同时看 Outcome 和 Trace。
  6. CI 评测速度覆盖度怎么平衡? → PR 跑 50 条核心集(3 分钟),主分支跑完整集。
  7. Skill 怎么单独评测? → 触发/核心逻辑/产物质量/异常容错四类用例。
  8. Harness 负责什么? → 读取集→调用系统→执行评分→保存结果+版本信息。

十五、总结

没有自己的评测集,就没有上线信心。

  • Golden Set 的价值在分布,边缘/对抗/高权重失败类型决定上线信心。
  • LLM-as-Judge 能扩大规模,但偏差要管住,客观任务要给可验证证据。
  • RAG 先看检索再看生成,Agent 同时看 Outcome 和 Trace,Skill 需单独评测。
  • 评测闭环要落到工程动作:离线 Golden Set → Trace 回放 → 线上灰度 → CI 自动化 → Badcase 回流
  • AI 应用从第一次改 Prompt、第一次换模型开始,就应该进入评测体系。
相关推荐
cypking2 小时前
Objective-C 语法完整学习手册(小白自学 + 开发备查)
c语言·开发语言·学习·objective-c
新芒4 小时前
AI Agent进入独立站:店匠Shoplazza主Agent Athena如何重构经营?
人工智能·重构
chuan.bai6 小时前
Java RAG 实战(第 11 篇):RAG 知识工作台网页
java·开发语言·人工智能
Terra.K9 小时前
Java异常学习[特殊字符]
java·开发语言·学习
fthux9 小时前
招聘季实测:我用 TraeWork 搭了一套 AI 简历初筛系统
人工智能·ai编程·trae
SLD_Allen9 小时前
NVIDIA KAI Scheduler深度解析——Kubernetes原生AI调度器的架构、原理与实践
人工智能·架构·kubernetes
小玮看世界10 小时前
从“画图”到“Mermaid”:AI语义理解与架构绘制的演进之路
人工智能·深度学习·计算机视觉
小岐AI观10 小时前
智赋岐黄适合养生馆吗?
大数据·人工智能·物联网