对照人工评分度量评判器的错误,再校正通过率

阅读约需 36分钟 分钟,7节中含6个示例。

版次 2026.11.3 示例于 2026年11月21日 通过 54个示例中有54个通过 变化内容

AI 翻译。由人工以英文核验。 我们如何制作图书

译自英文版图书,版次 2026.11.3。 阅读原文

学完本章,你将能够度量评判器的判定与人工评分之间的差异,把这些差异拆分为漏判(该通过却判为不通过)与误通过(不该通过却判为通过),并据此校正观测到的通过率,同时在旁写明校正所依据的假设。

第 5 章结尾给出了校准任务的第二种表述,并提出了一条规则:评判器的措辞要经过度量,而不是想当然。答案评判器对照书面参考答案阅读每条回复,并标记为 PASS 或 FAIL,助手基线运行的通过率就来自这个评判器。这个数字既反映助手的表现,也反映评判器的表现,因为评判器可能放过错误的回复,也可能否决正确的回复。第 5 章编写了评分细则并阅读了判定结果。本章要问的是:这些判定出错的频率有多高,错在哪个方向,以及团队在了解这些之后应当如何处理通过率。

人工评分及其性质

评判器只能与以其他方式产生的标签相比对,才能得到检验。本书使用 HelpSteer2 中的人工评分,这是 NVIDIA 发布的一个公开数据集。每一行包含一条提示、对它的一条回复,以及由人给出的五项属性分数,分数范围为 0 到 4。这些回复来自其他模型。本章只使用其中一项属性,即正确性。采样代码把分数转换为通过或不通过:3 分或 4 分记为 PASS,0 到 2 分记为 FAIL。这一划分是本书的选择,在运行任何评判器之前就已确定。

HelpSteer2 并不是本书自己的数据。它的回复来自其他模型,提示内容是通用的,也没有人为 sablefile 而编写。因此,这些标签衡量的是评判器在另一类问题上的表现,而不是答案评判器所回答的那类问题。这一差距正是迁移假设的主题,本章后面的内容会一再回到它。

校准评判器依据一份只针对这一项属性编写的评分细则进行阅读。细则要求判断回复中的每一个事实和结果是否正确,并要求评判器不考虑长度、语气、风格和格式,详见第 5 章。本书自己的测试集本可以用作校准,但本书没有针对 sablefile 回复的人工评分。因此校准改用公开数据行,代价是需要引入迁移假设。数据集并没有为本书提供正确性的通过线。这条线由本书自行设定,本章中的每一个比率都要对照它来解读。换一条线,所有比率都会随之变化,所以读者在将本章与其他研究比较时,应先确认那项研究把线划在了哪里。

校准数据行是从数据集的验证划分中以固定随机种子抽取的样本。在抽样之前,文本中含有可打印 ASCII 之外字符的行已被剔除。抽样从每个划分中取约 45 条 FAIL 行和 45 条 PASS 行,并且每条提示只保留一行。因此,基准比率是由抽样决定的,而不是在数据集中发现的。样本被分为开发集和留出集。同一数据集中还包含针对同一条提示的成对回复,以及人对二者的偏好。偏好强度为零的成对数据被排除在外。

划分方式决定了这些数字可以如何使用。开发集是本书设定一切内容的地方,包括校正所用的比率。留出集只在本章中读取一次,且在其他一切都已固定之后,本章中没有任何内容是用它来选择的。留出集的数字最初是在记录检查时计算的,早于本章的撰写。这里按当时的原样报告,没有为了做任何选择而重新计算。

**工作准则:**校准时,应使用针对评判器所回答问题而制作的标签,否则要在正文中说明这些标签与该问题相距多远。在查看任何结果之前,先写下把分数转换为评判器通过或不通过的规则。用于调整的划分与只报告一次的划分要分开保存。

一致率与 kappa

一致率是评判器与人工给出相同判定的行所占的比例。当某一种判定占绝大多数时,它可能产生误导。一个对所有样本都判通过的评判器,与大多数为 PASS 的样本一致率很高,而仅凭一致率,无法把它与一个审慎的评判器区分开来。解决办法是:仅从两方判定的 PASS 率出发,计算两者偶然能达到的一致率,再把这部分偶然因素扣除。kappa 就是这样做的。对于两名评判者的通过或不通过判定,kappa 等于观测一致率减去偶然一致率,再除以 1 减偶然一致率。McHugh 的综述《kappa 统计量》给出了这个公式。当两名评判者在每一行上都一致时,kappa 为 1。

