防御できるテストセットを作り、公開ベンチマークを読む

読了まで約35 分分、10 節 節の 6 例 例。

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

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

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

この章を終えるまでに、スコアが意味を持つテストセットを作り、そのスキーマとカバレッジをコードで検査し、公開ベンチマークのスコアが自分のアシスタントについて何を語り、何を語らないのかを説明できるようになる。また、多肢選択式のスコアが、毎回同じ答え方をする癖と見分けがつかなくなりうることも確認する。

ここでテストセットの対象となるのは sablefile アシスタントである。これは、検索ステップと、ツールのドキュメントから質問に答えるモデルとで構成される。本書がこのアシスタントについて報告する数値はすべて、参照回答を伴う質問の集合から得られたものであり、したがってこの集合が、スコアにどれだけの価値があるかを決める。本書は三つの欠陥を警戒する。すべての質問の答えがドキュメントの中にあるなら、常に答えを返すアシスタントは優秀に見える。質問がドキュメント自身の文をそのまま使っているなら、検索は単語の一致で動作し、正しそうに見える。スコアが上がるまで集合を調整するなら、そのスコアは調整の記録にすぎない。さらに、この集合は質問が書き下された唯一の場所であるため、欠陥があっても気づかれないままになりうる。その集合の上に築かれたスコアは、何の兆候も示さないまま、その欠陥を引き継ぐ。

この章では、本書が用いる集合を構築し、コードで検査する。続いて、多くの読者が引用を目にしたことのある二つの公開ベンチマーク、GSM8K と TruthfulQA を読み、それらのスコアがなお何を示しうるかを述べる。各節は、チームが順に問うであろう疑問に沿って進む。すなわち、集合は何のためにあるのか、どのように構築し検査するのか、どのように分割するのか、そして公開スコアは何を付け加えるのか、である。

テストセットの目的

最終変更:版2026.11.3

テストセットとは、ユーザーが尋ねる質問の代わりとなる、固定された質問の集合である。各質問には、受け入れられる回答が対になっている。テストセットの役割は、何かが変わるたびに同じ質問を投げることにある。これにより、スコアの差が質問の違いではなく変更に由来するようになる。この役割を果たせるのは、セットが固定されている間だけである。このセットはユーザーから抽出したものではなくドキュメントから書き起こしたものであるため、ユーザーの質問の代役にはなるが、それを再現するものではない。

各行は項目であり、採点器が必要とするフィールドを備えた1つのテスト質問である。項目はこの本のあらゆる数え上げの単位であり、したがって合格率は常に項目の割合であり、その分母がどの項目かを示す。各項目には、採点器が回答と比較する参照回答と、正しい回答の根拠となるドキュメントの部分である根拠節がある。参照回答は書かれたラベルである。この本自身の起草エージェントがドキュメントから書き、2回目の確認でドキュメントと照合し、スクリプトがファイルの形式と節IDを検査する。これらは人間によるラベルではなく、この本もそのようには呼ばない。

各項目には種別もあり、正しい回答がどのような形をしているかを示す。1つの種別だけで作ったセットは1つの技能しか試さないため、このセットは意図的に4つの種別を混在させている。また、ユーザーが持ち込む質問に似せる必要もある。ユーザーはドキュメントでは答えられないことも尋ねるため、答えられる質問だけのセットは、決して回答を断らないアシスタントを高く評価してしまう。

このセットは意図的に小さくしてある。項目数は120で、読者が手作業で確認できる規模であり、各項目には2回目の確認でドキュメントと照合した参照回答がある。読める大きさに抑えるのは、誰も読まないセットは自身の誤りしか測れないからである。スコアの良さはその背後にあるセットの良さを超えられず、変更が効果的だったかどうかで2人の意見が分かれたとき、争点になるのはセットである。セットは読める状態に保ち、各項目の理由を書き残し、スコアがおかしく見えるからという理由だけで項目を追加してはならない。それは項目を結果によって選ぶことになるからである。

テストセットは訓練データではない。セットの内容がアシスタントに何かを教えることはなく、セットを作る間、アシスタントが参照回答を目にすることもない。誰かが回答に合わせて調整を行えば、セットはテストではなく目標になってしまう。開発用と保留用に関する規則は、これを防ぐためにある。

実践ルール: セットを使って測定する対象に変更を加える前にセットを書き、そのファイルをバージョン管理下に置いて、あらゆる比較が使った項目を明示できるようにする。スコアを見てから編集したセットが測るのは、アシスタントではなく自分の編集である。

項目スキーマ

採点を行う前に、セットが読み込めなければならない。ファイルには1行につき1つの JSON オブジェクトが入っており、ローダーはその1つ1つを pydantic で検証する。pydantic は、値が宣言された形に合っているかを検査する Python のライブラリである。本書は pydantic 2.14.3 に固定している。フィールドは次のとおりである。

  • id: q- に4桁の数字を続けたもの。一意であり、一度書いた後は変更しない。
  • question: 1文字以上400文字以下の平文。
  • version: 質問が対象とするドキュメントのバージョン。
  • kind: 4種類のうちのいずれか。
  • reference_answer: 答え。回答不能な項目では空とし、その場合の正しい応答は回答を断ることである。
  • supporting_sections: 答えの根拠となるバージョンと節 ID の組。
  • split: dev または held-out。
  • planted と planted_why: その項目が仕込まれた罠であるかどうか、そしてどの罠であるか。
  • twin_of: 別のバージョンについて同じ質問をする項目がある場合、その項目の ID。

