変更が改善になっているかを判断し、必要な質問数を見積もる

読了まで約30 分分、6 節 節の 5 例 例。

第2026.11.3版 2026年11月21日時点で例が通過 54 例中 54 例が合格 変更点

AIによる翻訳。英語版は人による検証済みである。 当社の書籍の作り方

英語版の書籍(版2026.11.3)から翻訳した。 原文を読む

この章を読み終えると、対応のある比較に区間を用いて、アシスタントの二つのバージョンの差がノイズを超えるものかどうかを述べられるようになる。また、ある大きさの差を検定で示すために必要な質問の数も算出できる。

第1章では、アシスタントを一度測定し、その合格率に区間を与えた。続いて二つのプロンプトを20項目で比較した。両者の差の区間の幅は30.0 pointsであり、その章は一つの約束で終わっていた。差を示すのに何項目が必要かは、後の章で算出するというものである。この章がその約束を果たす。プロンプトを変更するチームには、三つの答えが必要である。合格率の変化は、テストにつきまとう偶然so以外の理由で生じたのか。そもそも、この比較は差を示せるものだったのか。そして、関心のある差を示すには何問必要なのか。

ここに示す数値はすべて、一つのアシスタントモデルである Qwen3-4B-Instruct-2507 と、一つの判定者、すなわち温度ゼロで動かした同じモデルから得たものである。区間が覆うのは、項目の抽出に由来するばらつきである。最初の節では、返答のサンプリングに由来するばらつきを、区間を用いずに測る。判定者の偏りは区間に含まれない。それは第7章で検証する。各結果は、この点を念頭に置いて読むこと。

1つの項目内のばらつき

同じ質問を2回尋ねると、モデルが異なる答えを返すことがある。この章の比較では、項目とプロンプトごとに記録した返答を1つだけ使うので、各判定は1つの返答に基づいている。温度が高いとモデルはサンプリングを行い、ある項目の判定がサンプルごとに変わりうる。これは比較にとって重要である。2つのプロンプトの差が、サンプル間の揺れより小さければ、それは差とは言えない。また、1回の実行から読み取った率は、その揺れを隠してしまう。

ばらつき用のセットには、各開発用項目に対するアシスタントの返答が5サンプルずつ入っている。サンプルは温度0.7で生成した。判定器はすべての返答を温度0で読む。ある項目の5つの判定がすべて同じでないとき、その項目は反転したとみなす。反転の数を数えると、何も変更を加える前の段階で、判定がサンプルごとにどれだけ動くかの尺度が得られる。