calibration-agreement.py Python 3.12.15 · numpy 2.5.5 通过
"""How often the reference-free correctness judge agrees with the human ratings on the HelpSteer2 sample, and Cohen's kappafor the same counts, on dev, on held-out and on both together.Agreement alone reads higher than the judge's skill when most rows are one verdict, so the kappa line is the one to readagainst chance: the chance agreement printed beside it is what the judge would reach by guessing at its own PASS rate."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom lib.calibration import agreement, chance_agreement, cohens_kappa, confusion, helpsteer2_judgmentsfrom lib.stats import pctfor label, split in (("all", None), ("dev", "dev"), ("held-out", "held-out")):    counts = confusion(helpsteer2_judgments(split))    print(f"agreement, {label}: {pct(counts.tp + counts.tn, counts.n)}")    # the chance figure is an expected rate, not a count, so it has no denominator beside it    print(f"chance agreement, {label}: {100 * chance_agreement(counts):.1f}%")    # kappa is printed with two decimals (plan section 6.5), not as a percentage    print(f"kappa, {label}: {cohens_kappa(counts):.2f}")
输出python calibration-agreement.py
agreement, all: 70.6% (127 of 180)
chance agreement, all: 50.3%
kappa, all: 0.41
agreement, dev: 71.1% (64 of 90)
chance agreement, dev: 50.2%
kappa, dev: 0.42
agreement, held-out: 70.0% (63 of 90)
chance agreement, held-out: 50.3%
kappa, held-out: 0.40

全部行上的一致率为 70.6% (127 of 180)。仅由两方 PASS 率算出的偶然一致率为 50.3%。kappa 为 0.41,保留两位小数且不带百分号,因为它是自成一套刻度的统计量,而不是一个比率。一致率与偶然一致率都是百分数,因此可以直接比较。kappa 是已经扣除偶然因素的数字,所以应把它读作评判器超出偶然水平的一致程度。

kappa 的取值范围是 −1 到 1。在偶然一致水平上它为 0;当两名评判者一致的频率低于偶然所预期的水平时,它为负,McHugh 的综述对此有说明。

请按顺序阅读这三个数字:先是一致率,再是它旁边的偶然一致率,最后是 kappa。如果一致率上升,而偶然一致率随之上升,那么这一增益可能来自基准率,而不是来自评判器。

两个数据划分的读法相同。在 dev 上,一致率为 71.1% (64 of 90),kappa 为 0.42。在 held-out 上,一致率为 70.0% (63 of 90),kappa 为 0.40。

基准率正是 kappa 重要的原因。当某一种判定占据绝大多数行时,偶然一致率很高,评判器可以取得很高的一致率,却难以区分两种判定。这里抽取的样本中 PASS 行与 FAIL 行的数量大致相当,因此偶然一致率接近一半。dev 上人工的 PASS 率为 51.1% (46 of 90)。样本严重偏斜的团队应当预期偶然一致率接近其一致率,于是即使一致率看上去很高,kappa 也接近于零。这样的团队应当先读 kappa。

一致率衡量的是与人工标注的接近程度,而不是回复是否正确。一致率高,说明评判器的判定与人工的判定相符,并不说明助手的回复是正确的。kappa 告诉你一致率距离偶然水平有多远,却不能告诉你评判器偏向哪一方向出错。这需要接下来的两个比率。

第 5 章介绍了第二种校准措辞,即 rubric B。校准用的评分细则,此后称为 rubric A,规定不含任何虚假陈述的回复属于“不算错误”。rubric B 对此作了改写:A 中的“不算错误”在 B 中写作“正确”,并且删去了关于误导与置信度的要点。rubric B 只在 dev 上记录过。下一个示例把两种措辞在同样的 dev 行上并排对照。

rubric-b-agreement.py Python 3.12.15 · numpy 2.5.5 通过
"""How often the second rubric's verdicts agree with the human ratings on the HelpSteer2 sample, beside the first rubric's,on dev and on held-out, with kappa, TPR and TNR and the PASS rates of judge and humans.The second rubric was recorded on dev only, so its held-out line says so instead of printing a rate. The paired differenceis on dev alone: each dev row's agreement under rubric B minus its agreement under rubric A, bootstrapped over rows. Areply with no readable verdict is printed by row ID and left out; it is never counted as FAIL."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom dataclasses import replacefrom lib.calibration import cohens_kappa, confusion, helpsteer2_judgments, readable_verdictsfrom lib.prompts import HS2B_SHA256from lib.replay import ReplayModelfrom lib.stats import bootstrap_mean, interval_points, pctRUBRIC_B = "judge-helpsteer2-rubric-b"def report(name, split, judgments):    c = confusion(judgments)    print(f"agreement, {name}, {split}: {pct(c.tp + c.tn, c.n)}")    print(f"kappa, {name}, {split}: {cohens_kappa(c):.2f}")    print(f"TPR, {name}, {split}: {pct(c.tp, c.tp + c.fn)}")    print(f"TNR, {name}, {split}: {pct(c.tn, c.tn + c.fp)}")    print(f"judge PASS rate, {name}, {split}: {pct(c.tp + c.fp, c.n)}")    print(f"human PASS rate, {name}, {split}: {pct(c.tp + c.fn, c.n)}")def same(j):    return int(j.judge_pass == j.human_pass)base = {j.id: j for j in helpsteer2_judgments()}  # rubric A's verdicts and the human PASS for every row, by idrecorded = {item for item, _ in ReplayModel(RUBRIC_B, HS2B_SHA256).keys()}verdicts_b, unreadable = readable_verdicts(RUBRIC_B, sorted(recorded & base.keys()), HS2B_SHA256)rows_b = {i: replace(base[i], judge_pass=v == "PASS") for i, v in verdicts_b.items()}print(f"unreadable, rubric B: {len(unreadable)} of {len(recorded)} replies")for item_id, _ in unreadable:    print(f"unreadable, rubric B, row {item_id}: excluded, not counted as FAIL")for split in ("dev", "held-out"):    report("rubric A", split, [j for j in base.values() if j.split == split])    b = [j for j in rows_b.values() if j.split == split]    if b:        report("rubric B", split, b)    else:        print(f"rubric B, {split}: no readable replies recorded")dev_ids = [i for i in verdicts_b if base[i].split == "dev"]diffs = [same(rows_b[i]) - same(base[i]) for i in dev_ids]  # the same row under both rubricslo, hi = bootstrap_mean(diffs)  # level 0.95 for one comparison; seed SEED, 2,000 resamplesn = len(dev_ids)print(f"paired difference, dev: {100 * sum(diffs) / n:+.1f} points, 95% interval {interval_points(lo, hi)}, n = {n}")reading = "rubric B better" if lo > 0 else "rubric B worse" if hi < 0 else f"no difference detected at n = {n}"caveat = ", on dev only with no held-out run" if lo > 0 or hi < 0 else ""  # a dev-only difference carries its caveatprint(f"paired difference, dev, reading: {reading}{caveat}")
输出python rubric-b-agreement.py
unreadable, rubric B: 0 of 90 replies
agreement, rubric A, dev: 71.1% (64 of 90)
kappa, rubric A, dev: 0.42
TPR, rubric A, dev: 80.4% (37 of 46)
TNR, rubric A, dev: 61.4% (27 of 44)
judge PASS rate, rubric A, dev: 60.0% (54 of 90)
human PASS rate, rubric A, dev: 51.1% (46 of 90)
agreement, rubric B, dev: 74.4% (67 of 90)
kappa, rubric B, dev: 0.49
TPR, rubric B, dev: 84.8% (39 of 46)
TNR, rubric B, dev: 63.6% (28 of 44)
judge PASS rate, rubric B, dev: 61.1% (55 of 90)
human PASS rate, rubric B, dev: 51.1% (46 of 90)
agreement, rubric A, held-out: 70.0% (63 of 90)
kappa, rubric A, held-out: 0.40
TPR, rubric A, held-out: 82.6% (38 of 46)
TNR, rubric A, held-out: 56.8% (25 of 44)
judge PASS rate, rubric A, held-out: 63.3% (57 of 90)
human PASS rate, rubric A, held-out: 51.1% (46 of 90)
rubric B, held-out: no readable replies recorded
paired difference, dev: +3.3 points, 95% interval [-1.1, +7.8] points, n = 90
paired difference, dev, reading: no difference detected at n = 90