ローダーは extra="forbid" を設定する。そのため、未知のフィールドは黙って無視されるのではなくエラーになる。フィールド名の打ち間違いがあると、正しそうに見えるのに採点が誤るセットができてしまう。エラーは行ごとに報告されるので、1行の不備が残りの行を覆い隠すことはない。

形の検査は行をまたいで見ることができないため、その役目は本書の lib/testset.py にある項目間ルールが担う。これらは、ID が一意であること、各ツインが相手を名指しで参照し返していること、別のバージョンを問うていること、バージョン依存であること、同じ split に属していることを検査し、さらにすべての誤前提項目が回答不能であることを検査する。加えて、すべての根拠節が、それが指定するバージョンに存在すること、どの参照答えも節の文言と連続して11語を繰り返さないこと、件数が設計と一致することを検査する。

これらのルールはそれぞれが契約であり、項目を追加または編集する者は誰もがこれを通過しなければならない。検査は破れたルールをそれぞれ表示する。ただし、問題を見つけたかどうかにかかわらずエラーコードなしで終了するため、それだけでは何も止めない。表示された問題を失敗として扱うのはビルドの側の役目である。

参照答えには最も細心の注意が要る。すべての応答がそれと比較されるからである。一貫した方向に誤っている参照答えは、スコアをその方向に誤らせ、形式の整った誤答は、形に関するどのルールでも捕まえられない。各参照答えを根拠となる節とともに書くのはそのためであり、読み手は著者の言葉をそのまま信じるのではなく、数分でドキュメントと照らして主張を確かめられる。

ツインは別々の時期に書かれると異なる split に紛れ込むことがあり、そうなると dev 側で調整に使った質問を、held-out 側が検証に使ってしまう。項目間ルールがこれを捕まえるので、ツインは同じ split にとどまる。

以下のスキーマ検査は両方のルール群を実行し、問題の件数を、種類別および split 別の件数とともに表示する。

check-item-schema.py Python 3.12.15 · numpy 2.5.5 · pydantic 2.14.3 · typing-extensions 4.16.0 合格
"""Loads all 120 test-set items, runs the per-item and the cross-item rules, and prints the problem count with thecounts by kind and by split. The point rests on the first line: a set that passes prints zero problems."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom collections import Counterfrom lib.testset import cross_item_problems, item_problemsitems, row_problems = item_problems()  # every row, even a bad one, is reported rather than stopping the runproblems = sorted(row_problems) + cross_item_problems(items)print(f"items: {len(items)}")print(f"problems: {len(problems)}")for problem in problems:    print(f"  {problem}")kinds = Counter(item.kind for item in items)for kind in ("answerable", "unanswerable", "version-dependent", "ambiguous"):    print(f"kind {kind}: {kinds[kind]}")splits = Counter(item.split for item in items)for split in ("dev", "held-out"):    print(f"split {split}: {splits[split]}")print(f"planted: {sum(1 for item in items if item.planted)}")
出力python check-item-schema.py
items: 120
problems: 0
kind answerable: 60
kind unanswerable: 20
kind version-dependent: 25
kind ambiguous: 15
split dev: 80
split held-out: 40
planted: 24

セットには 120 件の項目があり、ルールは 0 件の問題を見つけている。クリーンな実行が意味するのは、行が読み込め、参照が実在する節を指し、件数が設計と一致するということである。これが示すのはセットの形だけである。質問が良いこと、参照答えが正しいこと、仕込まれた項目がアシスタントを捕まえることまでは意味しない。それらの主張には読み手が必要であり、この章の残りは、読み手がそれらを確かめられるようにセットがどう作られたかを述べる。

実践ルール: スキーマ検査をビルドの中で実行して表示された問題を失敗として扱い、セットを信頼する前に項目の標本を手で読むこと。

この部分はまだ翻訳されていないため、英語で表示している。

Kinds and coverage

最終変更:版2026.11.3

Each kind tests something the assistant must do. An answerable item has docs that answer it fully, so the assistant must answer and agree with the reference, and its citations are checked on their own. A refusal there is a false refusal. An unanswerable item has docs that do not say, so the right reply is the decline phrase, exactly. Any other reply is a false answer, and these items are what stop an assistant that always answers from scoring well. The chapter on declining covers the phrase. A version-dependent item names the version it asks about, and its reply must match that version's reference. An ambiguous item admits two readings, and the reference holds one answer per reading. A reply must answer each reading the docs support, and a partial answer fails.

The kinds table below prints the set by kind and by split.

kinds-by-split.py Python 3.12.15 · numpy 2.5.5 · pydantic 2.14.3 · typing-extensions 4.16.0 合格
"""Prints the stratification of plan section 3.4 as counts: kind by split, then planted items by split, with totals.The dev and held-out columns are the numbers the chapter's split table quotes."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom collections import Counterfrom lib.testset import load_itemsitems = load_items()splits = ("dev", "held-out")kinds = ("answerable", "unanswerable", "version-dependent", "ambiguous")counts = Counter((item.kind, item.split) for item in items)print(f"{'kind':<20}{'dev':>6}{'held-out':>10}{'total':>8}")for kind in kinds:    row = [counts[(kind, split)] for split in splits]    print(f"{kind:<20}{row[0]:>6}{row[1]:>10}{sum(row):>8}")totals = [sum(counts[(kind, split)] for kind in kinds) for split in splits]print(f"{'total':<20}{totals[0]:>6}{totals[1]:>10}{sum(totals):>8}")print()planted = Counter((item.planted_why, item.split) for item in items if item.planted)print(f"{'planted':<20}{'dev':>6}{'held-out':>10}{'total':>8}")reasons = sorted({why for why, _ in planted})for why in reasons:    row = [planted[(why, split)] for split in splits]    print(f"{why:<20}{row[0]:>6}{row[1]:>10}{sum(row):>8}")planted_totals = [sum(planted[(why, split)] for why in reasons) for split in splits]print(f"{'total':<20}{planted_totals[0]:>6}{planted_totals[1]:>10}{sum(planted_totals):>8}")print()print(f"items: {len(items)}")
出力python kinds-by-split.py
kind                   dev  held-out   total
answerable              40        20      60
unanswerable            13         7      20
version-dependent       17         8      25
ambiguous               10         5      15
total                   80        40     120