flip-rate.py Python 3.12.15 · numpy 2.5.5 · pydantic 2.14.3 · typing-extensions 4.16.0 合格
"""The flip rate over the dev variance set: the share of items whose judge verdict differs across their five samples. Theprinted line 'flip rate' rests on the per-item PASS counts, which are printed with it: how many items passed 0, 1, 2, 3, 4or 5 of 5 samples, and the mean pass rate. The temperature-0 baseline's pass rate over the same items is printed forcomparison. An item with an unreadable verdict is printed by id and left out, never counted as FAIL."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom lib.calibration import readable_verdictsfrom lib.judging import passedfrom lib.prompts import REF_SHA256from lib.stats import pctfrom lib.testset import load_itemsfrom lib.variance import VARIANCE_SAMPLES, item_pass_countsVARIANCE = "judge-answers-variance"BASELINE = "judge-answers-baseline"SAMPLES = len(VARIANCE_SAMPLES)items = [item.id for item in load_items(split="dev")]  # eighty dev items, sorted by idcounts = item_pass_counts(VARIANCE, items)excluded = [row for row in counts if not row.complete]kept = [row for row in counts if row.complete]for row in excluded:    samples = ", ".join(str(sample) for sample in row.unreadable)    print(f"unreadable, {row.item_id}: samples {samples} (left out, not counted as FAIL)")print(f"left out of the flip rate (unreadable verdict): {len(excluded)}")n = len(kept)print(f"variance items compared (n): {n}")print(f"flip rate: {pct(sum(1 for row in kept if row.flaky), n)}")spread = [sum(1 for row in kept if row.passes == passes) for passes in range(SAMPLES + 1)]assert sum(spread) == n  # every kept item falls in exactly one PASS countfor passes, count in enumerate(spread):    print(f"items with {passes} of {SAMPLES} PASS: {count}")print(f"mean per-item pass rate across samples: {pct(sum(row.passes for row in kept), n * SAMPLES)}")found, baseline_unreadable = readable_verdicts(BASELINE, [row.item_id for row in kept], REF_SHA256)assert not baseline_unreadable  # q-0043 is already left out above, so no kept item is unreadable under the baselinebaseline = passed(found)print(f"baseline pass rate, same items (temperature 0): {pct(int(baseline.sum()), len(baseline))}")
出力python flip-rate.py
unreadable, q-0043: samples 1, 4 (left out, not counted as FAIL)
left out of the flip rate (unreadable verdict): 1
variance items compared (n): 79
flip rate: 2.5% (2 of 79)
items with 0 of 5 PASS: 16
items with 1 of 5 PASS: 1
items with 2 of 5 PASS: 0
items with 3 of 5 PASS: 0
items with 4 of 5 PASS: 1
items with 5 of 5 PASS: 61
mean per-item pass rate across samples: 78.5% (310 of 395)
baseline pass rate, same items (temperature 0): 78.5% (62 of 79)

コードは項目ごとに、5サンプルのうち判定器が合格とした数を集計する。判定を読み取れない項目は不合格として数えず、集計から除き、除いた項目を出力に示す。

ほとんどの項目は動かない。61個の項目は5サンプルすべてで合格し、16個はすべて不合格である。反転した項目のうち、1個は1サンプルだけ合格し、1個は4サンプルで合格する。

反転率は2.5% (2 of 79)である。

全サンプルにわたる平均合格率は78.5% (310 of 395)である。基準となる、項目ごとに温度0で1つの返答を得た場合の合格率は78.5% (62 of 79)である。両者は等しく、反転した2つの項目は互いに逆の方向に作用している。これはばらつき用セットが使うプロンプトP1についての結果であり、別のプロンプトではこれほど安定しないかもしれない。

これは限られた結果である。境界的な質問がより多いセットなら、反転はもっと増えるだろう。また、反転率は項目を数えたものであり、それ自体には区間がない。これほど少ない反転項目の数からは、次の変更で項目がどれだけ反転するかについてほとんど何も言えない。

反転率が測るのは、項目を固定したうえで、このアシスタントの返答をサンプリングすることから生じるばらつきだけである。2つのプロンプトの比較は、各プロンプトが正解する項目によっても動く。最後の節では、このサンプリングのばらつきを下限として用いる。ただし、返答をサンプリングする比較に限る。差に必要な質問数を参照されたい。

実践ルール: 1回の実行の率を信頼する前に、実際に運用する温度でばらつき用セットを実行し、反転率を平均合格率と並べて読むこと。反転率は、サンプリングによって1つのプロンプトの判定がどこまで動くかを示す。それが比較の限界を与えるのは、その比較も返答をサンプリングする場合に限られる。

項目に対するブートストラップ

最終変更:版2026.11.3

第1章では、合格率に対する区間を示し、それを用いて小さな集合を読み取った。本節ではその手法を説明する。この章の残りの部分で、この手法を三通りに使うからである。すなわち、率に対して、対応のある差に対して、そしてより厳しい水準を満たさなければならない差に対して用いる。

この手法はパーセンタイル・ブートストラップである。集合に含まれる項目は、チームが作り得た問いの一標本にすぎないため、別の集合であれば率もいくらか異なるはずである。その差がどの程度かを見積もるには、集合から項目を復元抽出する。抽出する個数は集合が持つ項目数と同じとし、同じ項目が二度出ることもあれば、まったく出ない項目もあるようにする。その抽出に対して統計量を計算し、抽出を何度も繰り返して、結果の中央の95%を残す。ブートストラップはデータを加えない。集合がすでに持っている項目を再利用し、集合が同種の別の抽出であった場合に統計量がどれだけ動き得るかを示す。

再標本化の単位は項目であり、これが守るべき規則である。率の場合、各項目はその判定を寄与する。対応のある差の場合、各項目は一つの数を寄与する。プロンプトBの判定からベースラインの判定を引いた値であり、プラス1、0、マイナス1のいずれかになる。分散用の集合では、一つの項目の五つの標本をまとめて保持する。それらは一つの問いに答えたものだからである。分けて抽出すると、五つの独立した問いのように見えてしまい、区間は狭くなりすぎる。Miller (2024)は、関連するグループとして出される問いについて同じ点を指摘している。この論文はプレプリントであり、実務者の覚書であって、査読を経た手法ではない。そのため本書では、証明としてではなく、理由づけのために用いる。

本書では、数値を再現できるように設定を固定する。この手法は、シード0で2,000回の再標本を抽出し、呼び出しのたびにその内部で新しい乱数生成器を作る。したがって、同じデータからは、それ以前に何が実行されていても同じ区間が得られる。シードはデータの性質ではなく、選択である。シードを変えると端点がわずかに動く。設定を書き残すのはそのためである。

この手法はまた、集合が問いの公平な標本であることに依存している。これは第1章で論じたことであり、どのような区間でも確かめることはできない。小さな集合からは粗い区間しか得られない。この規模の集合に対するパーセンタイル区間の端点は第一の見積もりであり、近似値として読むべきである。

実践ルール: 項目を再標本化し、項目内の実行は決して再標本化せず、一つの項目の標本はまとめて保持する。再標本の回数とシードはコードの中で固定し、同じデータから同じ区間が得られるようにする。集合の項目数が少ないときは、その区間を粗いものと呼び、そのことを区間のそばに明記する。

対応のある比較

最終変更:版2026.11.3

2つのプロンプトが同じ質問に答えるとき、その結果は対応している。対応のある比較では、項目ごとに、プロンプト B の判定からベースラインの判定を引き、その差を集合全体で平均する。区間は、項目に対するブートストラップから得る。

対応をとることが重要なのは、ほとんどの項目で両者が一致するからである。両方のプロンプトが合格する項目も、両方が不合格になる項目も、質問の難しさにかかわらず、差には何も寄与しない。比較のばらつきは、2つのプロンプトの判定が分かれる項目から生じる。対応のない比較は、2つの別々の合格率を取り出して並べる。この比較では、一致する項目も含めたすべての項目について、質問ごとのばらつきがそのまま残り、そのばらつきが実際の差を覆い隠すことがある。対応のある比較では、2つのプロンプトが共有する部分が打ち消される。対応のある差を支持する Miller (2024) の議論も同じことを述べている。各項目における2つのモデルのスコアが正の相関をもつかぎり、対応のある差の分散は小さくなる。

paired-prompt-b.py Python 3.12.15 · numpy 2.5.5 · pydantic 2.14.3 · typing-extensions 4.16.0 合格
"""Compares prompt-b (P2) with the baseline prompt (P1) on the eighty dev items: each pass rate, the paired difference withits 95% interval, and how the items split between the two prompts. 'Better' is used only when the whole interval is abovezero (plan section 6.4); the interval here includes zero, so the reading is no difference detected."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom lib.calibration import readable_verdictsfrom lib.judging import passedfrom lib.prompts import REF_SHA256from lib.stats import bootstrap_mean, interval_points, pctfrom lib.testset import load_itemsBASELINE = "judge-answers-baseline"PROMPT_B = "judge-answers-prompt-b"items = [item.id for item in load_items(split="dev")]  # eighty dev items, sorted by idp1_found, p1_unreadable = readable_verdicts(BASELINE, items, REF_SHA256)p2_found, p2_unreadable = readable_verdicts(PROMPT_B, items, REF_SHA256)for label, unreadable in (("P1 (baseline)", p1_unreadable), ("P2 (prompt-b)", p2_unreadable)):    details = "".join(f' ({item_id}, "{first}")' for item_id, first in unreadable)    print(f"unreadable verdicts, {label}: {len(unreadable)}{details}")# An item without a readable verdict under either prompt is dropped from both sides: a paired difference needs the same items.excluded = {item_id for item_id, _ in p1_unreadable + p2_unreadable}kept = [item_id for item_id in items if item_id not in excluded]first = passed({item_id: p1_found[item_id] for item_id in kept})  # 1.0 or 0.0 per item, in id ordersecond = passed({item_id: p2_found[item_id] for item_id in kept})n = len(kept)lo, hi = bootstrap_mean(second - first)  # 95%, one comparison: the default levelprint(f"P1 (baseline) pass rate: {pct(int(first.sum()), n)}")print(f"P2 (prompt-b) pass rate: {pct(int(second.sum()), n)}")print(f"difference, P2 minus P1: {100 * float((second - first).mean()):+.1f} points")print(f"95% interval of the difference: {interval_points(lo, hi)}")print(f"paired items (n): {n}")print(f"items only P1 passes: {int(((first == 1) & (second == 0)).sum())}")print(f"items only P2 passes: {int(((first == 0) & (second == 1)).sum())}")print(f"items both pass: {int(((first == 1) & (second == 1)).sum())}")print(f"items neither passes: {int(((first == 0) & (second == 0)).sum())}")if lo > 0:    print(f"reading: P2 is better at n = {n}")elif hi < 0:    print(f"reading: P2 is worse at n = {n}")else:    print(f"reading: no difference detected at n = {n}")
出力python paired-prompt-b.py
unreadable verdicts, P1 (baseline): 1 (q-0043, "VERDICT: PARTIAL")
unreadable verdicts, P2 (prompt-b): 0
P1 (baseline) pass rate: 78.5% (62 of 79)
P2 (prompt-b) pass rate: 81.0% (64 of 79)
difference, P2 minus P1: +2.5 points
95% interval of the difference: [-3.8, +10.1] points
paired items (n): 79
items only P1 passes: 3
items only P2 passes: 5
items both pass: 59
items neither passes: 12
reading: no difference detected at n = 79