在 dev 上没有显示出差异。rubric B 下的一致率为 74.4% (67 of 90)。在同样的行上,rubric A 下为 71.1% (64 of 90)。配对差值为 +3.3 points, 95% interval [-1.1, +7.8] points, n = 90。对每一条 dev 行,当某种措辞与人工一致时,代码记为 1,不一致时记为 0。配对差值是 rubric B 的得分减去 rubric A 的得分,在 dev 各行上取平均,其区间通过对这些行做自助重采样(bootstrap)得到。该示例对这一区间的解读为 no difference detected at n = 90。

该区间包含零,所以 dev 上的估计并没有显示 rubric B 更好。rubric B 没有 held-out 上的运行,因此它的 dev 估计没有第二次检验。它无法读取的回复数为 0 of 90 replies,所以没有任何回复被排除在外。

工作准则: 报告一致率时要同时报告 kappa,并对照其旁边印出的偶然一致率来解读 kappa。每个数字都要注明所用的评分细则和数据划分,以免把两种措辞当作同一种来读。只有当某种措辞的配对区间下界高于零时,才可称它更好,并且只能在 held-out 上这样说;若在 dev 上,则须在结论旁注明这一限定。当区间跨越零时,应说明在现有的 n 下没有检测到差异,不要把较高的点估计当成结论。

真阳性率与真阴性率

最近一次修改见于版次 2026.11.3

一致率与 kappa 说明评判器与人工标注者有多大程度上取得一致,却没有说明它朝哪个方向出错。能说明这一点的是两个比率:真阳性率与真阴性率。真阳性率(TPR)是人工标注为 PASS 的行中被评判器判为 PASS 的比例。真阴性率(TNR)是人工标注为 FAIL 的行中被评判器判为 FAIL 的比例。放行过多的评判器 TPR 高而 TNR 低,因为它的错误是误放行。判负过多的评判器则正好相反。下一节中的校正需要用到这两个比率,因为每一个比率纠正的是不同的错误。

