跳到主内容
@wquguru
精选88Microsoft Foundry 博客(RSS)技巧与观点

微软Foundry博客:用Rubric将LLM判断与代码计算分离

Let the LLM Judge, Let Code Do the Math: Using a Rubric to Size Work Consistently

原文
发到 X
推荐理由

Agent落地常遇评分不稳定难题,这篇给出了“判断归LLM、计算归代码”的完整工作流与配置细节,建议工程同学直接参考其Rubric设计思路优化现有链路。

Introduction

引言

Many AI workflows end with the same request: "Give this item a score." A priority, a risk level, a quality grade. The model reads something, and you need a number or a label back.

许多 AI 工作流的终点都是同一个请求:“给这个项目打个分。”一个优先级、一个风险等级、一个质量评级。模型读取某些内容,你需要返回一个数字或标签。

Take support ticket triage. Tickets arrive all day, and each one needs an urgency level so the right ones are handled first. The obvious move is to give the ticket to a model and ask, "Rate the urgency of this ticket from 1 to 5."

以支持工单的分级为例。工单全天不断涌入,每个工单都需要一个紧急程度等级,以便优先处理正确的工单。显而易见的做法是将工单交给模型并询问:“请对这张工单的紧急程度进行 1 到 5 的评分。”

It works in a demo. It falls apart in production. This post covers why, what we replaced it with, and what we got out of it.

这在演示中可行,但在生产环境中却行不通。本文涵盖其原因、我们替换它的方案以及从中获得的收益。

The Problem: A Number From a Model Is a Number You Can't Defend

问题:来自模型的数字是你无法辩护的数字

When we asked a model for a score directly, we hit the same issues repeatedly:

当我们直接向模型索要评分时,我们反复遇到以下问题:

  • Inconsistency. The same ticket could score a 3 on one run and a 5 on the next. Two near-identical tickets could land on different urgency levels with no clear reason.
  • No explanation. "It's a 4" is not an answer a reviewer can challenge. There was no way to see which aspect of the ticket drove the number.
  • Hidden arithmetic. Models are not reliable calculators. Asking one to weigh several factors and apply thresholds inside a prompt is arithmetic in disguise, and small prompt edits shifted results unpredictably.
  • Nothing to tune. If urgency ran too high for a certain kind of ticket, the only lever was to rewrite the prompt and hope. Every change risked side effects elsewhere.
  • No way to measure improvement. A single opaque number is hard to compare against what an experienced agent would say, so we couldn't tell whether a change made things better or worse.
  • 不一致性。同一张工单在一次运行中可能得分为 3,而在下一次运行中得分为 5。两张几乎相同的工单可能会落在不同的紧急程度等级上,且没有明确的原因。
  • 缺乏解释。“它是 4”不是一个审查者可以质疑的答案。无法看到是哪个方面的工单导致了这个数字。
  • 隐藏的算术运算。模型不是可靠的计算器。要求模型在提示词中权衡多个因素并应用阈值,这实际上是伪装起来的算术运算,而微小的提示词编辑会导致结果不可预测地变化。
  • 无可调优的参数。如果某种特定类型的工单紧急程度偏高,唯一的调整手段就是重写提示词并碰运气。每次更改都可能带来其他方面的副作用。
  • 无法衡量改进效果。单个不透明的数字很难与经验丰富的代理所说的内容进行对比,因此我们无法判断某项更改是使情况变好还是变坏。

The root cause is that we asked one component to do two jobs at once: make a judgment about the ticket and turn that judgment into a number. Models are good at the first and unreliable at the second.

根本原因在于我们要求一个组件同时完成两项工作:对工单做出判断,并将该判断转化为数字。模型擅长前者,但在后者上不可靠。

The Idea: Separate Judgment From Math

理念:将判断与数学计算分离

We split the two jobs:

我们将这两项工作分开:

  • The LLM only answers a checklist. A fixed list of binary Yes/No questions about the ticket, plus a short rationale.
  • Code computes the score. Counting, bucketing, weighting, and mapping to a final level all happen deterministically, outside the model.
  • LLM 仅回答检查清单。关于工单的固定二元(是/否)问题列表,加上简短的理由说明。
  • 代码负责计算分数。计数、分桶、加权以及映射到最终等级都在模型外部确定性地完成。

The model never sees a score, a weight, or a threshold, and it must not return one. If it does, that's a contract violation.

模型永远看不到分数、权重或阈值,也不应返回这些内容。如果它返回了,那就是违反了契约。

This pattern is often called a checklist evaluation (CheckEval). It sits underneath a more familiar idea, the rubric: a set of weighted dimensions that together describe what you are scoring.

这种模式通常被称为检查表评估(CheckEval)。它建立在更为人熟知的概念——量规(rubric)之下:一组加权维度,共同描述你所评分的内容。

Where Rubrics Come From: Microsoft Foundry Rubric Evaluators