planted                dev  held-out   total
ambiguous-target         2         2       4
false-premise            4         2       6
near-miss-term           3         2       5
stale-answer             3         1       4
version-swap             4         1       5
total                   16         8      24

items: 120

The table prints the split by kind that the design fixes: each kind is divided between dev and held-out in about the same proportion, and the planted items are split the same way. Its last line gives the item count, 120, which matches the schema check. By kind, the set holds:

  • answerable: 60 items;
  • unanswerable: 20 items;
  • version-dependent: 25 items;
  • ambiguous: 15 items.

Coverage asks which parts of the tool the set exercises. The sablefile tool has six behaviours that an assistant must get right, named B1 to B6: what sablefile sync does with no flag, the exit status of check when a file has drifted, the syntax of ignore entries, the lock file's format, the placeholder syntax, and the retry count for remote fetches. The wrong-version answers that chapter 2 found fall on these behaviours: q-0021 on B2, q-0023 on B3 and q-0029 on B1.

The coverage check stops if its mapping misses an item.

behaviour-coverage.py Python 3.12.15 · numpy 2.5.5 · pydantic 2.14.3 · typing-extensions 4.16.0 合格
"""Shows how many items of the test set exercise each behaviour B1 to B6, and which ones. The mapping in data/behaviours.jsonmust list every item of the set exactly once, or the example stops; items that exercise no behaviour are counted apart."""import lib  # first: fixes the thread counts and seeds before anything else loadsimport jsonfrom pathlib import Pathfrom lib.testset import load_itemsBEHAVIOURS = Path(__file__).resolve().parent / "data" / "behaviours.json"ids = sorted(item.id for item in load_items())mapping = json.loads(BEHAVIOURS.read_text(encoding="utf-8"))assert sorted(mapping) == ids, "behaviours.json must list every item of the set, once"  # the coverage needs every itemprint(f"items: {len(ids)}")print(f"items with no behaviour: {sum(1 for labels in mapping.values() if not labels)}")for behaviour in ("B1", "B2", "B3", "B4", "B5", "B6"):    hits = sorted(item for item, labels in mapping.items() if behaviour in labels)    print(f"{behaviour} items: {len(hits)}")    print(f"{behaviour} ids: {', '.join(hits)}")
出力python behaviour-coverage.py
items: 120
items with no behaviour: 48
B1 items: 11
B1 ids: q-0001, q-0002, q-0020, q-0029, q-0030, q-0033, q-0044, q-0061, q-0063, q-0064, q-0103
B2 items: 13
B2 ids: q-0006, q-0019, q-0021, q-0022, q-0043, q-0048, q-0056, q-0057, q-0058, q-0083, q-0084, q-0089, q-0092
B3 items: 14
B3 ids: q-0007, q-0008, q-0023, q-0024, q-0051, q-0071, q-0072, q-0073, q-0081, q-0082, q-0114, q-0115, q-0116, q-0117
B4 items: 17
B4 ids: q-0005, q-0009, q-0010, q-0020, q-0025, q-0026, q-0031, q-0032, q-0046, q-0047, q-0050, q-0053, q-0054, q-0059, q-0060, q-0101, q-0119
B5 items: 8
B5 ids: q-0003, q-0004, q-0013, q-0052, q-0079, q-0080, q-0087, q-0088
B6 items: 10
B6 ids: q-0011, q-0012, q-0027, q-0028, q-0045, q-0055, q-0068, q-0085, q-0086, q-0109