tpr-tnr.py Python 3.12.15 · numpy 2.5.5 通过
"""The judge's true positive rate and true negative rate on the HelpSteer2 sample, with the counts beside each, on dev, onheld-out and on both together.PASS is the positive class: TPR is the share of human PASS rows the judge passes, and TNR the share of human FAIL rows itfails. The two rates are the judge's error profile; a lenient judge has a high TPR and a low TNR."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom lib.calibration import confusion, helpsteer2_judgmentsfrom lib.stats import pct# PASS is the positive class: the rows a human rated PASS are the positives, and TPR is taken over them.print("positive class: PASS")for label, split in (("all", None), ("dev", "dev"), ("held-out", "held-out")):    counts = confusion(helpsteer2_judgments(split))    print(f"TPR, {label}: {pct(counts.tp, counts.tp + counts.fn)}")    print(f"TNR, {label}: {pct(counts.tn, counts.tn + counts.fp)}")
输出python tpr-tnr.py
positive class: PASS
TPR, all: 81.5% (75 of 92)
TNR, all: 59.1% (52 of 88)
TPR, dev: 80.4% (37 of 46)
TNR, dev: 61.4% (27 of 44)
TPR, held-out: 82.6% (38 of 46)
TNR, held-out: 56.8% (25 of 44)

这里以 PASS 为阳性类,因此 TPR 取自人工标注为 PASS 的行,TNR 取自人工标注为 FAIL 的行。每个比率旁边都打印了对应的计数,读者由此可以看出它建立在多少行之上。

在全部行上,TPR 为 81.5% (75 of 92),TNR 为 59.1% (52 of 88)。评判器放行了人工放行的大部分回复,同时也放行了相当一部分人工判为不通过的回复。两个比率中较弱的是 TNR,这说明该评判器偏宽松。

方向对于任何读取通过率的人都很重要,而且取决于该通过率所处的位置。下一节的通过率校正在交叉点 p* = (1 − TNR) / (2 − TPR − TNR) 处不改变通过率。低于 p* 时,校正会降低该通过率;高于 p* 时,校正会抬高该通过率。对于宽松的评判器,p* 的位置偏高,因此低于它的报告通过率读起来偏高,高于它的通过率读起来偏低。在 dev 上,交叉点为 66.4% (TPR 80.4%, TNR 61.4%)。知道某个通过率相对于该点的位置,团队就能在做任何校正之前判断所报告的数字偏向哪一边。仅凭一致率会掩盖这一点。两个评判器与人工标注者的一致程度可以相同,但它们更常犯的错误可能不同,所报告的通过率也会随之不同。

在 dev 上,TPR 为 80.4% (37 of 46),TNR 为 61.4% (27 of 44)。在 held-out 上,TPR 为 82.6% (38 of 46),TNR 为 56.8% (25 of 44)。held-out 划分在两个比率上都与 dev 接近,TNR 低几个百分点。

每个比率都取自一组人工标签,而每个划分的行数都少到足以让另一个样本改变这些比率。本章没有为 TPR 或 TNR 打印区间。应把这些比率读作评判器在这份样本上的误差,而不是它在一般情形下的误差。

工作准则: 同时报告 TPR 与 TNR 及其计数,并说明评判器朝哪个方向出错。校正所用的比率只取自 dev,并在任何校正后的通过率旁同时给出 dev 和 held-out 两者的比率。held-out 在各项选择完成之后只报告一次,并且不让它参与任何选择。

校正通过率

最近一次修改见于版次 2026.11.3

观察到的通过率统计了两类裁决:裁判抓到的真实通过,以及裁判放过的错误通过。校正方法试图一次性消除这两类偏差。给定裁判的 TPR 和 TNR,它求解出能产生所观察到的通过率的真实通过占比。本书将其写作 (observed + TNR - 1) / (TPR + TNR - 1)。Rogan 和 Gladen(1978)针对筛查检验处理过同一问题,他们的摘要提到给出了此类调整。本书只读过该摘要,因此这里的公式是本书自己对该校正的表述,与其代码的计算方式一致,并非对该论文的引用。

这一校正有其限度。它要除以 TPR + TNR - 1。如果裁判的两个比率都接近随机所能给出的水平,分母就接近零,此时任一比率的微小误差都会变成校正率的大幅波动。当该分母低于 0.1 时,本书的代码拒绝校正,并抛出错误而不是输出一个比率。下面的运行结果远高于这一下限。实践中,团队按顺序做四件事:在与待校正数据集分开的校准集上测量 TPR 和 TNR;检查分母是否越过下限;对可读回复上的观察率应用校正;在结果旁写明迁移假设。

corrected-pass-rate.py Python 3.12.15 · numpy 2.5.5 · pydantic 2.14.3 · typing-extensions 4.16.0 通过
"""The baseline's answer-judge pass rate over the test items the judge gave a readable verdict, corrected for the judge's errorswith TPR and TNR from dev only. The corrected rate is printed beside the observed rate and the two rates the correction uses.One judge reply has no PASS or FAIL on its first line. It is left out of the rate and printed by name, never counted as aFAIL. The TPR and TNR come from HelpSteer2, where the judge rates other models' answers without a reference. This judge readsthe answers against a written reference. The correction assumes the two error profiles transfer; nothing here tests that.The last lines apply the same correction to the calibration set itself: the rates are measured on those same rows, so thatcheck shows the arithmetic, not how well the correction generalises."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom lib.calibration import (    confusion,    corrected_pass_rate,    crossover_pass_rate,    helpsteer2_judgments,    readable_verdicts,    tnr,    tpr,)from lib.judging import passedfrom lib.prompts import REF_SHA256from lib.stats import pctfrom lib.testset import load_itemsitems = load_items()  # all 120 items of the test set, dev and held-out togetherfound, unreadable = readable_verdicts("judge-answers-baseline", [item.id for item in items], REF_SHA256)details = "".join(f' ({item_id}, "{first}")' for item_id, first in unreadable)print(f"unreadable verdicts: {len(unreadable)}{details}")  # left out of the rate below, not counted as FAILpasses = int(passed(found).sum())  # found is keyed in sorted id orderobserved = passes / len(found)print(f"observed pass rate, readable items: {pct(passes, len(found))}")dev = confusion(helpsteer2_judgments("dev"))  # the only rows the correction's TPR and TNR may come fromprint(f"TPR, dev: {pct(dev.tp, dev.tp + dev.fn)}")print(f"TNR, dev: {pct(dev.tn, dev.tn + dev.fp)}")# Below this observed rate the correction lowers the rate; above it, the correction raises it.crossover = crossover_pass_rate(tpr(dev), tnr(dev))print(f"crossover point, dev: {100 * crossover:.1f}% (TPR {100 * tpr(dev):.1f}%, TNR {100 * tnr(dev):.1f}%)")corrected = corrected_pass_rate(observed, tpr(dev), tnr(dev))  # refused if TPR + TNR - 1 is below 0.1print(f"corrected pass rate: {100 * corrected:.1f}%")# The sanity check: the same correction on the calibration set, with rates measured on those same rows. It checks the# arithmetic, not transfer to the answers: it should return the human PASS rate, and it does by construction.calibration = confusion(helpsteer2_judgments())judge_rate = (calibration.tp + calibration.fp) / calibration.nprint(f"calibration set, judge PASS rate: {pct(calibration.tp + calibration.fp, calibration.n)}")print(f"calibration set, corrected judge PASS rate: {100 * corrected_pass_rate(judge_rate, tpr(calibration), tnr(calibration)):.1f}%")print(f"calibration set, human PASS rate: {pct(calibration.tp + calibration.fn, calibration.n)}")calibration_crossover = crossover_pass_rate(tpr(calibration), tnr(calibration))  # the same test, on the same rowsprint(f"crossover point, calibration set: {100 * calibration_crossover:.1f}% "      f"(TPR {100 * tpr(calibration):.1f}%, TNR {100 * tnr(calibration):.1f}%)")
输出python corrected-pass-rate.py
unreadable verdicts: 1 (q-0043, "VERDICT: PARTIAL")
observed pass rate, readable items: 76.5% (91 of 119)
TPR, dev: 80.4% (37 of 46)
TNR, dev: 61.4% (27 of 44)
crossover point, dev: 66.4% (TPR 80.4%, TNR 61.4%)
corrected pass rate: 90.5%
calibration set, judge PASS rate: 61.7% (111 of 180)
calibration set, corrected judge PASS rate: 51.1%
calibration set, human PASS rate: 51.1% (92 of 180)
crossover point, calibration set: 68.9% (TPR 81.5%, TNR 59.1%)