量规的来源:Microsoft Foundry 量规评估器

We didn't invent the rubric idea. Microsoft Foundry ships rubric evaluators, which score an agent or model response against custom criteria (called dimensions) using an LLM as the judge. Their purpose is to let you define what "good" means for your use case and apply that judgment consistently.

我们并非首创评分标准(rubric)的概念。Microsoft Foundry 提供 rubric 评估器,它使用大语言模型作为裁判,根据自定义标准(称为维度)对智能体或模型的响应进行打分。其目的是让你为自身用例定义什么是“好”,并一致地应用该判断。

The core concepts line up closely with what we built:

核心概念与我们构建的内容高度契合:

Foundry rubric conceptHow we used it
Dimensions: custom criteria, each with a description and a weightOur scoring dimensions and their weights
1–5 rating per dimension, combined as a weighted averageThe same shape: per-dimension 1–5 scores and a weighted aggregate
Pass/fail checklist mode for quality rubricsThe inspiration for our binary Yes/No questions
Editable, versioned rubrics: adjust descriptions, weights, and thresholds, and save changes as new versionsOur versioned config, tuned without code changes
Rubric health diagnostics that surface overlapping or low-coverage criteriaThe same concern as keeping dimensions independent
Continuous evaluation against live trafficOur reference-free check on live results
Foundry rubric 概念我们的用法
维度:自定义标准,每个标准都有描述和权重我们的评分维度及其权重
每个维度按 1–5 分评级,以加权平均方式组合结构相同:按维度的 1–5 分评分及加权汇总
用于质量评分标准的通过/不通过清单模式我们二元是/否问题的灵感来源
可编辑、带版本控制的评分标准:调整描述、权重和阈值,并将更改保存为新版本我们的带版本控制的配置,无需代码更改即可微调
评分标准健康诊断功能,可揭示重叠或覆盖度低的准则这与保持维度独立性的关切相同
针对实时流量的持续评估我们对实时结果进行的无参考检查

Foundry's quality rubrics report either a 1–5 rating per dimension, which it normalizes to 0.0–1.0, or a pass/fail checklist. We combine the two ideas: a binary checklist under each dimension whose Yes-count becomes the 1–5 score, with all arithmetic done in code. The model still acts as the judge, but only on questions a person can verify.

Foundry 的质量评分标准会报告每个维度的 1–5 分评级(归一化为 0.0–1.0),或通过/不通过的清单。我们将这两种思路结合起来:在每个维度下设置一个二元清单,其中“是”的数量成为 1–5 分的评分,所有算术运算均在代码中完成。模型仍然充当裁判,但仅针对人类可以验证的问题进行评判。

Two ways to use this in practice:

在实践中有两种使用方式:

  • As the scoring mechanism itself. Define your dimensions and weights in a rubric and let the judge rate them.
  • As the evaluation layer. Keep your own deterministic scoring, and use a rubric evaluator to check whether the judge's answers and final scores match your team's standards.
  • 作为评分机制本身。在评分标准中定义你的维度和权重,让裁判对其进行评级。
  • 作为评估层。保留你自己确定性的评分逻辑,并使用 rubric 评估器来检查裁判的答案和最终评分是否符合团队的标准。

Microsoft's guidance is also a good starting point for authoring: generate a rubric from your context to get a grounded baseline, then refine it by hand until its scores match your team's judgment.

微软的指导方针也是编写评分标准的良好起点:根据你的上下文生成一份评分标准以获得扎实的基线,然后通过手工细化,直到其评分与团队的判断相符。

How the Rubric Works

评分标准的工作原理

1. Pick a few independent dimensions

1. 选择几个相互独立的维度

A rubric breaks the thing you care about into dimensions. Each should capture something different, with no overlap. For ticket urgency, we might use three:

评分标准将你关心的内容分解为多个维度。每个维度应捕捉不同的方面,且互不重叠。对于工单紧急程度,我们可能会使用以下三个维度:

DimensionWhat it measuresExample weight
ImpactHow much is affected: users, revenue, data0.40
SeverityHow badly it is broken: outage, data loss, workaround available or not0.40
Time pressureHow soon it matters: deadlines, SLAs, escalations0.20
维度衡量内容示例权重
影响范围受影响程度:用户、收入、数据0.40
严重程度损坏程度:服务中断、数据丢失、是否有变通方案0.40
时间压力紧迫程度:截止日期、SLA、升级处理0.20

Keeping dimensions separate matters. A rare bug that corrupts data and a minor glitch that affects every user are both "urgent", for different reasons. A single "how urgent?" question blurs that distinction.

保持各个维度相互独立至关重要。导致数据损坏的罕见缺陷和影响每位用户的微小故障,虽然都被标记为“紧急”,但原因各不相同。单一的“有多紧急?”提问会模糊这种区别。

2. Ask binary questions for each dimension

2. 针对每个维度提出二元问题