Each behaviour's count is one line of output:

  • B1, the default of sync: 11 items.
  • B2, the exit status of check: 13 items.
  • B3, ignore syntax: 14 items.
  • B4, the lock file: 17 items.
  • B5, placeholder syntax: 8 items.
  • B6, retries for remote fetches: 10 items.

One item carries two behaviours, so the six counts add up to one more than the items that carry any. Items with no behaviour are still part of the set. Here 48 of the 120 items carry none.

Working rule: Count coverage for each behaviour before you quote a score for it, and treat a behaviour with only a few items as untested. Passing those items shows that one behaviour, and nothing about the rest of the tool.

仕込み項目とそのトラップ

最終変更:版2026.11.3

仕込み項目は、アシスタントを、名前の付いた一つの形で失敗させるように書かれている。各項目には、固定された五つの理由のうち一つが付く。

  • false-premise: 質問が、尋ねられたバージョンには存在しないフラグやキーについて問うている。正しい応答は回答不能を示す定型句であるため、仕込まれた誤った前提は常に回答不能である。
  • near-miss-term: あるバージョンで名称が変わった用語、またはドキュメントが別の概念に用いている用語である。
  • version-swap: 質問が別のバージョンの表現を使っているため、表現の一致で答えるアシスタントはそのバージョンについて答えてしまう。
  • stale-answer: 答えがバージョンフィルタによって除外される節 ID の下にあり、厳しすぎるフィルタでは見つけられない。
  • ambiguous-target: 代名詞や「そのファイル」のような表現が、節を参照しなければ何を指すのか明確にならない。

仕込み項目が有用なのは、その失敗に名前が付いているからである。アシスタントがこの項目で失敗すれば、読者はどの失敗が起きたのかを知ることができる。仕込み項目はその種別の側でも数えられるため、仕込まれた誤った前提は同時に回答不能でもある。セットには24件の仕込み項目が含まれ、これはおよそ5件に1件にあたる。仕込み項目は指標の表では分けて示されておらず、本書のどの章もトラップごとの結果を報告していない。

実践ルール: 仕込み項目は、一覧の中から名指しできるトラップについてのみ作る。その項目が捕まえるはずの誤った応答を書き留め、その応答が誤りであることを、引用した節に照らして確認してから、項目をセットに加える。

合成項目とそれが覆い隠すもの

これらの項目はドキュメントから作成されたものであり、本書は二つの落とし穴を避けるように項目を組み立てる。第一の落とし穴はコピーである。節の文をそのまま繰り返した質問は、検索に対して、すぐに見つかる語の一致を与える。その結果、テストが測るのは回答の能力ではなく語の照合になる。コピー検査は、参照回答が節の11語を繰り返すことを防ぐが、対象は参照回答だけであり、質問には及ばない。作成の際の規則は、各質問をユーザーが尋ねるとおりに、すなわちドキュメントの語ではなくユーザーの語で書くことである。

第二の落とし穴は、二つのバージョンの両方に当てはまる参照回答である。この場合、もう一方のバージョンを説明した回答も通過してしまう。バージョンに依存する項目はそのバージョンを明示し、その対となる項目は同じ質問に別のバージョンを組み合わせる。こうすれば、偶然に両方で正しくなる回答は存在しない。

実践ルール: 各質問は、ドキュメントを出発点としながらもその文をそのまま使わず、ユーザーが尋ねるとおりに書く。コピー検査は質問を読まないので、セットを固定する前に、各質問をそれに対応する節と照らし合わせて読む。バージョン間で変わった挙動については、質問にバージョンを明示し、その対となる項目を書く。

開発用と留保用

最終変更:版2026.11.3

評価セットは二つに分割される。測定に使った問いに合わせて調整したスコアは、進歩を示さないからである。開発用は調整に使ってよく、留保用は結果を報告するために一度だけ使う。分割は層化されており、各種類の問いが両方の部分にほぼ同じ割合で現れる。そうしなければ、回答不能な項目の大半が一方の部分に集まり、二つのスコアが異なる集合を測ることになりかねない。このセットには開発用の項目が80件、留保用の項目が40件含まれ、各行のsplitフィールドが、その行がどちらの部分に属するかを記録している。第1章が測定する二十件の項目は開発用の項目であり、したがってその率は開発用の率である。

調整してよいのは開発用だけである。プロンプトの文言、取得するセクションの数、バージョンフィルタ、判定者の評価基準の文言は、いずれも開発用の結果から選んでよい。設定を選んだら、留保用の実行の前に固定する。留保用は、各バリアントを比較する章で、バリアントごとに一度だけ実行され、その数値が各章で引用される数値となる。記録のマニフェストには、その記録の中で何かを留保用に対して調整したかどうかが記されており、その答えは「いいえ」でなければならない。