输入是基线的答案裁判对测试条目给出的裁决,共 120 条,开发集与留出集合在一起。有一条回复没有可读的裁决,因为它的第一行既不是 PASS 也不是 FAIL。该示例按名称将其打印出来,并将其排除在比率之外,因为裁判无法读取的回复并不等于 FAIL。第 5 章说明了代码处理不可读裁决的两种方式。对应的那一行写作 1 (q-0043, "VERDICT: PARTIAL")。第 1 章把通过率定义为对集合中每个条目计算的比率。这里的比率只针对可读条目,因此与该定义相差被排除的那一条回复。

可读条目上观察到的通过率为 76.5% (91 of 119)。校正使用开发集上的 TPR 和 TNR,并且只能使用这些行。其开发集 TPR 为 80.4% (37 of 46)。其开发集 TNR 为 61.4% (27 of 44)。

校正后的通过率为 90.5%。校正率估计的是,按本书的正确性界线,人工会判为通过的 sablefile 回复所占的份额。它不是裁判的通过率,后者就是上面的观察率,它也不是助手的准确率。只有当裁判在 sablefile 的回答上的错误与它在 HelpSteer2 各行上的错误相符时,这一估计才成立。这就是迁移假设,上面的 TPR 和 TNR 来自一个无参考裁判对其他模型回复的评分,而答案裁判则是对照参考答案检查 sablefile 的回复。