Each dimension gets a short list of Yes/No questions. For example:

每个维度对应一份简短的是/否问题列表。例如:

  • Impact: Does it affect more than one customer? Does it affect a paid or critical account? Does it block a core workflow?
  • Severity: Is the service unavailable or failing outright? Is there data loss or corruption? Is there no workaround?
  • Time pressure: Is an SLA about to be breached? Has the customer escalated? Is there a hard deadline mentioned?
  • 影响范围:是否影响超过一名客户?是否影响付费账户或关键账户?是否阻塞了核心工作流?
  • 严重程度:服务是否不可用或完全失效?是否存在数据丢失或损坏?是否没有变通方案?
  • 时间压力:SLA(服务等级协议)是否即将被违反?客户是否已升级投诉?是否提到了硬性截止日期?

Binary questions are the key design choice. A model asked "rate the severity from 1 to 5" will drift. A model asked "is there data loss or corruption?" has a narrow, checkable job. A human can look at the answer and say right or wrong.

二元问题是关键的设计选择。如果要求模型“从 1 到 5 对严重程度进行评分”,其输出会产生漂移;而如果问“是否存在数据丢失或损坏”,则任务狭窄且可验证。人工可以查看答案并判断对错。

3. Turn answers into scores with plain arithmetic

3. 使用简单算术将答案转化为分数

For each dimension, count the "Yes" answers and map the count to a score:

对于每个维度,统计“是”的数量并将其映射为分数:

dimensionScore = (number of "Yes" answers) + 1 → 1 to 5

dimensionScore = (“是”的数量) + 1 → 1 到 5

Then combine the dimensions with a weighted average:

然后通过加权平均合并各维度:

aggregate = Σ ( weight × dimensionScore ) → 1 to 5

aggregate = Σ (权重 × dimensionScore) → 1 到 5

Because the weights add up to 1, the aggregate stays on the same scale as the dimension scores. Cutoffs then map the aggregate to a level such as Low, Normal, High, Urgent, Critical.

由于权重之和为 1,聚合分数与维度分数保持在同一量级上。随后通过阈值将聚合分数映射到低、正常、高、紧急、严重等级别。

4. Map the level to whatever you need downstream

4. 将级别映射到下游所需的任何内容

The level is a neutral, shared currency. A final, configurable step translates it into what the consumer needs: a queue, a response-time target, or an escalation. The top level can also trigger something special, such as paging an on-call engineer or routing to a human for review, instead of being treated as just another number.

该级别是一种中立、通用的度量标准。最后一步是可配置的,将其转换为消费者所需的内容:队列、响应时间目标或升级流程。最高级别还可以触发特殊操作,例如呼叫值班工程师或路由给人工审核,而不是仅仅被视为另一个数字。

Guardrails on the Model

模型的护栏

The judging model runs under strict rules:

评判模型在严格规则下运行:

  • Temperature 0 and structured output. The response is a JSON object with Booleans and a short rationale per dimension, nothing else.
  • Answer only the questions provided. It can't add, drop, or rename questions.
  • No numbers. It must never return scores, levels, or weights.
  • Ground every answer in the provided context. If the ticket doesn't support a "Yes", the answer is "No". Treating absence of evidence as No keeps the model from over-claiming and keeps scores reproducible.
  • Batch where possible. Scoring several items per call, with all dimensions at once, reduces cost and helps the model answer similar items consistently.
  • Temperature 设为 0 并使用结构化输出。响应是一个 JSON 对象,包含布尔值和每个维度的简短理由,无其他内容。
  • 仅回答提供的问题。不得添加、删除或重命名问题。
  • 不包含数字。绝不允许返回分数、级别或权重。
  • 所有回答必须基于提供的上下文。如果工单不支持“是”,则答案为“否”。将缺乏证据视为“否”,可防止模型过度断言并保持分数的可复现性。
  • 尽可能批量处理。每次调用中同时评估多个项目的所有维度,可降低费用并帮助模型对相似项目给出一致的回答。

Everything Lives in Config

一切皆由配置决定

The dimensions, questions, weights, score buckets, thresholds, and final mappings live in one versioned configuration file, not in code or in the prompt. Variants can override just the parts that differ: for example, a billing queue might add a question or weigh time pressure more heavily.

维度、问题、权重、分数区间、阈值以及最终映射关系都存储在一个版本化的配置文件中,而非代码或提示词中。变体可以仅覆盖存在差异的部分:例如,计费队列可能会增加一个问题,或对时间压力赋予更高的权重。

That turned scoring from a prompt-engineering problem into a tuning problem. Changing how a dimension counts is a small config change that can be reviewed, versioned, and rolled back.

这使得评分从提示工程问题转变为调优问题。更改某个维度的计算方式只需进行微小的配置调整,且该调整可被审查、版本控制并回滚。

Every Score Leaves an Audit Trail

每次评分都会留下审计轨迹

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件