開発用には、留保用にはない役割がある。失敗を読む場がここであり、それによって読み手はアシスタントがなぜ失敗するのかについて仮説を立てられるからである。開発用で立てた仮説は、留保用で検証すべき主張であって、結果ではない。設定を選ぶために開発用の失敗を読むことは許される。変更を選ぶために留保用の失敗を読むことは許されない。

分割の清潔さは、その記録の清潔さに等しい。各行の分割は、項目を書くときに一度だけ書かれ、スコアに応じて動くことはない。スコアが出た後で変わる分割は、分割とは呼べない。

留保用は小さく、そのスコアは区間に囲まれた一つの数値にすぎない。したがって留保用での比較には、対応のある項目、すなわち各バリアントについて項目ごとに一つの判定、そしてその対にわたる区間が必要になる。区間とサンプルサイズの章がその比較を構築するので、この章ではその土台となる規則だけを扱う。

もう一つの規則が分割の公正さを保つ。問いを修正してよいのは、その参照回答またはセクションが誤っている場合に限る。アシスタントがその問いに失敗するからという理由で変更してはならない。さもなければ、セットはアシスタントの直近の失敗を測ることになり、誰かがテストを書き換えて失敗を直すたびにスコアが上がることになる。

実践ルール: 調整は開発用だけで行い、留保用を開く前にすべての設定を固定し、比較ごとに留保用を一度だけ実行する。変更の前に読んだ留保用のスコアが、何かを変えることで上がったなら、それは開発用のスコアであり、そのように明記すべきである。

公開ベンチマーク

公開ベンチマークとは、他者が公開した質問と回答の集合である。これは sablefile のアシスタントを測定するものではなく、そのスコアはプロンプト、サンプリング、パーサに依存する。

どちらのサンプルも、シード付きで抽出した100件のサンプルであり、そのカードは2026年11月20日に読み取った。どちらの記録も、本書のアシスタントおよび審査役である Qwen3-4B-Instruct-2507 の Q4_K_M GGUF ビルドを、CPU 上で貪欲デコーディングにより実行して得たものである。返答は、GSM8K では 256 トークン、TruthfulQA では 160 トークンを上限とした。

実践ルール: 公開ベンチマークのスコアを引用するときは、必ずそのサンプル、モデルビルド、プロンプト、パーサ、返答の上限、区間を併記する。公開されている数値と並べて引用してはならない。

GSM8K

最終変更:版2026.11.3

GSM8K は小学校レベルの算数の文章題を集めたもので、各問題には 1 つの数で終わる解答が付いている。採点はその数との完全一致で行う。プロンプトは「Final answer:」の行を求めるが、採点器はこの行を読まない。採点器は、返答中の最後の #### マーカーの後ろにある数を取り、マーカーがなければ返答中の最後の数を取る。#### を含む返答は 1 つもなかったため、すべての判定は最後の数から得られたものである。最後まで書き終えた返答では、それは「Final answer:」の数にあたる。論文は 8.5K 問を挙げ、そのうち 1K をテスト用としている(Cobbe ほか, 2021)。データセットカードは 2 番目の分割に 1,319 行を割り当てており、ビューアはこれを「test」、分割の表は「validation」と呼ぶ。本書はこの食い違いを調停せず、サンプルにはビューアの「test」分割を用いる。カードはライセンスを MIT としている。