校正率高于观察率,交叉点说明了原因。观察率位于交叉点之下,在那里裁判的读数偏低。在该比率下,裁判对真实通过的漏判超过了它的错误通过,因此校正将其调高。

结果还接近代码的上限。代码把校正率截断到 0 至 1 的范围内。当观察率高于 TPR 时,未截断的值恰好超过 1,因为此时分子大于分母。这里观察率低于 TPR 不到四个百分点。如果裁判判为通过的开发集 PASS 行中有两行改判为失败,TPR 就会降到观察率以下,校正率将打印为 100.0%。

工作准则: 只用在校准集上测得的 TPR 和 TNR 来校正通过率。在校正率旁同时给出这两个值,分母偏小时拒绝校正,并在同一段中说明校正所依据的假设。下一节给出区间,以及应附在任何校正率旁边的单行改动。

一行数据对校正通过率的影响

correction-sensitivity.py Python 3.12.15 · numpy 2.5.5 · pydantic 2.14.3 · typing-extensions 4.16.0 通过
"""How much the corrected pass rate of corrected-pass-rate depends on its inputs. A 95% bootstrap interval resamples both thedev calibration rows and the readable test items, with the book's fixed seed. It prints the share of resamples that reachthe 100% cap, and the corrected rate when one dev row moves TPR or TNR up or down. Only dev rows set the correction's rates."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom dataclasses import replacefrom lib.calibration import confusion, correction_interval, corrected_pass_rate, helpsteer2_judgments, readable_verdicts, tnr, tprfrom lib.judging import passedfrom lib.prompts import REF_SHA256from lib.stats import RESAMPLES, interval_pct, pctfrom lib.testset import load_itemsitems = load_items()  # all 120 items of the test set, as in corrected-pass-ratefound, _ = readable_verdicts("judge-answers-baseline", [item.id for item in items], REF_SHA256)observed = int(passed(found).sum()) / len(found)dev_rows = helpsteer2_judgments("dev")dev = confusion(dev_rows)lo, hi, capped, refused = correction_interval(dev_rows, passed(found))  # resamples the dev rows and the readable itemsprint(f"corrected pass rate, 95% interval: {interval_pct(lo, hi)}")print(f"resamples at the 100% cap: {pct(capped, RESAMPLES)}")print(f"resamples refused, TPR + TNR - 1 below 0.1: {pct(refused, RESAMPLES)}")# One dev row moved: a human PASS row judged the other way changes TPR; a human FAIL row changes TNR.moved = {    "TPR one row higher": replace(dev, tp=dev.tp + 1, fn=dev.fn - 1),    "TPR one row lower": replace(dev, tp=dev.tp - 1, fn=dev.fn + 1),    "TNR one row higher": replace(dev, tn=dev.tn + 1, fp=dev.fp - 1),    "TNR one row lower": replace(dev, tn=dev.tn - 1, fp=dev.fp + 1),}for label, counts in moved.items():    print(f"corrected, {label}: {100 * corrected_pass_rate(observed, tpr(counts), tnr(counts)):.1f}%")
输出python correction-sensitivity.py
corrected pass rate, 95% interval: [62.1%, 100.0%]
resamples at the 100% cap: 29.5% (590 of 2000)
resamples refused, TPR + TNR - 1 below 0.1: 0.1% (2 of 2000)
corrected, TPR one row higher: 86.0%
corrected, TPR one row lower: 95.5%
corrected, TNR one row higher: 91.0%
corrected, TNR one row lower: 90.0%

该示例对开发集的行和可读条目同时进行重采样,共 2,000 次,使用本书固定的随机种子,并观察校正通过率的离散程度。95% 区间为 [62.1%, 100.0%]。这一区间很宽,因为 TPR 和 TNR 各自只依赖几十行开发集数据,而且区间的上端恰好就是上限本身。部分重采样结果达到了上限,其占比为 29.5% (590 of 2000)。因分母低于 0.1 而被拒绝的重采样占比为 0.1% (2 of 2000),区间是在其余重采样结果上计算的。

一行数据造成的变动如下。假设有一行人工判为通过的开发集数据被评判器判为 PASS 而不是 FAIL,则 TPR 会高出一行,校正通过率为 86.0%。假设这样的一行被判为 FAIL,则 TPR 会低出一行,校正通过率为 95.5%。对于 TNR,若有一行人工判为不通过而评判器判为通过的开发集数据,在被判为 FAIL 时,校正通过率变为 91.0%,在被判为 PASS 时,校正通过率变为 90.0%。需要重点关注的是 TPR:这里一行数据就会使结果变动四到五个百分点,而 TNR 的一行数据只使结果变动约半个百分点。

该区间涵盖了开发集行和可读条目的抽样变动,但不涵盖迁移假设。如果评判器在 sablefile 的回复上的错误情况与开发集不同,校正通过率的变动可能超出重采样所显示的范围。

**工作准则:**报告校正通过率时,应同时给出本书对各项比率所用的自助法区间、处于上限的重采样占比,以及一行数据造成的变动,以便读者看出单行数据的影响有多大。

迁移假设

最近一次修改见于版次 2026.11.3

上文的 TPR 和 TNR 来自这样一些数据行:裁判在没有参考答案的情况下,依据正确性评分标准阅读其他模型的回复,其中的 PASS 线是 HelpSteer2 正确性得分达到 3 分或以上。回答裁判则对照书面参考答案阅读 sablefile 的回复,此处的 PASS 表示回复与参考答案一致,正确的拒绝回答也算通过。这两个裁判所回答的是关于「正确」含义的不同问题。迁移假设是:裁判对人工通过项的漏判率,以及对人工未通过项的放过率,在 sablefile 的回复上与在 HelpSteer2 数据行上相同。本章没有任何内容检验这一假设。只有当输入、回复、问题和 PASS 标准的差异不改变误差特征时,这一校正才成立。第 5 章阐述了有参考答案的裁判与没有参考答案的裁判之间的区别。

同一示例的最后几行把校正应用到校准数据行上,所用的比率取自这些数据行。在这些数据行上,裁判的 PASS 率为 61.7% (111 of 180)。其交叉点为 68.9% (TPR 81.5%, TNR 59.1%),裁判的比率低于该点,因此校正会使该比率降低。校正后的裁判 PASS 率为 51.1%。人工 PASS 率为 51.1% (92 of 180)。

校正后的裁判比率恰好还原出人工比率。这是代数运算的必然结果,因为这些比率就是在这些相同的数据行上测得的。该检查只确认算术没有错误,并不说明这一校正是否适用于 sablefile,读者也不应把它当作迁移成立的证据。

更好的做法是为本书自己的回复获取标签。本书没有这类标签,因为没有人对 sablefile 的回复做过评分。拥有这类标签的读者应当在其上进行校准,并像本章把开发集与留出集分开那样,让校准所用的划分与被校正的集合保持分离。这样可以消除迁移假设的大部分,而公开数据行只是为这一假设付出代价,并不能消除它。

工作准则: 在每个校正后的比率旁边、同一段落中写明迁移假设,并指出校准裁判与该比率所描述的裁判之间的差异。在比率所来自的数据行上核对算术,并说明这类核对并不检验迁移。在针对该比率所描述的回答的人工标签出现并已与裁判核对之前,把校正后的比率称为估计值,仅在该假设成立时有效。

成对校准

成对评判器阅读两条回复,从中选出更好的一条,而不是对每条回复分别判定通过或不通过。人工一侧采用 HelpSteer2 中针对同一提示的两条回复之间的偏好。成对评判器有一个已知的弱点:哪条回复放在位置 A、哪条放在位置 B,可能决定最终的选择。第 5 章解释了本书为何要求评判器以两种顺序分别评判每一对回复,第 7 章则分析位置造成的顺序改变。本节要问的是:把两种顺序都计入之后,与人工偏好的一致率是什么样子。本节打印的顺序改变计数与第 5 章打印的相同,在此展示只是为了解释两种一致率之间的差距。

每一对由一个 HelpSteer2 提示、两条回复以及人工对二者的偏好组成。人工判为平局的回复对已被剔除,因此每一对都有人工的选择。评判器给出 TIE 算作未命中,因为人工选出了其中一条,而评判器却判定两条回复相当。只取单一顺序得到的比率取决于评判器偏向哪个字母,所以只报告一种顺序的团队,报告的是一个会随回复位置而变动的数字。把两种顺序都计入,就去掉了这种自由度,代价是数字更低。我们建议对成对评判器报告这个更严格的比率,而把单一顺序的比率仅仅当作诊断两者差距的依据来读。

运行示例之前,请先预测:一对回复只有在两种顺序下都选中人工偏好的那条回复时才计数,它的得分会高于还是低于单取任一种顺序的得分。然后用输出来检验这一猜测。

pairwise-agreement.py Python 3.12.15 · numpy 2.5.5 通过
"""How often the pairwise judge's verdict agrees with the human preference on each HelpSteer2 pair, dev and held-out apart.Three rates: the A,B order alone, the B,A order alone (both mapped back to the original responses), and both orders together,where a pair counts only when both orders pick the human's response. A flipped pair (the same letter won both times) cannever count in the last rate, so the flipped count printed beside it is the number of misses that come from position.Each single-order rate uses the pairs whose verdict in that order is readable; a TIE is judged and is not a pick, so it isa miss. The interval is the 95% percentile bootstrap over pairs of the both-orders rate."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom lib.judging import both_orders, human_pairsfrom lib.stats import bootstrap_mean, interval_pct, pctAB = "judge-hs2-pairs-ab"BA = "judge-hs2-pairs-ba"pairs = human_pairs()  # all 150 pairs, sorted by id, each with its split and the human's pickorders = both_orders(AB, BA, list(pairs))  # both recordings read for every pair, sorted by idfor split in ("dev", "held-out"):    rows = [o for o in orders if pairs[o.pair_id].split == split]    human = {o.pair_id: pairs[o.pair_id].preferred for o in rows}    ab = [o.ab == human[o.pair_id] for o in rows if o.ab is not None]    ba = [o.ba == human[o.pair_id] for o in rows if o.ba is not None]    both = [o.ab == human[o.pair_id] and o.ba == human[o.pair_id] for o in rows if o.ab is not None and o.ba is not None]    flipped = sum(1 for o in rows if o.kind == "flipped")    print(f"agreement, A,B order, {split}: {pct(sum(ab), len(ab))}")    print(f"agreement, B,A order, {split}: {pct(sum(ba), len(ba))}")    print(f"agreement, both orders, {split}: {pct(sum(both), len(both))}; flipped pairs: {flipped}")    lo, hi = bootstrap_mean([float(hit) for hit in both])  # 95% interval over pairs, the level for one comparison    print(f"95% interval, both orders, {split}: {interval_pct(lo, hi)}")
输出python pairwise-agreement.py
agreement, A,B order, dev: 77.3% (58 of 75)
agreement, B,A order, dev: 73.3% (55 of 75)
agreement, both orders, dev: 65.3% (49 of 75); flipped pairs: 15
95% interval, both orders, dev: [53.3%, 76.0%]
agreement, A,B order, held-out: 74.7% (56 of 75)
agreement, B,A order, held-out: 76.0% (57 of 75)
agreement, both orders, held-out: 62.7% (47 of 75); flipped pairs: 19
95% interval, both orders, held-out: [52.0%, 73.3%]

