0130 秒速览:这份文档在说什么
01The 30-second version
先讲一个场景。一个客服 Agent 回答了用户关于处方剂量的问题,模型报告自己「0.92 置信」。答案是错的。事后复盘发现:在这家公司自己的标注留出集上,模型说 0.9 的那批回答,实际准确率只有 64%。上线前没有人测过校准。而升级规则写的是「置信度低于 0.5 就转人工」——可模型几乎从来不报低于 0.7 的数。
Start with a scene. A support agent answers a question about prescription dosage. The model reports 0.92 confidence. The answer is wrong. The post-mortem finds that on the company's own labelled hold-out set, answers where the model said 0.9 were correct only 64% of the time. Nobody measured calibration before launch. And the escalation rule read "escalate if confidence is below 0.5" — while the model almost never reported below 0.7.
这不是「模型不够聪明」的问题,是门控信号本身没有被测量过的问题。一个从未与真实正确率对照过的置信度数字,不管它长得多像概率,都不是概率。
This is not a "the model isn't smart enough" problem. It is a the gating signal was never measured problem. A confidence number that has never been checked against real correctness is not a probability, however much it looks like one.
整份文档要建立的,是下面这条流水线。你会发现它每一次都长成同一个形状:采一个原始信号 → 在留出标注集上量出它偏了多少 → 拟合一个校准器把它映射成真正的概率 → 用这个概率设门槛 → 分布漂移时重新校准。
What this document builds is the pipeline below. It has the same shape every time: collect a raw signal → measure how miscalibrated it is on a held-out labelled set → fit a calibrator that maps it to a real probability → set your threshold on that probability → recalibrate when the distribution shifts.
本文假设你已经在跑一个会调用工具、有多轮的 LLM Agent,并且已经或打算给它加人工升级路径。不需要统计学背景——所有指标都会先用大白话解释。
This assumes you already run an LLM agent that calls tools over multiple turns, and that you have — or plan to add — a human escalation path. No statistics background needed; every metric is explained in plain language first.
02为什么「模型自己说的置信度」是表演
02Why the model's stated confidence is theatre
自述置信度(verbalized confidence):你在 prompt 里加一句「顺便给出你的置信度 0–1」,模型在答案旁边输出的那个数。它是模型生成出来的一串 token,不是模型内部对这个答案正确性的概率估计。这两件事的区别,是这一整节的全部内容。
Verbalized confidence: the number a model prints next to its answer when your prompt says "also give your confidence from 0 to 1." It is a sequence of tokens the model generated, not the model's internal probability that the answer is correct. The gap between those two things is what this whole section is about.
Future AGI 的工程博客把三个结构性原因梳理得很清楚(以下为该文观点,非官方规范):
Future AGI's engineering blog lays out three structural reasons (these are that article's arguments, not an official specification):
原因一:预训练根本没教过校准
Reason 1: pretraining never taught calibration
模型被训练去预测下一个 token,不是去预测「我这个答案对不对」。它内部的 token 概率对「下一个 token 是什么」这件事是校准良好的——但「我有 90% 把握」这句话本身,只是模型基于训练语料里置信话术的分布,选出来的一串词。它和底层论断的内部概率之间,没有直接连接。
The model is trained to predict the next token, not to predict whether the resulting answer is right. Its internal token probabilities are well calibrated for the next-token task — but the sentence "I'm 90% sure" is itself a token sequence chosen from whatever confidence-language patterns appeared in training. It has no direct link to the internal probability of the underlying claim.
原因二:RLHF 放大了过度自信
Reason 2: RLHF amplifies overconfidence
奖励模型偏好听起来果断的回答。模型学到「含糊其辞会被扣分」,于是就比它应该的更少地含糊。Tian 等人在 EMNLP 2023 的工作(《Just Ask for Calibration》)及后续研究显示,跨 GPT-4、Claude、Llama-2 系列,自述置信度与准确率单调相关但系统性偏高,而且偏差最大的区间正是 0.7–1.0 ——恰恰是高风险、高置信决策发生的地方。
Reward models prefer answers that sound decisive. The model learns that hedging is penalised, so it hedges less than it should. Tian et al. (EMNLP 2023, "Just Ask for Calibration") and follow-up work show that across the GPT-4, Claude and Llama-2 families, verbalized confidence is monotonically related to accuracy but systematically biased upward, and the gap is largest in the 0.7–1.0 region — exactly where high-stakes, high-confidence decisions live.
原因三:自述是「事后」的
Reason 3: the self-report is post-hoc
当你问「你有多确定」时,答案已经写在纸上了。模型这时生成的数字,只是与 prompt 给的评分标准保持一致,不是对正确性的内部估计。换一套 prompt 措辞,你会得到一套不同的刻度。
By the time you ask "how sure are you," the answer is already on the page. The number the model then generates is consistent with whatever rubric your prompt supplied — not with an internal estimate of correctness. A different prompt produces a different scale.
「LLM 自述的置信度是一种表演。模型说『95% 确定』,却有 30% 的时候是错的。」——Future AGI 工程博客(厂商观点)
"LLM-stated confidence is theater. The model says '95% sure' and is wrong 30% of the time." — Future AGI engineering blog (vendor perspective)
换个说法
想象你让一个很会说话的实习生汇报进度。他每次都说「肯定没问题」——不是因为他真的评估过风险,而是因为他学会了「说没问题的人显得靠谱」。你要判断这个项目会不会翻车,不能听他嘴上说什么,得看他写代码时在哪些地方反复删改(这就是 logprob),或者让他把同一件事讲五遍,看五遍讲的是不是同一个意思(这就是语义熵)。
Put another way
Picture a smooth-talking intern reporting progress. Every time, he says "definitely on track" — not because he assessed the risk, but because he learned that people who sound sure look reliable. To judge whether the project will derail, don't listen to what he says. Watch where he keeps deleting and rewriting code (that's logprobs), or make him explain the same thing five times and check whether the five explanations mean the same thing (that's semantic entropy).
结论不是「自述置信度毫无价值」,而是它只能当集成里的一个信号,永远不做主信号。它单调相关这件事本身,让它作为特征喂进一个训练好的校准器时仍然有用。
The conclusion is not "verbalized confidence is worthless." It is that it can be one signal in an ensemble, never the primary one. The fact that it is monotonically related to accuracy still makes it a useful feature to feed into a trained calibrator.
03三种能用的信号
03Three signals you can actually use
读者读到这里的自然疑问是:那我用什么?公开可得的替代信号主要有两类——模型内部的 token 概率,和多次采样之间的分歧。再加上第三条路:直接训一个小分类器。
The natural next question: so what do I use instead? Two families of signal are publicly available — the model's internal token probabilities, and disagreement across repeated samples. Plus a third route: train a small classifier directly.
信号 A:logprob 聚合(API 暴露 token 概率时)
Signal A: logprob aggregation (when the API exposes token probabilities)
OpenAI 的 chat completions 端点在传 logprobs=True 时会返回 top-k 对数概率;多数开放权重推理服务(vLLM、TGI、llama.cpp)默认就暴露;Anthropic 在部分端点上返回。能看到 logprob 时,两个派生信号最有用:
OpenAI's chat completions endpoint returns top-k log-probabilities when you pass logprobs=True; most open-weight inference servers (vLLM, TGI, llama.cpp) expose them by default; Anthropic returns them on certain endpoints. When logprobs are visible, two derived signals dominate:
- 承载论断的 token 上的平均 top-1 logprob——只对实体、数字、人名这些真正携带语义的位置求平均。
- top-k token 熵——每一步 top-k 分布的香农熵。熵高意味着模型在那个位置在几个都说得通的 token 之间犹豫;论断 token 上的熵尖峰,与错误强相关。
- Mean top-1 logprob over claim-bearing tokens — averaged only over entity, number and name positions that actually carry meaning.
- Top-k token entropy — Shannon entropy over the top-k distribution at each step. High entropy means the model was choosing between several plausible tokens at that position; entropy spikes on claim tokens correlate strongly with error.
一定要过滤掉填充词。「的」「和」「of」「the」这类 token 无论答案对错都接近 1.0 概率,把它们算进去会把信号冲干净。结构化输出时,只对解析出的字段 token 聚合。
Filter out filler tokens. Words like "the," "of," "and" sit at near-1.0 probability regardless of whether the answer is right; including them washes the signal out. For structured output, restrict the aggregate to the parsed field tokens.
import math
def claim_token_uncertainty(tokens, claim_mask):
# tokens: [{token, top_logprob, top_k=[(tok, logp), ...]}, ...]
# claim_mask: [bool, ...] —— True 表示这个位置承载论断
logps, entropies = [], []
for tok, is_claim in zip(tokens, claim_mask):
if not is_claim:
continue
logps.append(tok["top_logprob"])
probs = [math.exp(lp) for _, lp in tok["top_k"]]
z = sum(probs)
probs = [p / z for p in probs]
entropies.append(-sum(p * math.log(p + 1e-12) for p in probs))
return {
"mean_logprob": sum(logps) / max(len(logps), 1),
"mean_entropy": sum(entropies) / max(len(entropies), 1),
}
# 代码来源:Future AGI 工程博客(2026-02-24 发布,2026-05-20 更新)
import math
def claim_token_uncertainty(tokens, claim_mask):
# tokens: [{token, top_logprob, top_k=[(tok, logp), ...]}, ...]
# claim_mask: [bool, ...] — True at claim-bearing positions
logps, entropies = [], []
for tok, is_claim in zip(tokens, claim_mask):
if not is_claim:
continue
logps.append(tok["top_logprob"])
probs = [math.exp(lp) for _, lp in tok["top_k"]]
z = sum(probs)
probs = [p / z for p in probs]
entropies.append(-sum(p * math.log(p + 1e-12) for p in probs))
return {
"mean_logprob": sum(logps) / max(len(logps), 1),
"mean_entropy": sum(entropies) / max(len(entropies), 1),
}
# Source: Future AGI engineering blog (published 2026-02-24, updated 2026-05-20)
OpenAI 的 o 系列隐藏了思维链 token。你看得到的 logprob 只覆盖最终答案表层——而那往往是一段「内部很不确定的推理轨迹」之上的一句自信总结。对任何带 reasoning / thinking 包装的模型,logprob 聚合只能当辅助信号,不能当主信号。
OpenAI's o-series hides chain-of-thought tokens. The logprobs you can see cover only the final-answer surface — which is often a confident summary sitting on top of an internally uncertain reasoning trace. For any model behind a reasoning or thinking wrapper, treat logprob aggregation as a supporting signal, not the primary one.
信号 B:语义熵(API 隐藏 logprob 时)
Signal B: semantic entropy (when logprobs are hidden)
2026 年多数商用托管端点不返回 logprob。这时的办法是从采样行为里反推不确定性。
Most hosted commercial endpoints in 2026 do not return logprobs. The workaround is to infer uncertainty from sampling behaviour.
朴素做法是词面熵:在 temperature 0.7 下采 N 条回答,看字符串重合度。问题在于同义改写会被算成分歧——「巴黎是首都」和「首都是巴黎」在字面上完全不同,意思却一样。
The naive version is lexical entropy: sample N completions at temperature 0.7 and measure surface-string agreement. The problem is that paraphrases register as disagreement — "Paris is the capital" and "The capital is Paris" look distinct while expressing the same answer.
语义熵(Farquhar 等,《Nature》2024)解决了这个问题:采 N 条,按意思聚类,然后对簇的占比而不是原始字符串算熵。两种聚类方式:
Semantic entropy (Farquhar et al., Nature 2024) fixes this: sample N completions, cluster them by meaning, and compute entropy over the cluster proportions rather than the raw strings. Two ways to cluster:
- 双向 NLI:两条回答互相蕴含,就归为一簇。算力更重,在改写密集的任务上更准。
- 先嵌入再聚类:用句向量模型编码,再用 HDBSCAN 或层次聚类在调好的阈值上分簇。更便宜,边界情况更松。
- Bidirectional NLI: two completions join the same cluster if a small NLI model says each entails the other. Heavier compute, more accurate on paraphrase-dense tasks.
- Embed then cluster: encode with a sentence encoder, then cluster with HDBSCAN or agglomerative clustering at a tuned threshold. Cheaper, looser at the edges.
import math
def semantic_entropy(samples, equivalent_fn):
# samples: 生成的字符串列表
# equivalent_fn(a, b) -> bool: 双向 NLI 或嵌入距离判等
clusters = []
for s in samples:
placed = False
for cluster in clusters:
if equivalent_fn(s, cluster[0]):
cluster.append(s); placed = True; break
if not placed:
clusters.append([s])
n = len(samples)
probs = [len(c) / n for c in clusters]
return -sum(p * math.log(p + 1e-12) for p in probs)
# 代码来源:Future AGI 工程博客
import math
def semantic_entropy(samples, equivalent_fn):
# samples: list of generated strings
# equivalent_fn(a, b) -> bool: bidirectional NLI or embedding-distance check
clusters = []
for s in samples:
placed = False
for cluster in clusters:
if equivalent_fn(s, cluster[0]):
cluster.append(s); placed = True; break
if not placed:
clusters.append([s])
n = len(samples)
probs = [len(c) / n for c in clusters]
return -sum(p * math.log(p + 1e-12) for p in probs)
# Source: Future AGI engineering blog
存在多个正确答案的任务(开放式生成、创作类)。熵高是因为答案空间大,不是因为模型不确定。这类指标必须锚定在有可辩护 ground truth 的任务上。
更进一步:2026 年 3 月的论文《Entropy Alone is Insufficient for Safe Selective Prediction in LLMs》(Phillips 等)指出,基于熵的不确定性方法存在一个依赖具体模型的失效模式,会导致弃答行为不可靠;作者的解法是把熵分数与一个正确性探针信号组合。在 TriviaQA、BioASQ、MedicalQA 三个问答基准与四个模型族上,组合分数在风险-覆盖率权衡和校准表现上普遍优于纯熵基线。
Tasks with several correct answers (open-ended generation, creative work). Entropy is high because the answer space is large, not because the model is uncertain. Anchor the metric on tasks with a defensible ground truth.
Further: "Entropy Alone is Insufficient for Safe Selective Prediction in LLMs" (Phillips et al., March 2026) identifies a model-dependent failure mode in entropy-based uncertainty methods that produces unreliable abstention. Their fix is to combine the entropy score with a correctness probe signal. Across three QA benchmarks (TriviaQA, BioASQ, MedicalQA) and four model families, the combined score generally improves both the risk–coverage trade-off and calibration relative to entropy-only baselines.
信号 C:训练一个分类头
Signal C: a trained classifier head
如果你有足够的数据,最准的做法是直接在 (输入, 是否正确) 配对上训一个小分类器。它是负载专属的——只在你自己的流量分布上有效,但正因为如此,在数据够的时候准确率最高。
With enough data, the most accurate route is to train a small classifier directly on (input, was_correct) pairs. It is workload-specific — valid only on your own traffic distribution — but for exactly that reason it gives the highest accuracy once you have the data.
04怎么衡量「偏了多少」:Brier、ECE、可靠性图
04Measuring how far off you are: Brier, ECE, reliability diagrams
有了原始信号只是第一步。一个信号只有在你知道它偏了多少的时候才有用。这一节讲三个工具,它们其实是同一件事的三种呈现。
Having a raw signal is only step one. A signal is useful only once you know how miscalibrated it is. This section covers three tools, which are three views of the same thing.
- Brier score(布里尔分数)
- 预测概率
p_i与「对/错」二值标签y_i之间的均方误差,在 N 个样本上取平均。越低越好。它能干净地分解成两项:校准项(分箱后的预测值与实际准确率有多接近)和锐度项(模型有多敢给出极端概率,而不是一直待在 0.5)。一个恒定输出 0.5 的模型在 50/50 任务上校准完美、锐度极差——两个你都要。 - ECE(Expected Calibration Error,期望校准误差)
- 把预测按置信度分进 B 个箱(标准做法是 10 个),算每个箱的实际准确率与平均预测概率之差的绝对值,再按样本量加权平均。留出集上 ECE 低于 0.05 是一个合理的生产目标。
- 可靠性图(reliability diagram)
- 把上面两个指标画出来:x 轴是预测置信度,y 轴是实际准确率,每个箱一个点。校准良好的信号落在对角线上。
- Brier score
- The mean squared error between predicted probability
p_iand the binary correctness labely_i, averaged over N samples. Lower is better. It decomposes cleanly into a calibration term (how close binned predictions sit to observed accuracy) and a sharpness term (how willing the model is to commit to extreme probabilities rather than parking at 0.5). A model that always outputs 0.5 has perfect calibration on a 50/50 task and terrible sharpness — you want both. - ECE (Expected Calibration Error)
- Split predictions into B confidence bins (10 is standard), take the absolute gap between each bin's observed accuracy and its mean predicted probability, and average across bins weighted by sample count. ECE below 0.05 on your labelled set is a reasonable production target.
- Reliability diagram
- The picture both metrics summarise: predicted confidence on the x-axis, observed accuracy on the y-axis, one point per bin. A well-calibrated signal sits on the diagonal.
金标集:整条流水线的地基
The gold set: the foundation of the whole pipeline
上面三个指标都要在同一样东西上算——一个留出标注集。建议做法:
All three metrics are computed on the same thing: a held-out labelled set. Recommended practice:
- 规模 500–2000 条,且必须是生产代表性的样本。
- 从生产 trace 里捞,不要自己编测试用例。编出来的用例分布和真实流量不是一回事。
- 向最难的 10% 倾斜——边界情况、罕见意图。门控恰恰是在这些地方失效的。
- 人工打标。这是金标集,下游一切都依赖它。
- 500 to 2000 examples, and they must be production-representative.
- Pull from production traces, don't invent test cases. Invented cases don't share the distribution of real traffic.
- Skew toward the hardest 10% — edge cases, rare intents. That's precisely where gates fail.
- Label by hand. This is the gold set; everything downstream depends on it.
05后处理校准:Platt 缩放与保序回归
05Post-hoc calibration: Platt scaling and isotonic regression
量出偏差之后,下一个自然的问题是:怎么修?好消息是不用重训模型——两个标准的后处理方法就能把一个歪掉的信号映射成可用的概率。
Once you've measured the bias, the next question is how to fix it. The good news: you don't retrain the model. Two standard post-hoc methods map a skewed signal onto a usable probability.
Platt 缩放
Platt scaling
在校准划分上,对 (原始信号, 是否正确) 配对拟合一个单参数逻辑回归。
Fit a one-parameter logistic regression on (raw_signal, was_correct) pairs from a calibration split.
import numpy as np
from sklearn.linear_model import LogisticRegression
def fit_platt(raw_signals, labels):
X = np.array(raw_signals).reshape(-1, 1)
y = np.array(labels)
return LogisticRegression().fit(X, y)
def apply_platt(model, raw_signal):
return model.predict_proba([[raw_signal]])[0, 1]
适用于偏差是单调的、在 logit 空间大致线性的情况。拟合便宜,200 条以上的小校准集就稳定,是默认起点。
Works when miscalibration is monotonic and roughly linear in logit space. Cheap to fit, stable on 200+ examples, and the default starting point.
保序回归(isotonic regression)
Isotonic regression
拟合一个非参数的单调映射,能处理更奇怪的、非线性的校准曲线。
Fits a non-parametric monotonic mapping, handling weirder, non-linear calibration curves.
from sklearn.isotonic import IsotonicRegression
def fit_isotonic(raw_signals, labels):
return IsotonicRegression(out_of_bounds="clip").fit(raw_signals, labels)
需要更多数据(稳定通常要 1000 条以上),但不做参数假设、直接从数据读出形状。当 Platt 在尾部修不够时,就换它。
Needs more data (1000+ examples for stability) but reads the shape off the data with no parametric assumptions. Switch to it when Platt under-corrects in the tails.
在校准划分上拟合,在留出测试划分上验证,并检查 Brier 与 ECE 是否真的改善了(通常会)。据 Future AGI 博客,在 200 条以上样本上做 Platt 缩放,通常能把自述置信度的 ECE 降低 30%–60%。
Fit on a calibration split, validate on a held-out test split, and check that Brier and ECE actually improve (they usually do). Per the Future AGI blog, Platt scaling on 200+ examples commonly cuts ECE on verbalized confidence by 30–60%.
模型版本变了、prompt 模板有实质改动、或输入分布漂移了。校准器是模型与生产流量之间的一纸合约;任何一方动了,合约就失效。
When the model version changes, when the prompt template changes substantively, or when the input distribution shifts. The calibrator is a contract between the model and production traffic; the contract breaks when either side moves.
06Agent 特有的难题:不确定性会沿轨迹累积
06The agent-specific problem: uncertainty compounds along a trajectory
到这里为止讲的都是单轮问答的校准。但 Agent 不是单轮的——它调工具、读结果、再决策,一步接一步。这带来一个全新的问题:第 5 步的不确定性,有多少是它自己的,有多少是从前 4 步继承来的?
Everything so far applies to single-turn question answering. But agents are not single-turn — they call a tool, read the result, decide again, step after step. That creates a new problem: how much of the uncertainty at step 5 is its own, and how much was inherited from steps 1 through 4?
综述《Uncertainty Quantification in LLM Agents》(arXiv 2602.05073)指出:现有 LLM 不确定性量化方法主要是为单轮问答设计的,多步 Agent 系统仍然研究不足。这是一个新兴领域,而不是一套成熟的最佳实践。
The survey "Uncertainty Quantification in LLM Agents" (arXiv 2602.05073) notes that existing LLM UQ methods are primarily designed for single-turn question answering, leaving multi-step agentic systems underexplored. This is an emerging field, not a settled set of best practices.
两个开创性框架
Two pioneering frameworks
UProp(arXiv 2506.17419)把序贯决策的不确定性拆成两部分:内在不确定性(当前这一步决策本身固有的)和外来不确定性——一个互信息量,描述应当从前面各步继承多少不确定性。它通过对轨迹相关采样的逐点互信息取期望,来近似决策分布之间的互信息。
UProp (arXiv 2506.17419) decomposes sequential decision uncertainty into two parts: internal uncertainty intrinsic to the current decision, and extrinsic uncertainty — a mutual-information quantity describing how much uncertainty should be inherited from preceding decisions. It approximates the mutual information between decision distributions by taking an expectation of pointwise mutual information over trajectory-dependent samplings.
SAUP(Situation Awareness Uncertainty Propagation,arXiv 2412.01033)则引入情境感知:用插件式估计器给每一步附上不确定性估计,再通过基于 HMM 的情境权重做传播——也就是说,不同处境下的同一步,权重不一样。
SAUP (Situation Awareness Uncertainty Propagation, arXiv 2412.01033) adds situational awareness: it attaches per-step uncertainty estimates using plug-in estimators and propagates them via HMM-based situational weights — meaning the same step carries different weight in different situations.
多 Agent:分歧不等于不确定
Multi-agent: disagreement is not the same as uncertainty
当你用一组 Agent 投票时,直觉是「大家意见不合 = 不确定」。但研究指出这个直觉会双向出错:
When you have a panel of agents vote, the intuition is "they disagree, so it's uncertain." Research points out this intuition fails in both directions:
- 良性多样性会造成信心不足——大家从不同角度给出等价的正确答案,却被算成分歧。
- 沟通诱发的一致会造成过度自信——Agent 之间互相看见对方的答案后趋同,这种一致不是独立证据。
- Benign diversity causes under-confidence — several equivalent correct answers from different angles get counted as disagreement.
- Communication-induced agreement causes over-confidence — agents converge after seeing each other's answers, and that agreement is not independent evidence.
目前有三类校准路线:后处理多数派校准器(用投票或熵信号)、LLM 自陈置信度估计器(训练模型报告校准过的置信度)、训练式校准器(从置信度与分歧特征估计正确性)。DiscoUQ-LLM 从分歧特征学习,MATU 用张量分解建模不确定性——都属于这一支。
Three calibration routes currently exist: post-hoc plurality calibrators (using voting or entropy signals), LLM-elicited confidence estimators (training the model to report calibrated confidence), and trained calibrators (estimating correctness from confidence and disagreement features). DiscoUQ-LLM learns from disagreement features and MATU models uncertainty via tensor decomposition — both belong to this last group.
共形预测:给弃答一个可证明的保证
Conformal prediction: a provable guarantee on abstention
共形预测(conformal prediction)是一套分布无关、模型无关的方法:在一个留出校准集上标定「不符合度分数」(nonconformity score),就能得到覆盖率保证——比如「预测集有 95% 的概率包含真实答案」。用大白话说:它不告诉你「这个答案对不对」,而是给你一个数学上站得住的承诺:「按这个规则弃答,长期错误率不会超过 5%」。
Conformal prediction is a distribution-free, model-agnostic family of methods: calibrate a "nonconformity score" on a held-out calibration set and you get a coverage guarantee — e.g. "the prediction set contains the true answer with 95% probability." In plain terms: it does not tell you whether this answer is right. It gives you a mathematically defensible promise that if you abstain by this rule, your long-run error rate will not exceed 5%.
2026 年的几项工作把它推向 Agent 场景:
Several 2026 works push it into agent settings:
- 角色分层的共形风险控制(arXiv 2607.24343):不用聚合风险,而是按工具调用的角色分层做风险控制——因为「查天气」和「发起转账」的可容忍错误率显然不一样。
- PASC(arXiv 2605.18812):面向多阶段流水线的联合覆盖保证,把多阶段问题归约成对「联合最大不符合度分数」的单标量共形问题。作者指出这个归约直接适用于复合 LLM 系统与 Agent 流水线。
- 可证明对齐保证的不确定性感知弃答(arXiv 2607.04430):分裂共形预测提供分布无关的覆盖保证;与其构造预测集,不如做弃答感知的点预测——系统要么返回一个回答,要么弃答。
- 另有工作把共形风险控制应用到移动端 GUI Agent(CORA)。
- Role-stratified conformal risk control (arXiv 2607.24343): rather than aggregate risk, stratify risk control by the role of the tool call — the tolerable error rate for "look up the weather" and "initiate a transfer" is obviously not the same.
- PASC (arXiv 2605.18812): joint coverage guarantees for multi-stage pipelines, reducing the multi-stage problem to a single scalar conformal problem on the joint maximum nonconformity score. The authors note this reduction applies directly to compound LLM systems and agent pipelines.
- Uncertainty-aware abstention with provable alignment guarantees (arXiv 2607.04430): split conformal prediction gives distribution-free coverage; instead of building a prediction set, do abstention-aware point prediction — the system either returns one answer or abstains.
- Related work applies conformal risk control to mobile GUI agents (CORA).
07落地:三件套与升级门控
07In production: the three pieces and the gate
把整套东西接进生产,只需要三块。这三块也正是最容易漏掉其中一块的地方——漏掉哪一块,整条链子都断。
Wiring all of this into production takes three pieces. It's also where teams most often ship two out of three — and any one missing breaks the chain.
① span 埋点:把信号记进 trace
1. Span instrumentation: put the signals on the trace
不确定性信号应该作为自定义 span 属性,和标准的 OpenTelemetry GenAI 字段并排记录。这样它们天然跟着 trace 树走,后面做分析、聚类、回归都有数据。典型的三个属性:llm.semantic_entropy、llm.mean_top_logprob、llm.mean_entropy。
Uncertainty signals belong on the trace as custom span attributes, alongside the standard OpenTelemetry GenAI fields. That way they ride the trace tree and you have data for later analysis, clustering and regression testing. Three typical attributes: llm.semantic_entropy, llm.mean_top_logprob, llm.mean_entropy.
with tracer.start_as_current_span("llm.answer_with_uncertainty") as span:
samples = [client.chat.completions.create(
model="...", messages=[...], temperature=0.7,
logprobs=True, top_logprobs=5,
) for _ in range(n_samples)]
sem_entropy = semantic_entropy(
[s.choices[0].message.content for s in samples],
equivalent_fn=nli_equivalent)
logp_signal = claim_token_uncertainty(
extract_tokens(samples[0]), claim_mask=mask_claims(samples[0]))
span.set_attribute("llm.semantic_entropy", sem_entropy)
span.set_attribute("llm.mean_top_logprob", logp_signal["mean_logprob"])
span.set_attribute("llm.mean_entropy", logp_signal["mean_entropy"])
span.set_attribute("llm.n_samples", n_samples)
return majority_answer(samples), sem_entropy, logp_signal
# 结构参考:Future AGI traceAI 示例(Apache 2.0,OpenTelemetry 原生)
with tracer.start_as_current_span("llm.answer_with_uncertainty") as span:
samples = [client.chat.completions.create(
model="...", messages=[...], temperature=0.7,
logprobs=True, top_logprobs=5,
) for _ in range(n_samples)]
sem_entropy = semantic_entropy(
[s.choices[0].message.content for s in samples],
equivalent_fn=nli_equivalent)
logp_signal = claim_token_uncertainty(
extract_tokens(samples[0]), claim_mask=mask_claims(samples[0]))
span.set_attribute("llm.semantic_entropy", sem_entropy)
span.set_attribute("llm.mean_top_logprob", logp_signal["mean_logprob"])
span.set_attribute("llm.mean_entropy", logp_signal["mean_entropy"])
span.set_attribute("llm.n_samples", n_samples)
return majority_answer(samples), sem_entropy, logp_signal
# Structure adapted from the Future AGI traceAI example (Apache 2.0, OpenTelemetry-native)
② 标注集:锚定校准
2. The labelled set: the calibration anchor
见上一节的金标集做法。这里补一条评测视角:除了「答案对不对」,你还要评「该升级的时候有没有升级」。可以用现成的评测模板(如 AnswerRefusal、TaskCompletion、Groundedness)组合,再加一条校准专用的评分标准,例如:
See the gold-set practice in the previous section. One addition from the evaluation side: besides "was the answer correct," you also need to score "did it escalate when it should have." Combine off-the-shelf templates (AnswerRefusal, TaskCompletion, Groundedness) with a calibration-specific rubric, for example:
给定输入、Agent 的回答和它自称的置信度(0–1):若置信度 > 0.7 且答案正确,或置信度 < 0.3 且答案错误,返回 1.0;若置信度 > 0.7 但答案错误(过度自信的错误),返回 0.0。
Given the input, the agent's answer, and the stated confidence (0–1): return 1.0 if confidence above 0.7 and answer correct, or confidence below 0.3 and answer wrong. Return 0.0 if confidence above 0.7 and answer wrong (over-confident wrong).
③ 门控:把校准后的概率变成阈值
3. The gate: turn the calibrated probability into a threshold
阈值是业务决策,校准是工程。医疗分诊和内部聊天机器人显然应该落在曲线上不同的操作点。工程侧的责任只是保证:那个 0.65 确实意味着「65% 会对」。
The threshold is a business decision; the calibration is engineering. Medical triage and an internal chatbot obviously operate at different points on the curve. Engineering's job is only to guarantee that 0.65 really does mean "correct 65% of the time."
def route(prompt):
answer, sem_ent, logp = answer_with_uncertainty(prompt)
raw = combine(sem_ent, logp["mean_logprob"], verbalized_confidence(answer))
p_correct = platt.predict(raw) # 校准后的概率
if p_correct < 0.65: # 阈值 = 业务决策
return escalate_to_human(prompt, reason=f"p_correct={p_correct:.2f}")
return answer
# 结构参考:Future AGI 工程博客
def route(prompt):
answer, sem_ent, logp = answer_with_uncertainty(prompt)
raw = combine(sem_ent, logp["mean_logprob"], verbalized_confidence(answer))
p_correct = platt.predict(raw) # calibrated probability
if p_correct < 0.65: # threshold = business decision
return escalate_to_human(prompt, reason=f"p_correct={p_correct:.2f}")
return answer
# Structure adapted from the Future AGI engineering blog
p_correct = platt.predict(raw) 是整篇文档的落点。开头那个失败案例里,代码写的是 if stated_confidence < 0.5——少了中间这一步,阈值就只是一个数字,而不是一个承诺。
p_correct = platt.predict(raw) is where this whole document lands. In the failure case at the top, the code read if stated_confidence < 0.5 — without that middle step, a threshold is just a number, not a promise.
08对比与选型:什么情况用哪个
08Choosing an approach: what to use when
| 信号 / 方法 | 它测的是什么 | 什么时候用 | 代价 |
|---|---|---|---|
| 自述置信度 | 模型自己报告的概率 | 集成里的一个信号,绝不单用 | 几乎为零 |
| 平均 top-1 logprob | 论断 token 上被选中 token 的平均概率 | API 暴露 logprob;结构化或分类输出 | 零额外推理 |
| top-k token 熵 | 下一 token 分布的香农熵 | 同上;熵高标记犹豫 | 零额外推理 |
| 语义熵 | 按意思聚类后各簇占比的熵 | API 隐藏 logprob;开放式生成 | N 倍推理 |
| Brier / ECE | 留出标注集上的校准缺口 | 告诉你原始信号偏了多少的那把尺 | 需要标注集 |
| Platt / 保序回归 | 后处理校准器 | 把原始信号映射成可用概率 | 200 / 1000 条以上样本 |
| 训练分类头 | 在 (输入, 是否正确) 上训练 | 负载专属;数据够时最准 | 需要大量标注 |
| 共形预测 | 分布无关的覆盖率保证 | 需要可证明的错误率上界时 | 需校准集 + 接受覆盖率-效用权衡 |
| UProp / SAUP | 不确定性沿轨迹的传播 | 多步 Agent;需区分「自己的」与「继承的」 | 研究阶段,工程成熟度低 |
| Signal / method | What it measures | When to use | Cost |
|---|---|---|---|
| Verbalized confidence | The model's self-reported probability | One signal in an ensemble; never alone | Near zero |
| Mean top-1 logprob | Average chosen-token probability over claim-bearing tokens | API exposes logprobs; structured or classification output | No extra inference |
| Top-k token entropy | Shannon entropy of the next-token distribution | Same as above; high entropy flags hesitation | No extra inference |
| Semantic entropy | Entropy over meaning-clustered completions | API hides logprobs; open-ended generation | N× inference |
| Brier / ECE | The calibration gap on held-out labels | The ruler that tells you how far off the raw signal is | Requires a labelled set |
| Platt / isotonic | Post-hoc calibrator | Mapping a raw signal to a usable probability | 200 / 1000+ examples |
| Trained classifier head | Trained on (input, was_correct) pairs | Workload-specific; highest accuracy with enough data | Substantial labelling |
| Conformal prediction | Distribution-free coverage guarantee | When you need a provable error-rate bound | Calibration set + coverage/utility trade-off |
| UProp / SAUP | Propagation of uncertainty along a trajectory | Multi-step agents; separating "own" from "inherited" | Research-stage, low engineering maturity |
如果你今天什么都还没做:先攒 500 条生产 trace 打标 → 拿现有的自述置信度算一遍 ECE(你大概率会看到 0.15 以上)→ 拟合一个 Platt 缩放 → 把门控改成读校准后的概率。这四步不需要改模型、不需要 N 倍推理,是投入产出比最高的一段。语义熵、共形预测、轨迹传播都是之后的事。
If you've done none of this yet: collect and label 500 production traces → compute ECE on the verbalized confidence you already have (you will most likely see 0.15 or worse) → fit a Platt scaler → change the gate to read the calibrated probability. Those four steps need no model changes and no N× inference, and they are the highest-return stretch of the whole path. Semantic entropy, conformal prediction and trajectory propagation come later.
09常见坑与限制
09Pitfalls and limits
「confidence < 0.5 就升级」在实践中常常等于永不升级——因为模型几乎不报低于 0.7 的数。这是开篇失败案例的直接死因。先看你的信号的实际分布,再定阈值。
"escalate if confidence < 0.5" often means never escalate in practice, because the model almost never reports below 0.7. That is the direct cause of death in the opening case. Look at your signal's actual distribution before setting a threshold.
已有论文指出基于熵的方法存在依赖具体模型的失效模式,会导致弃答不可靠;把熵与正确性探针组合,在三个问答基准与四个模型族上普遍更好。不要只靠一个信号。
Published work identifies a model-dependent failure mode in entropy-based methods that makes abstention unreliable; combining entropy with a correctness probe was generally better across three QA benchmarks and four model families. Don't lean on a single signal.
存在多个正确答案时,熵高是因为答案空间大,不是因为模型不确定。这类任务上语义熵会系统性地高估不确定性,导致过度升级、把人工淹没。
When several answers are correct, entropy is high because the answer space is large, not because the model is uncertain. On such tasks semantic entropy systematically overestimates uncertainty, causing over-escalation that drowns your human queue.
校准器绑定的是「这个模型版本 + 这个 prompt + 这段流量分布」。三者任一变化,ECE 就会悄悄回升,而且不会报警——除非你把 ECE 本身做成一个受监控的指标。
A calibrator is bound to "this model version + this prompt + this traffic distribution." Change any of the three and ECE quietly drifts back up — with no alarm, unless you make ECE itself a monitored metric.
Agent 之间看得见彼此答案时,趋同不是独立证据。这种「沟通诱发的一致」会让你的集成信号系统性过度自信。
When agents can see each other's answers, convergence is not independent evidence. This communication-induced agreement makes your ensemble signal systematically over-confident.
诚实的边界
Honest limits
- 多步 Agent 的 UQ 仍然研究不足。综述明确这么说。UProp / SAUP 是开创性工作,不是成熟工具链——不要指望装个库就解决。
- 本文的生产实践部分,主要来源是一篇厂商工程博客(Future AGI,2026-02-24 发布 / 2026-05-20 更新)。其中的方法论(logprob 聚合、语义熵、Brier/ECE、Platt)有独立学术来源支撑,但「ECE 降低 30%–60%」「ECE < 0.05 是合理目标」这类具体数字,截至调研时仅见于该单一来源,未能交叉验证,请当作经验参考而非基准。
- Farquhar 等的语义熵结论是在问答基准上得出的,迁移到工具调用 Agent 的效果未见系统性公开评测。
- 共形方法给的是长期覆盖率保证,不是对单条回答的保证——单次它仍然可能错。
- UQ for multi-step agents remains underexplored. The survey says so explicitly. UProp and SAUP are pioneering work, not a mature toolchain — don't expect to install a library and be done.
- The production-practice sections here rest largely on one vendor engineering blog (Future AGI, published 2026-02-24, updated 2026-05-20). Its methodology (logprob aggregation, semantic entropy, Brier/ECE, Platt) has independent academic backing, but specific figures like "cuts ECE by 30–60%" and "ECE below 0.05 is a reasonable target" appear, as of this research date, only in that single source and could not be cross-verified. Treat them as experience-based guidance, not benchmarks.
- Farquhar et al.'s semantic-entropy result was established on QA benchmarks; no systematic public evaluation of its transfer to tool-calling agents was found.
- Conformal methods give long-run coverage guarantees, not guarantees on any single answer — an individual response can still be wrong.
10术语表
10Glossary
- Calibration(校准)
- 「说的把握」与「实际正确率」之间的一致程度。说 0.8 的那批答案,真有 80% 是对的,就叫校准良好。
- Verbalized confidence(自述置信度)
- 模型在答案旁边生成的那个数字。是 token,不是概率。
- Logprob(对数概率)
- 模型给某个 token 的概率取对数。越接近 0(即概率越接近 1)表示模型越笃定。
- Semantic entropy(语义熵)
- 把多次采样的回答按意思聚类后,对簇占比算的熵。高 = 模型在「说什么意思」这件事上摇摆,而不只是措辞不同。
- ECE / Brier score
- 两把量校准偏差的尺。ECE 是分箱后的平均缺口,Brier 是概率与 0/1 标签的均方误差。
- Platt scaling / Isotonic regression
- 两种后处理校准器,把歪掉的原始分数映射回真概率。前者单参数、数据要求低;后者非参数、更灵活但要更多数据。
- Selective prediction / Abstention(选择性预测 / 弃答)
- 允许系统在没把握时拒绝回答,而不是硬答。升级到人工是弃答的一种实现。
- Conformal prediction(共形预测)
- 一套分布无关的方法,通过在校准集上标定不符合度分数,给出可证明的覆盖率保证。
- Risk–coverage trade-off(风险-覆盖率权衡)
- 你答得越多(覆盖率高),错得越多(风险高)。弃答策略的好坏,看的就是这条曲线的形状。
- Span / Trace
- 可观测性术语。一次操作 = 一个 span,一串因果相关的 span 组成一个 trace。把不确定性信号写成 span 属性,就能跟着调用链一起被查询。
- Calibration
- How well stated confidence matches observed correctness. If answers labelled 0.8 really are right 80% of the time, the signal is well calibrated.
- Verbalized confidence
- The number the model prints next to its answer. Tokens, not a probability.
- Logprob
- The log of the probability the model assigned to a token. Closer to 0 (probability closer to 1) means the model was more committed.
- Semantic entropy
- Entropy over cluster proportions after grouping repeated samples by meaning. High means the model wavers about what it is saying, not merely how it phrases it.
- ECE / Brier score
- Two rulers for calibration error. ECE is the average binned gap; Brier is the mean squared error between probability and the 0/1 label.
- Platt scaling / Isotonic regression
- Two post-hoc calibrators that map a skewed raw score back onto a real probability. The first is one-parameter and data-light; the second is non-parametric, more flexible, and hungrier for data.
- Selective prediction / Abstention
- Letting the system decline to answer when it isn't sure, rather than forcing an answer. Escalating to a human is one implementation of abstention.
- Conformal prediction
- A distribution-free family of methods that calibrates a nonconformity score on a held-out set to deliver provable coverage guarantees.
- Risk–coverage trade-off
- The more you answer (higher coverage), the more you get wrong (higher risk). The quality of an abstention policy is the shape of that curve.
- Span / Trace
- Observability terms. One operation is a span; a causally linked chain of spans is a trace. Writing uncertainty signals as span attributes makes them queryable alongside the call chain.
11来源清单与延伸阅读
11Sources and further reading
下列来源为 2026-08-27 调研时实际检索/阅读到的材料。标签含义:论文同行评审或预印本研究;文档官方文档或规范;厂商/社区厂商工程博客或社区观点,属经验之谈而非权威事实。
The sources below were retrieved and read during research on 2026-08-27. Tags: paper peer-reviewed or preprint research; docs official documentation or specification; vendor vendor engineering blog or community opinion — experience, not authoritative fact.
- 厂商Nikhil Pareek,《Evaluating LLM Confidence and Uncertainty (2026): The Calibration Methodology》,Future AGI 博客,2026-02-24 发布 / 2026-05-20 更新 —— 链接(本文生产实践、代码示例与 ECE 数字的主要来源)
- 论文《Uncertainty Quantification in LLM Agents: Foundations, Emerging Challenges, and Opportunities》,arXiv 2602.05073 —— 链接
- 论文Farquhar, S. 等,《Detecting hallucinations in large language models using semantic entropy》,Nature(2024)
- 论文Tian, K. 等,《Just Ask for Calibration: Strategies for Eliciting Calibrated Confidence Scores from Language Models Fine-Tuned with Human Feedback》,EMNLP(2023)
- 论文Phillips, E.、Gustafsson, F. K.、Wu, S.、Thakur, A.、Clifton, D. A.,《Entropy Alone is Insufficient for Safe Selective Prediction in LLMs》,arXiv 2603.21172,2026-03-22 —— 链接
- 论文《UProp: Investigating the Uncertainty Propagation of LLMs in Multi-Step Agentic Decision-Making》,arXiv 2506.17419 —— 链接
- 论文《SAUP: Situation Awareness Uncertainty Propagation on LLM Agent》,arXiv 2412.01033 —— 链接
- 论文《Beyond Aggregate Risk: Role-Stratified Conformal Risk Control for LLM Tool Calls》,arXiv 2607.24343 —— 链接(调研时 fetch 遇到限流,内容依据搜索摘要,标注为未完整核实)
- 论文《PASC: Pipeline-Aware Conformal Prediction with Joint Coverage Guarantees for Multi-Stage NLP and LLM Pipelines》,arXiv 2605.18812 —— 链接
- 论文《Uncertainty-Aware Abstention in Large Language Models with Provable Alignment Guarantees》,arXiv 2607.04430 —— 链接
- 论文《DiscoUQ: Structured Disagreement Analysis for Uncertainty Quantification in LLM Agent Ensembles》,arXiv 2603.20975 —— 链接
- 论文《Quantifying Uncertainty of LLM-based Multi-Agent Systems》,ACL 2026 —— 链接
- 文档Future AGI traceAI(Apache 2.0,OpenTelemetry 原生)—— GitHub
- vendorNikhil Pareek, "Evaluating LLM Confidence and Uncertainty (2026): The Calibration Methodology," Future AGI blog, published 2026-02-24 / updated 2026-05-20 — link (primary source for this document's production practices, code examples and ECE figures)
- paper"Uncertainty Quantification in LLM Agents: Foundations, Emerging Challenges, and Opportunities," arXiv 2602.05073 — link
- paperFarquhar, S. et al., "Detecting hallucinations in large language models using semantic entropy," Nature (2024)
- paperTian, K. et al., "Just Ask for Calibration: Strategies for Eliciting Calibrated Confidence Scores from Language Models Fine-Tuned with Human Feedback," EMNLP (2023)
- paperPhillips, E., Gustafsson, F. K., Wu, S., Thakur, A., Clifton, D. A., "Entropy Alone is Insufficient for Safe Selective Prediction in LLMs," arXiv 2603.21172, 2026-03-22 — link
- paper"UProp: Investigating the Uncertainty Propagation of LLMs in Multi-Step Agentic Decision-Making," arXiv 2506.17419 — link
- paper"SAUP: Situation Awareness Uncertainty Propagation on LLM Agent," arXiv 2412.01033 — link
- paper"Beyond Aggregate Risk: Role-Stratified Conformal Risk Control for LLM Tool Calls," arXiv 2607.24343 — link (full-text fetch was rate-limited during research; summarised from search results and flagged as not fully verified)
- paper"PASC: Pipeline-Aware Conformal Prediction with Joint Coverage Guarantees for Multi-Stage NLP and LLM Pipelines," arXiv 2605.18812 — link
- paper"Uncertainty-Aware Abstention in Large Language Models with Provable Alignment Guarantees," arXiv 2607.04430 — link
- paper"DiscoUQ: Structured Disagreement Analysis for Uncertainty Quantification in LLM Agent Ensembles," arXiv 2603.20975 — link
- paper"Quantifying Uncertainty of LLM-based Multi-Agent Systems," ACL 2026 — link
- docsFuture AGI traceAI (Apache 2.0, OpenTelemetry-native) — GitHub
主页