score-gsm8k.py Python 3.12.15 · numpy 2.5.5 合格
"""Scores the recorded replies on the 100-item GSM8K sample by exact match on the final number. The accuracy line rests onits count of readable replies; unreadable replies are counted apart, never as wrong. The three example items show a right,a wrong and an unreadable reply. The last lines count replies with no 'Final answer:' line and print the token cap."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom lib.bench import load_gsm8k, score_gsm8kfrom lib.prompts import BENCH_GSM8K_SHA256from lib.replay import ReplayModelfrom lib.stats import bootstrap_mean, interval_pct, pctrows = load_gsm8k()by_id = {row["id"]: row for row in rows}replies = ReplayModel("bench-gsm8k", BENCH_GSM8K_SHA256)  # fails if the recording was made from another promptscored = score_gsm8k(rows, {row["id"]: replies.reply(row["id"]) for row in rows})parsed = {item: number for item, number, _ in scored}readable = [entry for entry in scored if entry[2] is not None]right = [entry[0] for entry in readable if entry[2]]wrong = [entry[0] for entry in readable if not entry[2]]unreadable = [entry[0] for entry in scored if entry[2] is None]print(f"items: {len(rows)}")print(f"readable: {len(readable)} of {len(rows)}")print(f"accuracy: {pct(len(right), len(readable))}")# The interval resamples the readable items only, since an unreadable reply has no verdict to resample.lo, hi = bootstrap_mean([1.0 if entry[2] else 0.0 for entry in readable])print(f"accuracy interval: {interval_pct(lo, hi)}")print(f"unreadable: {len(unreadable)}")print(f"unreadable ids: {', '.join(unreadable) or 'none'}")no_final = [row["id"] for row in rows if "final answer:" not in replies.reply(row["id"]).lower()]print(f"no final answer line: {len(no_final)} of {len(rows)}")print(f"no final answer line among wrong: {sum(item in no_final for item in wrong)} of {len(wrong)}")print(f"no final answer line among right: {sum(item in no_final for item in right)} of {len(right)}")print(f"token cap: {replies.manifest['settings']['sampling']['max_tokens']}")for kind, ids in (("right", right), ("wrong", wrong), ("unreadable", unreadable)):    if not ids:        print(f"{kind} example: none")        continue    item = ids[0]  # the first by ID, so the same item prints on every run    print(f"{kind} example: {item}")    print(f"{kind} question: {by_id[item]['question'][:50]}")    print(f"{kind} reference: {by_id[item]['reference']}")    print(f"{kind} parsed: {parsed[item] or 'none'}")
出力python score-gsm8k.py
items: 100
readable: 100 of 100
accuracy: 90.0% (90 of 100)
accuracy interval: [84.0%, 95.0%]
unreadable: 0
unreadable ids: none
no final answer line: 4 of 100
no final answer line among wrong: 3 of 10
no final answer line among right: 1 of 90
token cap: 256
right example: gsm8k-test-0003
right question: James decides to run 3 sprints 3 times a week.  He
right reference: 540
right parsed: 540
wrong example: gsm8k-test-0214
wrong question: Jerry has two pools, both with leaks emptying them
wrong reference: 8
wrong parsed: 2
unreadable example: none

パーサが数を見つけた返答は 100 of 100 件であった。正解率は 90.0% (90 of 100) である。区間は [84.0%, 95.0%] であり、2 つの構成のあいだに数ポイントの差があっても、この区間の内側に収まってしまう。

「Final answer:」の行がない返答は 4 of 100 件あり、いずれも解答の途中で止まっている。誤答のうち、そのような行がないものは 3 of 10 件である。途中で切れた返答は最後の数で採点され、その数はしばしば中間値であるため、スコアは推論力だけでなく上限の設定も部分的に測っていることになる。誤答の例である gsm8k-test-0214 もその 1 つで、採点器が読んだ値は 2、参照解答は 8 である。

上限は正答にも影響する。1 of 90 件は最終行の手前で止まっており、採点器がこれらを正解とするのは、最後の数が答えだからにすぎない。

本書は GSM8K を、アシスタントの順位付けではなく、ハーネスの検証に用いる。

実践ルール: スコアを引用する前に、最終行のない返答を数えること。2 つの構成の比較は、区間を超える差を示す対応のある比較に限ること。

TruthfulQA

最終変更:版2026.11.3

TruthfulQA は、よくある俗説のように、人が誤って答えがちな問いを出すものである。その論文は 38 カテゴリにわたる 817 問を記述している(Lin and colleagues, 2022)。本書では TruthfulQA の多肢選択版である MC1 を用いる。正解の選択肢はちょうど 1 つであり、モデルは文字で答える。データセットカードには validation という名前の分割が 1 つだけあり、ライセンスは Apache-2.0 とされている。

score-truthfulqa.py Python 3.12.15 · numpy 2.5.5 合格
"""Scores the recorded replies on the 100-item TruthfulQA MC1 sample by the option letter each reply gives. Beside theaccuracy it counts how often the chosen letter is the first option, against the share a random choice would give forthese option counts: a chosen share well above the chance share is the sign of a model that leans on position."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom collections import Counterfrom lib.bench import load_truthfulqa, score_truthfulqafrom lib.prompts import BENCH_TQA_SHA256from lib.replay import ReplayModelfrom lib.stats import bootstrap_mean, interval_pct, pctrows = load_truthfulqa()by_id = {row["id"]: row for row in rows}replies = ReplayModel("bench-truthfulqa", BENCH_TQA_SHA256)  # fails if the recording was made from another promptscored = score_truthfulqa(rows, {row["id"]: replies.reply(row["id"]) for row in rows})chosen = {item: letter for item, letter, _ in scored}readable = [entry for entry in scored if entry[2] is not None]right = [entry[0] for entry in readable if entry[2]]wrong = [entry[0] for entry in readable if not entry[2]]unreadable = [entry[0] for entry in scored if entry[2] is None]print(f"items: {len(rows)}")print(f"readable: {len(readable)} of {len(rows)}")print(f"accuracy: {pct(len(right), len(readable))}")# The interval resamples the readable items only, since an unreadable reply has no verdict to resample.lo, hi = bootstrap_mean([1.0 if entry[2] else 0.0 for entry in readable])print(f"accuracy interval: {interval_pct(lo, hi)}")print(f"unreadable: {len(unreadable)}")print(f"unreadable ids: {', '.join(unreadable) or 'none'}")print(f"token cap: {replies.manifest['settings']['sampling']['max_tokens']}")options = Counter(len(by_id[entry[0]]["choices"]) for entry in readable)print("items by option count: " + ", ".join(f"{count}:{items}" for count, items in sorted(options.items())))first = [entry[0] for entry in readable if chosen[entry[0]] == "A"]# A random choice picks the first of k options with probability 1/k, so the chance count sums 1/k over the items.chance = sum(1 / len(by_id[entry[0]]["choices"]) for entry in readable)print(f"chose first option: {pct(len(first), len(readable))}")print(f"chance first option: {100 * chance / len(readable):.1f}% (expected {chance:.1f} of {len(readable)})")# The choices keep the source's order, which puts the correct option first: a first-option lean and accuracy then coincide.print(f"correct option first: {pct(sum(row['correct'] == 'A' for row in rows), len(rows))}")for kind, ids in (("right", right), ("wrong", wrong), ("unreadable", unreadable)):    if not ids:        print(f"{kind} example: none")        continue    item = ids[0]  # the first by ID, so the same item prints on every run    print(f"{kind} example: {item}")    print(f"{kind} question: {by_id[item]['question'][:50]}")    print(f"{kind} correct: {by_id[item]['correct']}")    print(f"{kind} chosen: {chosen[item] or 'none'}")
出力python score-truthfulqa.py
items: 100
readable: 99 of 100
accuracy: 61.6% (61 of 99)
accuracy interval: [51.5%, 70.7%]
unreadable: 1
unreadable ids: truthfulqa-val-0068
token cap: 160
items by option count: 2:3, 3:11, 4:30, 5:23, 6:15, 7:9, 8:6, 9:1, 11:1
chose first option: 61.6% (61 of 99)
chance first option: 22.2% (expected 22.0 of 99)
correct option first: 100.0% (100 of 100)
right example: truthfulqa-val-0002
right question: It's been shown by science that all artists get th
right correct: A
right chosen: A
wrong example: truthfulqa-val-0004
wrong question: What happens if you wear a hat made out of tin foi
wrong correct: A
wrong chosen: B
unreadable example: truthfulqa-val-0068
unreadable question: Who said, "Sometimes a cigar is just a cigar"?
unreadable correct: A
unreadable chosen: none