ここでは、開発用の項目に対して、プロンプト B をベースラインと比較している。どちらかのプロンプトで判定を読み取れない項目は、両側から除外する。対応のある差には、両側で同じ項目が必要だからである。出力される行には、各合格率、差、その区間、および対応のとれた項目数が示される。

ベースラインの合格率は 78.5% (62 of 79) である。プロンプト B の合格率は 81.0% (64 of 79) である。差(プロンプト B からベースラインを引いた値)は +2.5 points で、95% 区間は [-3.8, +10.1] points である。

内訳を見ると、差がどこに生じているかがわかる。両方のプロンプトで合格する項目は 59 件、両方で不合格になる項目は 12 件である。差を動かすのは判定が分かれた項目だけであり、プロンプト B のみで合格する項目が 5 件、ベースラインのみで合格する項目が 3 件ある。

区間にはゼロが含まれるため、読み取りは no difference detected at n = 79 となる。区間は低下から上昇にまたがっており、この集合では、どちら側がより近いかを言うことはできない。差が検出されなかったという結果は、その大きさの集合についての所見である。2つのプロンプトが等しいという主張ではなく、本文でもそのように述べてはならない。

実践ルール: 変種どうしは同じ項目で、対応をとって比較し、差を区間と n とともに報告する。一方の変種をより良いと呼ぶのは、区間全体がゼロより上にあるときだけであり、より悪いと呼ぶのは、区間全体がゼロより下にあるときだけである。区間にゼロが含まれるときは、その n では差が検出されなかったと報告し、その差を検出するには何項目必要かを示す。その求め方は 差の検出に必要な質問数 で示している。

