name: advanced-evaluation
description: This skill should be used when the user asks to “implement LLM-as-judge”, “compare model outputs”, “create evaluation rubrics”, “mitigate evaluation bias”, or mentions direct scoring, pairwise comparison, position bias, evaluation pipelines, or automated quality assessment.
risk: safe
source: community
date_added: 2026-03-18
高级评估
此技能涵盖了使用大型语言模型(LLM)作为评判者来评估LLM输出的生产级技术。它将学术论文、行业实践和实际实施经验的研究成果综合为可操作的模式,用于构建可靠的评估系统。
关键见解:将大语言模型作为裁判并不是单一的技术,而是一系列方法,每种方法适用于不同的评估情境。选择合适的方法并减轻已知偏见是这一技能所培养的核心能力。
何时使用
在以下情况下激活此技能:
- 为大型语言模型输出构建自动化评估管道
- 比较多个模型响应以选择最佳响应
- 在评估团队中建立一致的质量标准
- 调试显示结果不一致的评估系统
- 为提示或模型更改设计 A/B 测试
- 为人工或自动评估创建评分标准
- 分析自动评估与人工评估之间的相关性
核心概念
评估分类法
评估方法主要分为两大类,且其可靠性特征各不相同:
直接评分:一个大型语言模型在定义的评分标准上对一个回答进行评价。
- 最适合:客观标准(事实准确性、遵循指令、毒性)
- 可靠性:对于明确定义的标准,中到高
- 故障模式:分数校准漂移,尺度解释不一致
逐对比较:大语言模型比较两个回答并选择更好的一个。
- 最适合:主观偏好(语调、风格、说服力)
- 可靠性:比直接评分偏好更高
- 失败模式:位置偏差,长度偏差
来自 MT-Bench 论文(Zheng 等,2023 年)的研究表明,对于基于偏好的评估,成对比较比直接评分与人工评判者的一致性更高,而对于具有明确真实标准的客观指标,直接评分仍然是适用的。
偏见格局
大型语言模型评审表现出必须积极缓解的系统性偏见:
位置偏差:在成对比较中,首位的回答会受到优先对待。缓解方法:交换位置后进行两次评估,使用多数投票或一致性检查。
长度偏差:无论质量如何,更长的回答评分更高。缓解方法:明确提示忽略长度,使用长度归一化评分。
自我提升偏差:模型会对自己的输出评价更高。缓解方法:使用不同的模型进行生成和评估,或承认这一限制。
冗长偏差:即使不必要,详细的解释也会获得更高的分数。缓解方法:使用针对特定标准的评分量表,对无关的细节进行惩罚。
权威偏见:自信、权威的语气会得到更高评价,无论其准确性如何。缓解方法:要求引用证据,增加事实核查环节。
指标选择框架
根据评估任务结构选择指标:
| Task Type | Primary Metrics | Secondary Metrics |
|---|---|---|
| Binary classification (pass/fail) | Recall, Precision, F1 | Cohen’s κ |
| Ordinal scale (1-5 rating) | Spearman’s ρ, Kendall’s τ | Cohen’s κ (weighted) |
| Pairwise preference | Agreement rate, Position consistency | Confidence calibration |
| Multi-label | Macro-F1, Micro-F1 | Per-label precision/recall |
关键洞察:高绝对一致性不如系统性分歧模式重要。在特定标准上持续与人类意见不一致的评审,比起存在随机噪声的评审更成问题。
评估方法
直接评分实现
直接评分需要三个组成部分:明确的标准、校准的量表和结构化的输出格式。
标准定义模式:
Criterion: [Name] Description: [What this criterion measures] Weight: [Relative importance, 0-1]秤校准:
- 1-3 分量表:二元选项,带中性选项,认知负荷最低
- 1-5 量表:标准李克特量表,粒度和可靠性良好平衡
- 1-10 评分尺度:颗粒度高但难以校准,仅在详细评分细则下使用
直接评分的提示结构:
You are an expert evaluator assessing response quality. ## Task Evaluate the following response against each criterion. ## Original Prompt {prompt} ## Response to Evaluate {response} ## Criteria {for each criterion: name, description, weight} ## Instructions For each criterion: 1. Find specific evidence in the response 2. Score according to the rubric (1-{max} scale) 3. Justify your score with evidence 4. Suggest one specific improvement ## Output Format Respond with structured JSON containing scores, justifications, and summary.链式思维要求:所有评分提示都必须在给出分数前要求提供理由。研究表明,与先给分数的方法相比,这可以提高15-25%的可靠性。
成对比较实现
成对比较在基于偏好的评估中本质上更可靠,但需要减轻偏见。
位置偏差缓解协议:
- 第一次处理:回应 A 在第一位,回应 B 在第二位
- 第二遍:回应 B 放在第一位,回应 A 放在第二位
- 一致性检查:如果通过与不通过意见不一致,则返回信心降低的平局
- 最终裁定:平均置信度下的持续获胜者
成对比较的提示结构:
You are an expert evaluator comparing two AI responses. ## Critical Instructions - Do NOT prefer responses because they are longer - Do NOT prefer responses based on position (first vs second) - Focus ONLY on quality according to the specified criteria - Ties are acceptable when responses are genuinely equivalent ## Original Prompt {prompt} ## Response A {response_a} ## Response B {response_b} ## Comparison Criteria {criteria list} ## Instructions 1. Analyze each response independently first 2. Compare them on each criterion 3. Determine overall winner with confidence level ## Output Format JSON with per-criterion comparison, overall winner, confidence (0-1), and reasoning.置信度校准:置信度分数应反映位置一致性:
- 两轮结果一致:置信度 = 各自置信度的平均值
- 通过意见不一致:置信度 = 0.5,裁决 = 平局
评分标准生成
与开放式评分相比,定义明确的评分标准可以将评估差异减少40-60%.
评分标准组成部分:
- 等级描述:每个分数等级的清晰界限
- 特征:定义每个层级的可观察特征
- 示例:每个级别的代表性文本(可选但有价值)
- 边缘情况:模糊情境的指导
- 评分指南:一致应用的一般原则
严格性校准:
- 宽松:较低的及格分标准,适合鼓励反复尝试
- 平衡:公平,适合生产使用的典型预期
- 严格:高标准,适用于安全关键或高风险评估
领域适应:评分标准应使用特定领域的术语。“代码可读性”评分标准提到变量、函数和注释。“医学准确性”评分标准引用临床术语和证据标准。
实用指导
评估流程设计
生产评估系统需要多层次:
┌─────────────────────────────────────────────────┐ │ Evaluation Pipeline │ ├─────────────────────────────────────────────────┤ │ │ │ Input: Response + Prompt + Context │ │ │ │ │ ▼ │ │ ┌─────────────────────┐ │ │ │ Criteria Loader │ ◄── Rubrics, weights │ │ └──────────┬──────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────┐ │ │ │ Primary Scorer │ ◄── Direct or Pairwise │ │ └──────────┬──────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────┐ │ │ │ Bias Mitigation │ ◄── Position swap, etc. │ │ └──────────┬──────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────┐ │ │ │ Confidence Scoring │ ◄── Calibration │ │ └──────────┬──────────┘ │ │ │ │ │ ▼ │ │ Output: Scores + Justifications + Confidence │ │ │ └─────────────────────────────────────────────────┘常见反模式
反模式:没有理由的打分
- 问题:分数缺乏基础,难以调试或改进
- 解决方案:在评分前始终要求有基于证据的理由
反模式:单次遍历的逐对比较
- 问题:位置偏差会损坏结果
- 解决方法:始终交换位置并检查一致性
反模式:过多的标准
- 问题:衡量多种事物的标准不可靠
- 解决方案:一个标准 = 一个可衡量的方面
反模式:缺少边缘情况指导
- 问题:评估人员处理模糊情况不一致
- 解决方案:在评分标准中包含边缘情况并提供明确指导
反模式:忽视置信度校准
- 问题:高置信度的错误判断比低置信度的更糟
- 解决方案:根据位置一致性和证据强度校准信心
决策框架:直接法与成对法
使用这个决策树:
Is there an objective ground truth? ├── Yes → Direct Scoring │ └── Examples: factual accuracy, instruction following, format compliance │ └── No → Is it a preference or quality judgment? ├── Yes → Pairwise Comparison │ └── Examples: tone, style, persuasiveness, creativity │ └── No → Consider reference-based evaluation └── Examples: summarization (compare to source), translation (compare to reference)规模评估
用于大批量评估:
LLM小组 (PoLL):使用多个模型作为评审,汇总投票
- 减少个体模型偏差
- 更贵但在重大决策中更可靠
分层评估:快速廉价的模型用于筛选,昂贵的模型用于边缘情况
- 大批量成本效益高
- 需要校准筛查阈值
人类在回路中:对明确情况进行自动评估,对低置信度情况进行人工审核
- 关键应用的最佳可靠性
- 设计反馈循环以改进自动化评估
例子
示例 1:准确性直接评分
输入:
Prompt: "What causes seasons on Earth?" Response: "Seasons are caused by Earth's tilted axis. As Earth orbits the Sun, different hemispheres receive more direct sunlight at different times of year." Criterion: Factual Accuracy (weight: 1.0) Scale: 1-5输出:
{"criterion":"Factual Accuracy","score":5,"evidence":["Correctly identifies axial tilt as primary cause","Correctly explains differential sunlight by hemisphere","No factual errors present"],"justification":"Response accurately explains the causeofseasonswithcorrect scientific reasoning.Both the axial tilt and its effect on sunlight distribution are correctly described.","improvement":"Could add the specific tilt angle (23.5°) for completeness."}示例 2:位置交换的两两比较
输入:
Prompt: "Explain machine learning to a beginner" Response A: [Technical explanation with jargon] Response B: [Simple analogy-based explanation] Criteria: ["clarity", "accessibility"]第一次通过(A 首轮):
{"winner":"B","confidence":0.8}第二次通道(先B):
{"winner":"A","confidence":0.6}(注意:获胜者是A,因为B位居第一名)
映射第二遍:
{"winner":"B","confidence":0.6}最终结果:
{"winner":"B","confidence":0.7,"positionConsistency":{"consistent":true,"firstPassWinner":"B","secondPassWinner":"B"}}示例 3:评分标准生成
输入:
criterionName: "Code Readability" criterionDescription: "How easy the code is to understand and maintain" domain: "software engineering" scale: "1-5" strictness: "balanced"输出(缩写):
{"levels":[{"score":1,"label":"Poor","description":"Code is difficult to understand without significant effort","characteristics":["No meaningful variable or function names","No comments or documentation","Deeply nested or convoluted logic"]},{"score":3,"label":"Adequate","description":"Code is understandable with some effort","characteristics":["Most variables have meaningful names","Basic comments present for complex sections","Logic is followable but could be cleaner"]},{"score":5,"label":"Excellent","description":"Code is immediately clear and maintainable","characteristics":["All names are descriptive and consistent","Comprehensive documentation","Clean, modular structure"]}],"edgeCases":[{"situation":"Code is well-structured but uses domain-specific abbreviations","guidance":"Score based on readability for domain experts, not general audience"}]}指南
在评分前始终要求理由- 链式思维提示可以提高15-25%的可靠性
在成对比较中始终交换位置- 单次比较会受到位置偏差的影响
将评分尺度的粒度与评分标准的具体性匹配- 不要在没有详细等级描述的情况下使用1-10评分
区分客观与主观标准- 对客观标准使用直接评分,对主观标准使用成对比较
包含置信度评分- 校准以匹配位置一致性和证据强度
明确定义边界情况- 模糊的情况会导致评估差异最大
使用特定领域评分标准- 通用评分标准会产生通用(不太有用的)评估
与人工判断进行验证- 自动评估只有在与人工评估相关时才有价值
监控系统性偏差- 按标准、回应类型、模型跟踪分歧模式
迭代设计- 评价系统通过反馈循环改进
整合
此技能可与以下内容集成:
- 上下文基础- 评估提示需要有效的上下文结构
- 工具设计- 评估工具需要适当的架构和错误处理
- 上下文优化- 评估提示可以针对令牌效率进行优化
- 评估(基础)- 这个技能扩展了基础评估概念
参考文献
内部参考:
- 作为法官的大型语言模型实现模式
- 偏差缓解技术
- 指标选择指南
外部研究:
- Eugene Yan: Evaluating the Effectiveness of LLM-Evaluators
- Judging LLM-as-a-Judge (Zheng et al., 2023)
- G-Eval: NLG Evaluation using GPT-4 (Liu et al., 2023)
- Large Language Models are not Fair Evaluators (Wang et al., 2023)
本系列相关技能:
- 评估 - 基础评估概念
- 上下文基础 - 用于评估提示的上下文结构
- 工具设计 - 构建评估工具
技能元数据
创建:2024-12-24
最后更新: 2024-12-24
作者: Muratcan Koylan
版本: 1.0.0
限制
- 仅当任务明确符合上述描述的范围时才使用此技能。
- 不要将输出视为环境特定验证、测试或专家审查的替代品。
- 如果缺少所需的输入、权限、安全界限或成功标准,请停下来并要求澄清。