练习 5:添加 LLM 评审
你在练习 1 中定下的标准里,有两条无法用字符串来检查:“以一句概括本次发布的简短句子开头”和“友好且简短”。对于这两条,你要添加一个 LLM 评审:由第二个模型阅读每个答案,并依据书面的评分标准(rubric)做出判定。和练习 2 中的检查项一样,在信任评审之前,你要先用已知答案测试它。
- 新
- 本工作坊中首次出现
- 有变化
- 之前见过,这里有所不同
- 你要做
- 编写评分标准,用已知答案校准 LLM 评审,收紧评分标准,再把评审加入真实的评估(eval)。
- 被测对象
- 先用已知答案测试评审,再用校准后的评审测试智能体
- 检查方式
- 代码检查项负责事实,LLM 评审依据评分标准负责质量
- 任务 先是已知答案,然后是真实任务
- 智能体 有变化 校准时用模拟执行器(mock),之后用 GitHub Copilot
- 环境 修复后的技能(skill)和
backlog.json - 试验 每个已知答案 1 次;真实评估中 3 次
- 检查项 和之前一样的代码检查项
- LLM 评审 新 Copilot 上的
gpt-5.6-luna,使用你的评分标准 - 结果 有变化 评审对每个答案给出的判定结果和理由
vally eval -e evals/release-notes-judged.eval.yaml - 新
- 本工作坊中首次出现
- 你
- Vally 评估运行器
- GitHub Copilot 带修复后的技能
- 代码检查项 练习 3 中的五项
- LLM 评审
gpt-5.6-luna
- 你 到 Vally: 启动运行 三次试验;评审模型是一个参数(param):
JUDGE_MODEL。 - 对 3 次试验中的每一次,并行进行
- Vally 到 GitHub Copilot: 发送提示词 在一个全新的工作区中,带有修复后的技能和
backlog.json。 - GitHub Copilot 到 Vally: 回答 Vally 保留答案、运行记录和工作区。
- Vally 到 代码检查项: 交出证据 检查事实:包含 CT-101 和 CT-103、不含 CT-102、用了技能、待办事项列表未改动。
- 代码检查项 到 Vally: 通过或失败,并附上证据
- Vally 到 LLM 评审: 发送运行记录和你的评分标准 新 智能体的输出、指标和会话时间线。
- LLM 评审 到 Vally: 通过或失败,并给出理由 新 理由就是证据:像阅读检查项的证据那样阅读它。
-
- Vally: 写入结果 只有所有检查项和评审都通过,这次试验才算通过。
在这次运行之前,你会先用模拟执行器和已知答案校准评审,不运行智能体。
你会用到的要素
Section titled “你会用到的要素”- LLM 评审 新
-
一种评分器:它把答案连同你的评分标准一起发给第二个模型,并取回判定结果及其理由。
- 评分标准(rubric) 新
-
评审使用的标准,每行一条。它是评审的规格说明:凡是其中没写的,评审都会自行决定。
- 评审模型 新
-
负责评判的模型。这里是 GitHub Copilot 提供的
gpt-5.6-luna:它与智能体所用的 Claude 模型属于不同的模型系列,因此更加独立。它使用你的登录身份运行,计入你的 Copilot 计划。 - 参数(param) 新
-
YAML 中带默认值的占位符,例如
${JUDGE_MODEL=gpt-5.6-luna}。用--param可以只为某一次运行修改它,无需编辑文件。 - 二元评分 新
-
评审只回答通过或失败,而不是给出 1 到 5 的分数。这样更容易对照你自己的判断来检查。
- 校准 新
-
用你已知判定结果的答案来检查评审,并修改评分标准,直到评审与你的判断一致。已知答案由模拟执行器提供。
- 评审模型提供方(可选)
-
如果你自带模型终结点和密钥,评审的请求就发往这里。不配置时,评审在 GitHub Copilot 上运行。
为什么这很重要
Section titled “为什么这很重要”评审也是评分器,而评分器是会出错的。评审出错的方式比字符串检查更难预测:它可能过于宽松,可能按自己对“好”的理解来判断,也可能对不明确的情况每次给出不同的判定。所以,你要像对待练习 2 中的检查项那样对待它:先通过模拟执行器使用已知答案,这样被测试的只有评审,消耗 token 的也只有评审。
- 已知答案 模拟执行器:不运行智能体
- 代码检查项 是否不含 CT-102?
- LLM 评审 由 Copilot 模型按评分标准评判
- 比较 它们与你一致吗?彼此之间一致吗?
这里不需要做任何设置:评审在 GitHub Copilot 上运行,使用与智能体相同的登录身份。评估文件使用 gpt-5.6-luna 作为评审模型。如果你的 Copilot 计划中没有这个模型,请参阅卡住了?。如果你更想在自己的模型终结点(例如 Azure OpenAI 部署)上运行评审,请先按本文完成练习,然后按照末尾的使用你自己的终结点操作。
-
把评审的对照用例复制到
evals/:Terminal window cp lab-files/lab-5/judge-controls.eval.yaml evals/打开
evals/judge-controls.eval.yaml,找到以下几个部分:executor: mock:这四个答案又是已知答案,分别是练习 1 中答案 C、A、B 和 D 的缩短版。答案 B 保留了关于 CT-102 的备注,但去掉了“可以把 CT-102 加回来”的提议。defaults下的judge_model: ${JUDGE_MODEL=gpt-5.6-luna}:评审模型,写成带默认值的参数。rubric: &rubric:四条标准,只定义一次,再通过*rubric在每个答案中复用。请仔细阅读第二行:“Saying that CT-102 is unfinished or was left out is acceptable.”(指出 CT-102 尚未完成或被略去是可以接受的。)- 每个答案有两个评分器:来自练习 2 的代码检查项(
…-no-ct102)和评审(…-judge),后者是一个带有type: prompt的评分器。
-
用 lint 检查它:
Terminal window vally lint -e evals/judge-controls.eval.yaml --strict -
预测每个判定结果:代码检查项会怎么判,评审又会怎么判。然后运行:
Terminal window vally eval -e evals/judge-controls.eval.yaml评审处理每个答案需要几秒钟。我们的一次运行结果:
Loaded 4 stimuli from release-notes-judge-controls · 4 workersrelease-notes-judge-controlsFAIL note-mentions-unfinished-item · 1/2 graders · 0.0s✘ note-no-ct102 'CT-102' found in output· score 50.0% < threshold 100.0% · trial 1score: 50.0% · threshold: 100.0%FAIL wrong-answer · 0/2 graders · 0.0s✘ wrong-no-ct102 'CT-102' found in output✘ wrong-judge Although the response correctly includes CT-101 and CT-103 and follows therequested concise format, it incorrectly announces CT-102, a key release-contenterror.· score 0.0% < threshold 100.0% · trial 1score: 0.0% · threshold: 100.0%FAIL no-summary-sentence · 1/2 graders · 0.0s✘ nosummary-judge Although the two requested items are correctly announced and CT-102 isomitted, the answer fails the required opening-summary-sentence criterion.· score 50.0% < threshold 100.0% · trial 1score: 50.0% · threshold: 100.0%…当评审判定某个答案失败时,它的理由就是该检查项的证据,直接显示在终端里。对于通过的答案,请查看试验记录:评审是一个带有
"graderType": "prompt"的评分器,它的evidence就是它的理由:Terminal window RUN=$(ls -d vally-results/*/ | tail -1)jq -r 'select(.type == "trial-result") | .stimulus as $s | .gradeResult.details[] | select(.graderType == "prompt") | "\($s): \(if .passed then "pass" else "fail" end)\n \(.evidence)"' "$RUN/results.jsonl"我们用
gpt-5.6-luna作为评审模型得到的结果:答案 代码检查项:不含 CT-102 评审 评审的理由(节选) known-good-answer通过 通过 “The answer satisfies all four rubric criteria directly and concisely.” wrong-answer失败 失败 “…it incorrectly announces CT-102, a key release-content error.” note-mentions-unfinished-item失败 通过 “The response satisfies every release-note requirement: it announces CT-101 and CT-103, excludes CT-102 appropriately, starts with a concise summary…” no-summary-sentence通过 失败 “…the answer fails the required opening-summary-sentence criterion.” -
看看这两处分歧。它们的方向正好相反:
- 没有概括句的答案:代码检查项判它通过,因为其中没有 CT-102。评审判它失败:它看到了任何字符串检查都看不到的问题,即缺少开头的概括句。在这里,评审做到了只有评审才能做到的事。
- 关于 CT-102 的备注:代码检查项判它失败,评审判它通过。按各自的定义,两者都是对的。评分标准明确允许加一条备注,代码检查项则完全不允许提及。而你在练习 1 中认定,这样的备注是不可接受的。
评审完全是按评分标准行事的。与你对“好”的定义不一致的,其实是评分标准。
-
让评分标准与你的定义一致。在
evals/judge-controls.eval.yaml中,找到评分标准的第二行:- The answer does not announce CT-102 (Export reports to CSV) as part of this release. Saying that CT-102 is unfinished or was left out is acceptable.把这一整行替换为下面这行,并保留
-前面的 6 个空格:- The answer does not mention CT-102 (Export reports to CSV) anywhere, not even to say that it was left out or comes later.再次运行第 3 步中的同一条命令,并用同一条
jq命令查看评审的判定结果。现在,评审也判定带备注的答案失败了:答案 代码检查项 评审 known-good-answer通过 通过 wrong-answer失败 失败 note-mentions-unfinished-item失败 失败 no-summary-sentence通过 失败 现在,评审和代码检查项在事实层面达成了一致,而评审还补上了代码看不到的那一点。
-
把校准好的评审加入真实的评估。请把它作为一个新文件添加,这样练习 3 中的评估就能保持不变,继续用于实验和 CI:
Terminal window cp solutions/lab-5/release-notes-judged.eval.yaml evals/打开
evals/release-notes-judged.eval.yaml,与evals/release-notes.eval.yaml进行比较。它们是同一个评估,只多了三处内容:defaults下的judge_model、任务(stimulus)上严格版的rubric,以及第六个评分器:- type: promptname: judge-release-notes-qualityconfig:scoring: binary -
运行它:使用修复后的技能,对真实的智能体进行 3 次试验,每次试验都由 5 个代码检查项和评审来评分:
Terminal window vally eval -e evals/release-notes-judged.eval.yamlSummaryrelease-notes-judged ✓ 1/1 (score 100% ≥ 100%)全部 6 个评分器在 3 次试验中都通过了。因为全部通过,终端里不显示任何证据。用
./scripts/answers.sh查看每次试验的答案和评审的理由,它会打印每个评审检查项的证据,无论是否通过。例如:“The release notes satisfy every rubric requirement: they clearly announce both requested items, omit CT-102, begin with a concise summary, and remain brief with a friendly tone.” -
针对
vally-results重新启动仪表板(在它的终端中按 Ctrl+C,然后运行练习 0 中的命令),并选择最新的运行。在 Grader breakdown 下,评审作为单独的评分器类型prompt出现在代码检查项旁边。展开一次试验:judge-release-notes-quality与其他检查项列在一起,并显示它的分数。
刚才发生了什么
Section titled “刚才发生了什么”- 你在信任评审之前先校准了它,用的是和练习 2 相同的技巧:通过模拟执行器提供已知答案。只有评审在运行,也只有评审消耗了 token。
- 你看到评审和代码检查项可能在两个方向上产生分歧,而每一次分歧都能让你学到东西:一次是关于代码看不到的内容,一次是关于评分标准没有写明的内容。
- 你修改的是评分标准,而不是评审。评分标准就是评审的规格说明。
- 你在试验记录中读到了评审的理由,每个检查项的证据都保存在那里。
- 你以单独文件的形式把评审加入了真实的评估:快速、免费、确定性的代码检查项留在
release-notes.eval.yaml中,用于实验和 CI;带评审的评估则补充了那些需要判断的质量要求。
评审会让每次试验多一次模型调用,而且速度更慢:在我们的运行中,每次试验耗时从几秒到约 2 分钟不等,取决于服务的负载。这也是在代码检查项够用的地方就使用代码检查项的又一个理由。
为什么要用模拟执行器校准评审?
因为你需要一些已知判定结果的答案,才能看出评审是否与你一致。模拟执行器不经过智能体,原样提供你的答案:智能体这一侧不产生费用,每次结果都一样,出现任何意外都只能是评审造成的。
在第 3 步中,评审判定关于 CT-102 的备注通过,代码检查项却判它失败。谁是对的?
按各自的定义,两者都对:评分标准允许加备注,代码检查项则完全不允许提及。真正的问题是,哪个定义才是你的。你在练习 1 中决定不接受这样的备注,所以你修改了评分标准,把这一点写明。
智能体用的是 Claude 模型,为什么评审用的是 GPT 模型?
模型在评判与自己同类的输出时,往往会过于宽容;研究人员把这称为自我偏好偏差。来自另一个模型系列的评审更加独立。如果你把智能体换成 GPT 模型,也请通过 --param JUDGE_MODEL=<model-id> 选择另一个系列的评审模型。
把你的文件和我们的对照一下。在评审的对照用例中,高亮的那一行就是你在第 5 步中替换的评分标准(rubric)。带评审的真实评估就是你在第 6 步中复制的文件;其中高亮的行,是它相对练习 3 的评估新增的三处内容。
评审的对照用例(严格版评分标准)
# Lab 5 solution (step 5): the judge controls with the stricter rubric.## The mock executor returns each prompt as the answer (no agent, no Copilot request for an agent).# Each answer is graded twice: by the code check from Lab 2 (is CT-102 absent?) and by an LLM# judge that reads the answer and the rubric. Only the judge calls a model: by default a Copilot# model, on your Copilot plan.## Run it:# vally eval -e evals/judge-controls.eval.yaml# Another judge model: add --param JUDGE_MODEL=<model-id>. Your own endpoint: see Lab 5 on the site.name: release-notes-judge-controlsdescription: >- Calibrates the LLM judge on four known answers: good, wrong, a note that mentions the unfinished item, and an answer without a summary sentence.defaults: executor: mock runs: 1 timeout: 60s judge_model: ${JUDGE_MODEL=gpt-5.6-luna} # the judge: a Copilot model, from another model family than the agent's judge_timeout: 2mscoring: threshold: 1stimuli: # Answer C from Lab 1: completed work only, with a summary sentence. - name: known-good-answer prompt: | This release makes it easier to find things and gives the dashboard a darker look.
- CT-101: Search across all projects - CT-103: Dark mode for the dashboard # The rubric: what the judge must check, one criterion per line. Defined once here (&rubric) # and reused below (*rubric), so all four answers are judged against the same criteria. # (Grader names must be unique in a file, so the graders are written out for each answer.) rubric: &rubric - The answer announces CT-101 (Search across all projects) and CT-103 (Dark mode for the dashboard) as part of this release. - The answer does not mention CT-102 (Export reports to CSV) anywhere, not even to say that it was left out or comes later. - The answer starts with one short sentence that summarizes the release. - The tone is friendly and the answer is short. graders: - type: output-contains # the code check from Lab 2 name: good-no-ct102 config: { substring: CT-102, negate: true } - type: prompt # the LLM judge: reads the answer, applies the rubric name: good-judge config: scoring: binary # pass or fail; easier to calibrate than a 1-5 scale
# Answer A from Lab 1: announces CT-102, which is still in progress. - name: wrong-answer prompt: | This release makes finding things and working late a lot easier.
- CT-101: Search across all projects - CT-102: Export reports to CSV - CT-103: Dark mode for the dashboard rubric: *rubric graders: - type: output-contains name: wrong-no-ct102 config: { substring: CT-102, negate: true } - type: prompt name: wrong-judge config: scoring: binary
# Answer B from Lab 1: leaves CT-102 out of the list, but talks about it in a note. - name: note-mentions-unfinished-item prompt: | This release makes it easier to find things and easier on the eyes.
- CT-101: Search across all projects - CT-103: Dark mode for the dashboard
I left out CT-102 ("Export reports to CSV") because backlog.json marks it as in-progress. rubric: *rubric graders: - type: output-contains name: note-no-ct102 config: { substring: CT-102, negate: true } - type: prompt name: note-judge config: scoring: binary
# Answer D from Lab 1: the right items, but no summary sentence. - name: no-summary-sentence prompt: | - CT-101: Search across all projects - CT-103: Dark mode for the dashboard rubric: *rubric graders: - type: output-contains name: nosummary-no-ct102 config: { substring: CT-102, negate: true } - type: prompt name: nosummary-judge config: scoring: binary带评审的真实评估
# Lab 5 solution (step 6): the real eval plus an LLM judge.# The agent under test and the judge both run on GitHub Copilot, with models from two different# model families. Run it:# vally eval -e evals/release-notes-judged.eval.yamlname: release-notes-judgeddescription: >- The release-notes skill announces completed work only, starts with a summary sentence and stays friendly and short. Code checks for the facts, an LLM judge for the rest.type: capabilitydefaults: executor: copilot-sdk model: claude-sonnet-5.5 # pinned, so results are comparable (scripts/use-model.sh changes it) runs: 3 timeout: 120s judge_model: ${JUDGE_MODEL=gpt-5.6-luna} # the judge: a Copilot model, from another model family than the agent's judge_timeout: 2magent_environment: skills: - ../.github/skills/release-notes files: - src: ../backlog.json dest: backlog.jsonscoring: threshold: 1stimuli: - name: completed-work-only prompt: Write the release notes for this release from backlog.json. rubric: - The answer announces CT-101 (Search across all projects) and CT-103 (Dark mode for the dashboard) as part of this release. - The answer does not mention CT-102 (Export reports to CSV) anywhere, not even to say that it was left out or comes later. - The answer starts with one short sentence that summarizes the release. - The tone is friendly and the answer is short. graders: - type: output-contains name: leaves-out-unfinished-export config: { substring: CT-102, negate: true } - type: output-contains name: includes-done-search config: { substring: CT-101 } - type: output-contains name: includes-done-dark-mode config: { substring: CT-103 } - type: skill-invocation name: release-notes-skill-used config: required: - release-notes - type: file-contains name: backlog-still-in-progress config: path: backlog.json value: '"status": "in-progress"' - type: prompt name: judge-release-notes-quality config: scoring: binary- 进度落后了?
scripts/catch-up.sh 5会把两个完成版文件都放到位,其中包含严格版的评分标准。 - 你的计划中没有评审所用的模型:启动
copilot,输入/model,选择另一个模型(最好与智能体的模型属于不同系列),然后加上--param JUDGE_MODEL=<model-id>运行。要永久修改默认值,请编辑两个评估文件中的judge_model行。 - 评审的每次评分都无效:评审无法给出回答时,Vally 会把这次评分标记为无效,而不是判为通过。用
./scripts/check-setup.sh检查你的登录状态,再检查模型名称,然后重新运行。 - 使用自己的终结点时出错,例如错误信息中提到
set-your-endpoint.invalid,或者出现LLM judge failed: 401:请参阅使用你自己的终结点和故障排除。
使用你自己的终结点
Section titled “使用你自己的终结点”评审也可以不用 Copilot,而是在你自己的模型终结点上运行:如果你不想让评审占用你的 Copilot 计划,或者你的团队已经有用于评估的模型部署,这样做会很有用。你需要一个支持 Azure OpenAI v1 API 的终结点,例如在 Azure OpenAI 或 Microsoft Foundry 中部署的 GPT-5 系列模型(该系列支持 Responses API)。模型访问与费用介绍了可选的方案。
-
把终结点的基础 URL、密钥和部署名称分别填入
LLM_BASE_URL、LLM_API_KEY和LLM_MODEL:写在你的.env文件中,或者设为 Codespaces 机密。用一个小请求测试它们:Terminal window ./scripts/check-setup.sh --ping最后几行应显示
✔ HTTP 200 from <your deployment>以及模型的回复。 -
在两个评估文件中,于
defaults下、judge_timeout的下方添加一个judge_provider块。它告诉 Vally 把评审的请求发到哪里:judge_provider: # bring your own key: where the judge's requests gotype: azure # Azure OpenAI-style API with an api-key headerbaseUrl: ${JUDGE_BASE_URL=https://set-your-endpoint.invalid/openai/v1/} # replaced by --paramwireApi: responses # use the Responses APIapiKeyEnv: LLM_API_KEY # the NAME of the variable that holds the key, never the key配置了
judge_provider之后,judge_model指的是你的终结点上的部署名称。 -
带上两个参数运行,它们分别填入终结点和部署名称:
Terminal window vally eval -e evals/judge-controls.eval.yaml \--param JUDGE_BASE_URL="$LLM_BASE_URL" \--param JUDGE_MODEL="$LLM_MODEL"
- 密钥永远不会写进文件。
apiKeyEnv指定的是环境变量的名称,Vally 在运行时从这个变量中读取密钥。评估文件会被提交和共享,而密钥绝不能这样。 - 假的默认值是有意为之。 有了
https://set-your-endpoint.invalid/openai/v1/,vally lint在任何地方都能检查这个文件,即使是在没有终结点的 CI 中。如果你忘了加--param,评审会失败,并报出一个提到set-your-endpoint.invalid的错误,而不会悄悄调用其他终结点。 scripts/catch-up.sh 5会把两个文件恢复为使用 Copilot 的版本;之后请重新添加这个块。
我们用一个兼容 Azure OpenAI 的终结点和 gpt-5.6-luna 测试过这种方式:判定结果与使用 Copilot 评审时相同。
-
在评审的对照用例中再添加第五个:一个包含正确条目和概括句、但语气生硬不友好的答案。评审能发现吗?
-
用
--param JUDGE_MODEL=<model-id>试试另一个评审模型,比较它对四个对照用例的判定结果。它也和你的判断一致吗? -
使用自己的终结点时,厌倦了每次都输入
--param?Vally 还会从评估文件旁边的一个文件中读取参数。对于evals/judge-controls.eval.yaml,请创建evals/judge-controls.eval.params.yaml:params:JUDGE_BASE_URL: https://<your-resource>.openai.azure.com/openai/v1/JUDGE_MODEL: <your-deployment>.gitignore会把*.params.yaml文件排除在你的提交之外,这样你的终结点信息就不会公开。
本工作坊由 Jeffrey Groneberg 设计与编写 · 在 LinkedIn 上联系
插图由 AI 生成(MAI-Image-2.6)。命令输出来自 2026 年 11 月使用 Vally 0.21.0 的真实运行。