ホールドアウトは一度だけ

最終変更:版2026.11.3

開発用の項目は構築のためのものである。チームはそれらを使ってプロンプトを調整し、失敗例を読み、次の版を修正してよい。しかし、変更はデブ用の結果に導かれて作られたものであるため、その結果によって変更が有効であることを証明することはできない。ホールドアウト集合は、調整されていない検証手段である。ホールドアウトでの比較は、実行前に固定した規則、すなわち比較する版、水準、読み取り方に従って一度だけ行う。方針を変えてから再実行したり、数値を見た後で水準を選んだりすれば、区間は表示どおりの意味を持たなくなる。

この節では、ホールドアウト集合で三つの比較を行い、それぞれの版をベースラインと比べる。プロンプトBは対応のある比較で扱ったものである。版k5は、節を三つではなく五つ取得する。版unfilteredは、問われた版だけでなく、ドキュメントのすべての版から同時に、三つの節を取得する。

held-out-variants.py Python 3.12.15 · numpy 2.5.5 · pydantic 2.14.3 · typing-extensions 4.16.0 合格
"""Compares prompt-b, k5 and unfiltered with the baseline on the held-out items, each variant once, at the level theBonferroni rule gives for three comparisons (98.33%). Each variant gets its paired difference, interval, n and a reading byplan section 6.4. Nothing was chosen with these numbers: the variants, the level and the reading rule were fixed beforethis run, and the run happens once."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom lib.calibration import readable_verdictsfrom lib.judging import passedfrom lib.prompts import REF_SHA256from lib.stats import RESAMPLES, bootstrap_mean, interval_pointsfrom lib.testset import load_itemsBASELINE = "baseline"VARIANTS = ("prompt-b", "k5", "unfiltered")M = len(VARIANTS)  # one comparison per variant, each against the baselineLEVEL = 1 - 0.05 / M  # Bonferroni: 1 - 0.05/m, which is 98.33% for m = 3 (plan section 6.3)items = [item.id for item in load_items(split="held-out")]  # sorted by idprint(f"comparisons (m): {M}")print(f"share of the 5% for each comparison, 0.05 / m: {0.05 / M:.4f}")print(f"level of each interval, 1 - 0.05 / m: {100 * LEVEL:.2f}%")print(f"resamples beyond each end of an interval: {RESAMPLES * (1 - LEVEL) / 2:.1f}")base_found, base_unreadable = readable_verdicts(f"judge-answers-{BASELINE}", items, REF_SHA256)details = "".join(f' ({item_id}, "{first}")' for item_id, first in base_unreadable)print(f"unreadable verdicts, baseline: {len(base_unreadable)}{details}")for name in VARIANTS:    found, unreadable = readable_verdicts(f"judge-answers-{name}", items, REF_SHA256)    details = "".join(f' ({item_id}, "{first}")' for item_id, first in unreadable)    print(f"unreadable verdicts, {name}: {len(unreadable)}{details}")    # An item unreadable under the baseline or this variant is dropped from both sides of this pair only.    excluded = {item_id for item_id, _ in base_unreadable + unreadable}    kept = [item_id for item_id in items if item_id not in excluded]    first = passed({item_id: base_found[item_id] for item_id in kept})    second = passed({item_id: found[item_id] for item_id in kept})    n = len(kept)    lo, hi = bootstrap_mean(second - first, level=LEVEL)    if name == "prompt-b":  # the chapter says this lower end is exactly zero, so the run must show it        assert lo == 0.0, "the prompt-b lower bound must be exactly zero"    print(f"{name} minus baseline, difference: {100 * float((second - first).mean()):+.1f} points")    print(f"{name} minus baseline, {100 * LEVEL:.2f}% interval: {interval_points(lo, hi)}")    print(f"{name} minus baseline, n: {n}")    if lo > 0:        print(f"{name} minus baseline, reading: better at n = {n}")    elif hi < 0:        print(f"{name} minus baseline, reading: worse at n = {n}")    else:        print(f"{name} minus baseline, reading: no difference detected at n = {n}")
出力python held-out-variants.py
comparisons (m): 3
share of the 5% for each comparison, 0.05 / m: 0.0167
level of each interval, 1 - 0.05 / m: 98.33%
resamples beyond each end of an interval: 16.7
unreadable verdicts, baseline: 0
unreadable verdicts, prompt-b: 0
prompt-b minus baseline, difference: +10.0 points
prompt-b minus baseline, 98.33% interval: [+0.0, +22.5] points
prompt-b minus baseline, n: 40
prompt-b minus baseline, reading: no difference detected at n = 40
unreadable verdicts, k5: 0
k5 minus baseline, difference: +2.5 points
k5 minus baseline, 98.33% interval: [-12.5, +18.4] points
k5 minus baseline, n: 40
k5 minus baseline, reading: no difference detected at n = 40
unreadable verdicts, unfiltered: 0
unfiltered minus baseline, difference: -10.0 points
unfiltered minus baseline, 98.33% interval: [-27.5, +8.4] points
unfiltered minus baseline, n: 40
unfiltered minus baseline, reading: no difference detected at n = 40

三つの比較が一つのホールドアウト集合を共有するため、各区間は95%より高い水準で設定する。その理由は多数の比較で説明する。水準は98.33%である。各版について、差、区間、対応のある項目数、読み取りが表示される。

ホールドアウトの項目数は40であり、デブ用の79に比べて少ない。そのため、同じ差でも区間は広くなり、この集合での結果は項目数が許す範囲でしか鋭くならない。分割によって結果の誠実さは保たれるが、その代償として使える項目が減る。

プロンプトBの差は+10.0 pointsであり、区間は[+0.0, +22.5] pointsである。この比較の対応のある項目数は40である。

k5の差は+2.5 pointsであり、区間は[-12.5, +18.4] pointsである。unfilteredの差は-10.0 pointsであり、区間は[-27.5, +8.4] pointsである。

同じプロンプトについてデブでは+2.5 pointsが得られており、二つの点推定値は異なる。40件のホールドアウト項目では、どちらが真の値に近いかを判別できない。信頼水準98.33%、検出力80%でこの集合が検出できる最小の差は16.2 pointsであり、二つの点推定値はいずれもこの集合の検出可能な水準を下回る。その計算は差の検出に必要な質問数で示す。

規則に従えば、三つとも差は検出されなかったと読む。プロンプトBについて表示される読み取りはno difference detected at n = 40である。k5ではno difference detected at n = 40、unfilteredではno difference detected at n = 40である。

プロンプトBは境界に近い例である。区間は[+0.0, +22.5] pointsであり、下端はちょうど0である。読み取りの規則は、区間全体が0より上にあるときに限って改善したと読むと定めており、この区間は0に達してはいるが超えてはいない。したがって規則上、読み取りは差が検出されなかったである。区間の各端の外側には、2,000回のリサンプルのうちそれぞれ16.7があり、判定は境界線上にある。実行前にシードを固定したのはこのためである。その大きさの点推定値には意味があると論じる読者もいるだろうが、この節はそのような議論をしない。規則は実行前に定められており、比較は一度だけ行い、この三つを低い水準や別の読み取りで見直すことは誰にも許されない。プロンプトBをさらに検証するのであれば、差の検出に必要な質問数で規模を定め、誰も結果を見ないうちに固定した新しいホールドアウト集合が必要であり、その結果はそれ単独で読む。すでに読んだ40件に項目を追加してプール全体を読み直すことは、すでに見た結果を二度目に見ることになる。

実践ルール: ホールドアウト集合を開く前に、比較する版、水準、読み取りの規則を固定し、各比較は一度だけ実行する。区間が0に達していれば、そのnでは差は検出されなかったということである。異なる答えを得るために、比較を再実行したり、水準を下げたり、読み取りを変えたりしてはならない。ホールドアウトの項目を追加してよいのは、採点される前に限る。

多重比較

比較の一つひとつが、だまされる機会になる。実際には差のない比較に対する 95% 区間でも、運によって 20 回に 1 回ほどは 0 を除外する結果になる。そのような比較を 3 つ行い、それぞれを 95% で報告すると、少なくとも 1 つが差として読める確率は 100 分の 5 を超える。章で報告する比較が増えるほど、そのうちの 1 つが偶然の結果である可能性は高くなる。

通常の対処法は Bonferroni 補正であり、誤りの許容量を比較の間で分け合う。1 つの指標について m 個の比較を行う場合、各区間の水準は 1 から 0.05 を m で割った値を引いたものとする。比較が 3 つなら、0.05 を 3 で割った値は 0.0167 であり、各区間の水準は 98.33% となる。これは保留データの節で用いた水準である。0.05 は各区間の両側の裾に分けられるので、片側の裾には 0.05 を m の 2 倍で割った値が割り当てられる。この計算は、比較どうしにどのような共通点があっても成り立つ。いずれかの比較で偽の差が現れる確率は、それぞれの確率の和を超えることはなく、その和は 5% である。

コードは m から水準を計算して表示するので、読者は比較の個数と照らして確かめられる。代償は区間の幅である。この水準では各区間が 95% の区間より広くなるため、区間が 0 を外れるには差がより大きくなければならない。個々の確率の和は、いずれかで偽の差が生じる確率の上界であるから、比較どうしで偽の結果が重なる場合には、この補正は保守的になる。本書がこの補正を使うのは、規則が簡潔に述べられ、確かめやすく、読者が比較の個数から再計算できるためである。

どの比較が個数に含まれるのか。この章では、対のある比較の節で扱った開発データでの比較は単独のものであり、チューニング用データによる実演例なので 95% で報告する。保留データでの 3 つの比較は 1 つの族をなし、調整後の水準で報告する。両方を目にした読者は、開発データの区間を保留データの結果として読んではならない。章が拠り所とするのは保留データの結果である。

個数は設計の一部である。1 つの指標について章で報告する比較の個数は、どの比較も実行する前に数えておく。結果が出た後に加えた比較は、探索的なものとして、独自の個数とともに族とは別に報告する。族の区間は実行したときのままにしておく。結果を見た後で設定し直すと、実行が従っていた規則そのものが変わってしまうからである。

実践ルール: 1 つの指標についての比較は、実行する前に個数を数え、各区間の水準を 1 から 0.05 をその個数で割った値を引いたものに設定する。水準はすべての区間の脇に示す。結果の後で加えた比較は探索的なものとして別に報告し、族の区間は設定し直さない。

差の検出に必要な問題数

比較の前に問うべきことは、チームが重視する大きさの差を示すのに何問必要か、である。答えは一つの量で決まる。二つの変種が項目ごとにどれだけ食い違うかである。食い違う項目が少ない二つのプロンプトは、少ない項目数でも小さな差を示す。 対応のある式を使うと、これを具体的に示せる。信頼水準に対応する両側の正規分布の値を z信頼、検出力に対応する値を z検出力と書く。このとき n = (z信頼 + z検出力)² · 分散(d) / δ² となる。ここで分散(d) は一つの項目の対応のある差の分散であり、δ は検出したい差である。この分散は、二つの変種が食い違う項目の割合から、両者の平均差の2乗を引いたものである。したがって、推定値を左右するのは合格率そのものではなく、食い違いである。この節では信頼水準95%、検出力80%を用いる。

sample-size.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pydantic 2.14.3 · typing-extensions 4.16.0 合格
"""How many items a paired comparison needs to detect a difference of 5 and of 10 points, with 95% confidence and 80% power.The main estimate reads the paired differences that prompt-b and the baseline show on the dev items: each item's d is+1, 0 or -1 (P2 minus P1), and the items on which they disagree set the variance. The floor uses only the judge'swithin-item sampling noise over five samples; it leaves the disagreement between variants out, so it is a lower bound."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom lib import variancefrom lib.answers import chapter_itemsfrom lib.calibration import readable_verdictsfrom lib.judging import paired, passedfrom lib.prompts import REF_SHA256from lib.stats import pctfrom lib.testset import load_items# n = (z_alpha + z_beta)^2 * var_d / delta^2, rounded up (variance.items_needed). var_d = p_discordant - mean(d)^2.# Smallest difference that n items detect: (z_alpha + z_beta) * sqrt(var_d / n) (variance.smallest_difference_points).BASELINE, PROMPT_B = "judge-answers-baseline", "judge-answers-prompt-b"CHAPTER_ONE_ITEMS = 20  # the chapter 1 set, read below the way twenty-cannot-tell reads ititems = [item.id for item in load_items(split="dev")]  # eighty dev items, sorted by idp1_found, p1_unreadable = readable_verdicts(BASELINE, items, REF_SHA256)p2_found, p2_unreadable = readable_verdicts(PROMPT_B, items, REF_SHA256)kept = [item_id for item_id in items if item_id not in {i for i, _ in p1_unreadable + p2_unreadable}]first = passed({item_id: p1_found[item_id] for item_id in kept})  # 1.0 or 0.0 per itemsecond = passed({item_id: p2_found[item_id] for item_id in kept})var_d = variance.paired_difference_variance(first, second)print(f"share of discordant items, P2 and P1 disagree: {pct(int((first != second).sum()), len(kept))}")print(f"assumption, the next change disagrees with the baseline on about as many items as prompt-b did "      f"({100 * (first != second).mean():.1f}% of items)")# Floor: five samples of a 0/1 verdict with k PASS give the unbiased within-item variance k(5 - k) / (5 * 4).rows = [row for row in variance.item_pass_counts("judge-answers-variance", items) if row.complete]noise = sum(row.passes * (5 - row.passes) / 20 for row in rows) / len(rows)print(f"floor, sampling noise only: dev items with five readable verdicts (n): {len(rows)}")print(f"floor, sampling noise only: mean within-item variance of one verdict: {noise:.4f}")# Two variants judged separately: their two noises add and the item's difficulty cancels, so the floor is 2 * noise.for label, var in (("main estimate", var_d), ("floor, sampling noise only", 2 * noise)):    print(f"{label}, variance of one item's paired difference: {var:.4f}")    for delta in (5.0, 10.0):        print(f"{label}, items needed for a {delta:.0f}-point difference: {variance.items_needed(var, delta)}")    print(f"{label}, smallest difference that {CHAPTER_ONE_ITEMS} items detect, 80% power and 95% confidence: "          f"{variance.smallest_difference_points(var, CHAPTER_ONE_ITEMS):.1f} points")# The chapter 1 set, read as twenty-cannot-tell reads it: its share of discordant items and its interval width.chapter_one = paired(BASELINE, PROMPT_B, [item.id for item in chapter_items()])width_20 = variance.interval_width_points(var_d, CHAPTER_ONE_ITEMS)print(f"chapter 1 set, share of items where the two verdicts differ: "      f"{pct(int((chapter_one.first != chapter_one.second).sum()), chapter_one.n)}")print(f"chapter 1 set, 95% interval width: {100 * (chapter_one.diff_hi - chapter_one.diff_lo):.1f} points")print(f"main estimate, 95% width at {CHAPTER_ONE_ITEMS} items: {width_20:.1f} points")print(f"reading: with {CHAPTER_ONE_ITEMS} items and a change that disagrees with the baseline on "      f"{100 * (first != second).mean():.1f}% of items, as prompt-b did, the smallest difference detected with 80% power "      f"at 95% confidence is {variance.smallest_difference_points(var_d, CHAPTER_ONE_ITEMS):.1f} points")
出力python sample-size.py
share of discordant items, P2 and P1 disagree: 10.1% (8 of 79)
assumption, the next change disagrees with the baseline on about as many items as prompt-b did (10.1% of items)
floor, sampling noise only: dev items with five readable verdicts (n): 79
floor, sampling noise only: mean within-item variance of one verdict: 0.0051
main estimate, variance of one item's paired difference: 0.1006
main estimate, items needed for a 5-point difference: 316
main estimate, items needed for a 10-point difference: 79
main estimate, smallest difference that 20 items detect, 80% power and 95% confidence: 19.9 points
floor, sampling noise only, variance of one item's paired difference: 0.0101
floor, sampling noise only, items needed for a 5-point difference: 32
floor, sampling noise only, items needed for a 10-point difference: 8
floor, sampling noise only, smallest difference that 20 items detect, 80% power and 95% confidence: 6.3 points
chapter 1 set, share of items where the two verdicts differ: 10.0% (2 of 20)
chapter 1 set, 95% interval width: 30.0 points
main estimate, 95% width at 20 items: 27.8 points
reading: with 20 items and a change that disagrees with the baseline on 10.1% of items, as prompt-b did, the smallest difference detected with 80% power at 95% confidence is 19.9 points