两种顺序都计入时,一致率低于任何单一顺序,而差距来自顺序改变的回复对。在开发集上,仅 A,B 顺序给出 77.3% (58 of 75)。仅 B,A 顺序给出 73.3% (55 of 75)。两种顺序都计入则给出更严格的比率 65.3% (49 of 75); flipped pairs: 15。

分号之后的计数是顺序改变的回复对,示例的输出将其标为 flipped。按照第 5 章的定义,顺序改变的回复对是指判定结果跟随位置而不是跟随回复的那一对。顺序改变的回复对永远无法计入两种顺序的一致率,因此每一个在其中都是未命中。

留出集呈现同样的规律。A,B 顺序给出 74.7% (56 of 75),B,A 顺序给出 76.0% (57 of 75),两种顺序都计入给出 62.7% (47 of 75); flipped pairs: 19。

两种顺序都计入的比率,其在回复对上的区间,在开发集上为 [53.3%, 76.0%]。留出集为 [52.0%, 73.3%]。这些区间很宽,因为每个划分中的回复对都很少。站得住的结论是这一规律:随位置改变选择的评判器,不能在任何单一顺序下被读作与人工一致。

学完本章,读者可以度量评判器超出随机水平的一致率、它在该样本上的未命中和误通过,以及修正后的通过率及其旁边写明的迁移假设。这些度量建立在公开数据行之上,而不是 sablefile 的回复之上,而且按两种顺序计数的成对评判器仍然会因位置而损失回复对。第 7 章在本书自己的记录上检验评判器所能显示的局限,从位置开始,读者将在那里学到何时应当不再信任某个判定。

工作准则: 评判器比较两条回复时,应以两种顺序各运行一次,并报告两种顺序都计入的一致率,同时在旁边列出顺序改变的回复对。不要把单一顺序的比率当作评判器与人工的一致率。报告回复对上的区间,并说明顺序改变的回复对算作未命中,因为这正是位置造成的代价。

本章,在本版次中

版次 2026.11.3示例于 2026年11月21日 通过本章 6个示例 个示例中有 6 个通过

译自英文版图书,版次 2026.11.3。

引用本节

格式

每种格式均引用英文原书,本译本以其为准。

每种格式都会注明该版次。其链接会打开当前版次,节标题处会说明该节文本最后一次修改的时间。访问日期和检索日期即为您打开此页的当天。

本页内容

第 6 章,共 11 章: 对照人工评分度量评判器的错误,再校正通过率

  1. 人工评分及其性质
  2. 一致率与 kappa
  3. 真阳性率与真阴性率
  4. 校正通过率
  5. 一行数据对校正通过率的影响
  6. 迁移假设
  7. 成对校准

返回顶部全部章节