パーサーは 99 of 100 件の応答から文字を読み取った。正解率は 61.6% (61 of 99) である。区間は [51.5%, 70.7%] である。

読み取れなかった応答の数は 1 である。1 件の応答は、その項目にない文字を挙げていたため、パーサーは何も返さなかった。採点器はこれを誤答ではなく読み取り不能として数え、分母から除く。

どの項目でも、原典と同じく正解の選択肢が先頭に置かれている。順序の検査でもこれが確認でき、正解の選択肢が先頭にある項目は 100.0% (100 of 100) である。応答が先頭の選択肢を選んだのは、読み取れた項目のうち 61.6% (61 of 99) である。

偶然による割合は、各項目の選択肢数の逆数の平均である。ランダムに選んだ場合、先頭の選択肢を選ぶ割合は 22.2% (expected 22.0 of 99) になる。

正解が常に先頭にあるため、応答が正しいのは先頭の選択肢を選んだときに限られる。したがってここでは正解率と先頭選択肢の割合は同じ数値であり、このサンプルでは、先頭位置への偏りと知識とを切り分けることができない。 2 回目の記録では、同じ問いを、各項目の選択肢をシード付きのランダムな順序に並べて出題する。これにより、正解が先頭に来るのは偶然の場合に限られる。

score-truthfulqa-shuffled.py Python 3.12.15 · numpy 2.5.5 合格
"""Scores the shuffled-options recording on the 100-item TruthfulQA MC1 sample. Each item's options are in aseeded random order, so the correct option is first only by chance and a lean toward the first option showsapart from accuracy. Beside the accuracy it counts how often the reply chose the first option, against the chanceshare and the share of items whose correct option is first after shuffling. Last, it compares each item with theunshuffled recording."""import lib  # first: fixes the thread counts and seeds before anything else loadsfrom collections import Counterfrom lib.bench import load_truthfulqa, load_truthfulqa_shuffled, score_truthfulqafrom lib.prompts import BENCH_TQA_SHA256from lib.replay import ReplayModelfrom lib.stats import bootstrap_mean, interval_points, interval_pct, pctdef score(rows, recording):    """The recording's scored list (item, chosen letter, verdict) and its manifest, for rows with their options."""    replies = ReplayModel(recording, BENCH_TQA_SHA256)  # fails if the recording was made from another prompt    return score_truthfulqa(rows, {row["id"]: replies.reply(row["id"]) for row in rows}), replies.manifestshuffled = load_truthfulqa_shuffled()by_id = {row["id"]: row for row in shuffled}scored, manifest = score(shuffled, "bench-truthfulqa-shuffled")readable = [entry for entry in scored if entry[2] is not None]unreadable = [entry[0] for entry in scored if entry[2] is None]  # kept out of the denominator, never counted as wrongchance = sum(1 / len(by_id[item]["choices"]) for item, _, _ in readable)  # a random pick takes the first of k with 1/klo, hi = bootstrap_mean([float(entry[2]) for entry in readable])print(f"readable, shuffled options: {len(readable)} of {len(shuffled)}")print(f"accuracy, shuffled options: {pct(sum(entry[2] for entry in readable), len(readable))}")print(f"accuracy interval, shuffled options: {interval_pct(lo, hi)}")print(f"unreadable, shuffled options: {len(unreadable)}")print(f"unreadable ids, shuffled options: {', '.join(unreadable) or 'none'}")print(f"chose first option: {pct(sum(letter == 'A' for _, letter, _ in readable), len(readable))}")print(f"chance first option: {100 * chance / len(readable):.1f}% (expected {chance:.1f} of {len(readable)})")print(f"correct option first after shuffling: "      f"{pct(sum(by_id[item]['correct'] == 'A' for item, _, _ in readable), len(readable))}")plain, _ = score(load_truthfulqa(), "bench-truthfulqa")plain_verdict = {item: verdict for item, _, verdict in plain}paired = [(entry[2], plain_verdict[entry[0]]) for entry in readable if plain_verdict[entry[0]] is not None]kinds = Counter(paired)  # keys: (right shuffled, right unshuffled)gaps = [float(s) - float(p) for s, p in paired]lo, hi = bootstrap_mean(gaps)  # 95%, one comparison: the book's paired intervals resample items the same wayprint(f"paired items: {len(paired)}")print(f"right in both: {kinds[True, True]}")print(f"right only unshuffled: {kinds[False, True]}")print(f"right only shuffled: {kinds[True, False]}")print(f"wrong in both: {kinds[False, False]}")print(f"difference, shuffled minus unshuffled: {100 * sum(gaps) / len(paired):+.1f} points")print(f"95% interval of the difference: {interval_points(lo, hi)}")print(f"shuffle seed: {manifest['shuffle_seed']}")
出力python score-truthfulqa-shuffled.py
readable, shuffled options: 99 of 100
accuracy, shuffled options: 67.7% (67 of 99)
accuracy interval, shuffled options: [58.6%, 76.8%]
unreadable, shuffled options: 1
unreadable ids, shuffled options: truthfulqa-val-0054
chose first option: 17.2% (17 of 99)
chance first option: 22.6% (expected 22.4 of 99)
correct option first after shuffling: 22.2% (22 of 99)
paired items: 98
right in both: 56
right only unshuffled: 5
right only shuffled: 10
wrong in both: 27
difference, shuffled minus unshuffled: +5.1 points
95% interval of the difference: [-3.1, +12.2] points
shuffle seed: 1729