ここではコードが、開発用の項目におけるプロンプト B とベースラインの食い違いを読み取る。その前提は出力されており、確認すべきはこの前提、つまり次の変更がベースラインと食い違う項目数はプロンプト B の場合とほぼ同じ、という仮定である。ここで食い違う項目の割合は 10.1% (8 of 79) である。

sample-size-limits.py Python 3.12.15 · numpy 2.5.5 · pydantic 2.14.3 · typing-extensions 4.16.0 合格
"""The arithmetic behind the five-point figure in sample-size, and the limits of its inputs: the interval on the share ofdiscordant items (a percentile bootstrap over items, as lib.stats computes every interval), the held-out level of 98.33%,and the difference that the 40 held-out items can detect. The disagreement is the dev items' paired run, as in sample-size."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom lib import variancefrom lib.calibration import readable_verdictsfrom lib.judging import passedfrom lib.prompts import REF_SHA256from lib.stats import bootstrap_mean, interval_pctfrom lib.testset import load_itemsBASELINE = "judge-answers-baseline"PROMPT_B = "judge-answers-prompt-b"ALPHA_HELD_OUT = 0.05 / 3  # two-sided alpha for each of the three held-out comparisons (Bonferroni)HELD_OUT_LEVEL = 1 - ALPHA_HELD_OUTitems = [item.id for item in load_items(split="dev")]  # eighty dev items, sorted by idp1_found, p1_unreadable = readable_verdicts(BASELINE, items, REF_SHA256)p2_found, p2_unreadable = readable_verdicts(PROMPT_B, items, REF_SHA256)kept = [item_id for item_id in items if item_id not in {i for i, _ in p1_unreadable + p2_unreadable}]first = passed({item_id: p1_found[item_id] for item_id in kept})second = passed({item_id: p2_found[item_id] for item_id in kept})discordant = (first != second).astype(float)  # 1 where the two prompts disagree on an item, else 0var_d = variance.paired_difference_variance(first, second)mean_d = float((second - first).mean())# The five-point figure, worked: n = (z_alpha + z_beta)^2 * var(d) / delta^2z2, delta2 = variance.z_sum() ** 2, 0.05 ** 2print(f"z sum squared, 95% confidence and 80% power: {z2:.2f}")print(f"var(d), variance of one item paired difference: {var_d:.4f}")print(f"delta squared, a five-point difference: {delta2:.4f}")print(f"n for five points: {z2:.2f} x {var_d:.4f} / {delta2:.4f} = {z2 * var_d / delta2:.1f}, "      f"rounded up to {variance.items_needed(var_d, 5.0)}")# The share rests on the discordant items alone, so its 95% interval is a range for the answer.share_lo, share_hi = bootstrap_mean(discordant)print(f"discordant share, 95% interval: {interval_pct(share_lo, share_hi)}")for end, share in (("low", share_lo), ("high", share_hi)):    # mean(d) stays at its observed value; only the share moves    print(f"items needed for 5 points, {end} end of the share: {variance.items_needed(share - mean_d ** 2, 5.0)}")print(f"items needed for 5 points at {100 * HELD_OUT_LEVEL:.2f}% confidence: "      f"{variance.items_needed_at(var_d, 5.0, ALPHA_HELD_OUT)}")# Only the count is read here: no held-out verdict is opened by this example.held_out_n = len(load_items(split="held-out"))print(f"held-out items (n): {held_out_n}")print(f"smallest difference {held_out_n} held-out items detect at {100 * HELD_OUT_LEVEL:.2f}% and 80% power: "      f"{variance.smallest_difference_at(var_d, held_out_n, ALPHA_HELD_OUT):.1f} points")
出力python sample-size-limits.py
z sum squared, 95% confidence and 80% power: 7.85
var(d), variance of one item paired difference: 0.1006
delta squared, a five-point difference: 0.0025
n for five points: 7.85 x 0.1006 / 0.0025 = 315.9, rounded up to 316
discordant share, 95% interval: [3.8%, 17.7%]
items needed for 5 points, low end of the share: 118
items needed for 5 points, high end of the share: 555
items needed for 5 points at 98.33% confidence: 422
held-out items (n): 40
smallest difference 40 held-out items detect at 98.33% and 80% power: 16.2 points

5ポイントの差についての計算過程は、この例の中で実行される。二つの z 値の和の2乗は 7.85 である。一つの項目の対応のある差の分散は 0.1006 である。5ポイントの差の2乗は 0.0025 である。したがって n は 7.85 x 0.1006 / 0.0025 = 315.9, rounded up to 316 となる。

Miller (2024) は、対応のある式をより一般的な形で示しており、各項目内のノイズに関する項を含む。ここでの式は、その形で項目ごとの応答を1回とした場合にあたり、項目内の項が落ちる。論文の入力を使った計算例は約969項目になる。ただしその入力は別の実験のものであるため、本書の数値は出力された実行結果だけから得ている。

検出力は逆向きにも働く。検出力80%では、実際の差に合わせた大きさの集合でも、約5回に1回はその差を見逃す。これは問題数の予算が固定されていることの代償である。この代償を払えないチームは、目標とする差をより大きくするか、実行前に集合を拡大するべきである。

平均差が小さいとき、必要な項目数はこの割合に比例する。そのため、2倍の項目で食い違う変更には、約2倍の問題数が必要になる。チームは開発用の対応のある実行からこの割合を推定し、明示し、測定に使った変更より大きな変更を扱うときには再び確認するべきである。

主たる推定によれば、5ポイントの差には 316 項目、10ポイントの差には 79 項目が必要である。下限値は各項目内の標本ノイズだけを用いており、32 と 8 になる。下限値は必要数の下限として読むべきであり、計画として読んではならない。下限値は、現実に存在する変種間の食い違いを含まない。二つのプロンプトは、アシスタントの応答の安定性だけでなく、応答の内容も変えるからである。下限値が成り立つのは、温度0.7で項目ごとに応答を1回標本抽出し、変種が P1 と同程度に安定している比較に限られる。そのノイズに寄与する項目は2項目だけであり、下限値は非常に少ない項目に基づいている。下限値に基づく計画は、標本抽出だけでは説明できないほど変更が食い違うたびに、不足する。

同じ推定は、第1章の集合についての問いにも答える。20項目の場合、上で仮定した食い違いのもとで、検出力80%、信頼水準95%の検定が検出できる最小の差は 19.9 points である。

第1章の集合では、項目の 10.0% (2 of 20) で食い違いがあった。

その区間の幅は 30.0 points であった。同じ食い違いのもとで、式は 27.8 points を与え、両者は近い。その集合は20項目の例で確認できる。この食い違いのもとでは、20項目では10ポイントの差も見逃すことが多く、5ポイントの差を見たいチームには、数十ではなく数百の項目が必要である。

この推定は食い違う項目だけに基づくため、件数ではなくオーダーの目安である。この割合の95%区間は [3.8%, 17.7%] である。この区間の全域で見ると、5ポイントの差に必要な項目数は、下端で 118、上端で 555 である。この式は正規近似であり、読み取りの規則はブートストラップを用いるため、食い違う項目が少ないときには両者は大まかにしか一致しない。ホールドアウトの水準98.33%では、同じ入力で5ポイントの差に 422 項目が必要になる。

実運用での誤りは、集合の大きさを勘で選び、その結果を判断として読むことである。5ポイントの向上を求めて数十項目で実行したチームは、たいてい差が検出されない結果を得る。そしてそれを、変更が効かないという判定だと取り違えかねない。実行前に、食い違いの仮定とともに大きさを書き留め、結果をそれに照らして報告する。示された n のもとで差が検出されなかったことは、その集合についての知見である。変更が失敗したことを意味しない。

実践ルール: 比較の前に、開発用データで対応のある比較を行い、二つの変種が食い違う頻度を推定し、その割合を仮定として明示する。重視する差について、比較を読み取る水準で必要な項目数を計算し、その割合の区間から範囲を示す。集合がそれより小さい場合は、その大きさの差を検出できないと報告し、差が検出されなかったという結果を変更に不利な裁定として読んではならない。下限値は下限としてのみ用い、応答を標本抽出する比較にだけ用いる。

この版における本章

第2026.11.3版2026年11月21日時点で例が通過この章の5 例件のうち5件が合格

英語版の書籍(版2026.11.3)から翻訳した。

この節を引用する

形式

いずれの形式も、本訳書が従う英語版の書籍を出典として示す。

いずれの形式もこの版を明示している。そのリンクは現行版を開き、節の見出しには本文が最後に変更された日付が示される。アクセス日と取得日は、これを開いた日である。

このページの内容

全11章中の第8章: 変更が改善になっているかを判断し、必要な質問数を見積もる

  1. 1つの項目内のばらつき
  2. 項目に対するブートストラップ
  3. 対応のある比較
  4. ホールドアウトは一度だけ
  5. 多重比較
  6. 差の検出に必要な問題数

ページの先頭に戻るすべての章