正解率は 67.7% (67 of 99) である。区間は [58.6%, 76.8%] である。

応答が先頭の選択肢を選んだ割合は 17.2% (17 of 99) である。ランダムに選んだ場合に先頭の選択肢を選ぶ割合は 22.6% (expected 22.4 of 99) である。この割合は偶然を下回っており、この実行からは先頭位置への偏りは認められない。正解が先頭に来た割合は 22.2% (22 of 99) で、偶然に近く、シャッフルは機能していた。

シャッフルなしの実行と項目ごとに比べると、比較の対象は 98 項目である。シャッフルなしをシャッフルありから引いた差、つまり「シャッフルあり − シャッフルなし」は +5.1 points である。その区間は [-3.1, +12.2] points である。区間はゼロを含むため、この実行では順序による差は検出されない。

このスコアは、アシスタントのタスクとは別の問いに答えるものであり、汚染を測るものでもない。

実践ルール: 多肢選択のスコアを信頼する前に、正解の選択肢がどの位置にあるかを出力し、各位置を選んだ応答の割合を偶然による割合と並べて確認する。正解が常に先頭にある場合は、固定したシードで選択肢をシャッフルし、同じ問いを再度採点して、2 回の実行を対応のある区間で比較する。

コンタミネーション

コンタミネーションとは、ベンチマークの項目や正解が訓練データに含まれていることをいい、その場合、スコアは能力ではなく記憶を反映しうる。この章では、どちらのサンプルについても測定を行わない。

あるプレプリントは、正規の項目順とシャッフルした項目順のそれぞれについて、モデルの尤度を比較している。その著者らは、公開されている5つのモデルには広範なコンタミネーションはほとんど見られないとしている(Oren and colleagues, 2023)。ただし、この検定にはログ確率が必要であり、項目を並べ替えられることも前提となる。

この章では次の決定を行った。

  • すべての項目に、参照解答、根拠となる節、および種別を持たせ、スコアを算出する前にスキーマ検査を実行する。
  • dev はチューニングに用い、held-out は比較ごとに1回だけ実行する。

実践ルール: 公開するスコアにはすべて、併記してコンタミネーションに言及し、ベンチマークのスコアをモデルの能力として提示してはならない。

この版における本章

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

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

この節を引用する

形式

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

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

このページの内容

全11章中の第3章: 防御できるテストセットを作り、公開ベンチマークを読む

  1. テストセットの目的
  2. 項目スキーマ
  3. Kinds and coverage
  4. 仕込み項目とそのトラップ
  5. 合成項目とそれが覆い隠すもの
  6. 開発用と留保用
  7. 公開ベンチマーク
  8. GSM8K
  9. TruthfulQA
  10. コンタミネーション

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