人間とLLMによる判定
読了まで約72 分分、13 節 節の 11 例 例。
このページの内容
この章を終えるまでに、判定ガイドラインを書き、カッパと重み付きカッパで2人の判定者の一致度を測り、混同行列からLLM判定者の誤りを読み取り、LLMの判定が人間の判定の代わりになる場面とならない場面を見極められるようになる。
この本のすべてのスコアは判定に基づいている。人間が、ストアの検索ボックスに入力されたクエリと、それに対して返された商品を並べて読み、そのペアに評価を付けた。これらの判定がWANDSのラベルであり、各ラベルは訓練を受けた最大3人のアノテーターの多数決で決まる。ラベルには抜けがある。テストクエリでは、BM25の上位10件に、誰も判定していない商品が22件含まれている(未判定の商品を数える)。判定には人の時間もかかり、WANDSのアノテーター間の一致度は4か月にわたる調整の間に上昇した(判定者の不一致を想定する)。LLMは、提示されたどのクエリと商品でも評価できる。ストアがLLMに判定を任せる前に、LLMがストアの判定者とどのくらいの頻度で一致するか、またLLMの評価からランカーについて同じ判断が導かれるかどうかを知る必要がある。
LLMの評価は記録から得る。recordings/llm_judgments.pyがオープンモデルgemma4:12b-it-q4_K_Mをローカルで、温度0、固定シードで1回実行し、その出力を保存した。そのため、各例はモデルを呼び出さずにlib.recorded.llm_judgments()を通じて記録を読む。このモデルを選んだ理由は、オープンでApache 2.0ライセンスの下にあり、ローカルで動作するので、誰でも記録を再実行できるからである。JSONスキーマにより、各出力は3つのラベルのいずれか1つに限られる。記録では、shortとguidelinesの2つのプロンプトで各ペアを評価した(判定ガイドラインを書く)。記録は2つの集合からペアを取っており、この章ではそれらをプールと呼ぶ。
ランカーの優劣を決めるスコアは、引き続き人間の評価に基づく。この章で計画した、テストクエリでの比較は第3章の3つの比較であり、各プロンプトのLLM評価で再計算したものであり、対応のある並べ替え検定には第3章の閾値0.0167を用いる。比較の内容は、意味検索とBM25、ハイブリッドと意味検索、リランキングしたハイブリッドとハイブリッドである。
この部分はまだ翻訳されていないため、英語で表示している。
Write judging guidelines
This chapter calls whoever gives a judgment, person or LLM, a judge, and a grade is the number that stands for it. Chapter 1 defines a judgment as a person's label; this chapter widens it to an LLM's label too. Judgments depend on the instructions behind them. Judging guidelines say what each grade means, how to choose between grades, and what to do with the cases that fall between them.
WANDS published the guidelines its annotators used: eight pages, under the MIT licence (annotation guidelines). For each pair they list what a judge sees: the query, and the product's ID, name, image and web page. They define the three grades and add two notes, one asking the judge to understand the query first: "Strongly recommend google it first", and one saying to ignore misspellings and annotate the pair as written. Then they teach by example, giving a query, a product and a reason for each grade: a wire basket without dividers is partial for wire basket with dividers, one of the store's own train queries, and a salon anti-fatigue mat is irrelevant to salon chair, because the customer looks for a salon chair, not a mat. Guidelines also change as judges use them. WANDS's authors say their annotators' agreement rose over four months, and among the reasons they give are a daily routine for discussing conflicting annotations, and guidelines refined with the annotators' input (Chen et al., 2022, section 5). One web search engine's rater guidelines do the same, at 182 pages in their version of September 11, 2025 (Search Quality Rater Guidelines).
The recording's two prompts are judging guidelines for the LLM. short is WANDS's three definitions alone; guidelines keeps them and adds five rules, so print it as the recording sent it:
1"""Prints the model, the word count of each prompt and the guidelines prompt verbatim, from the recording's manifest. The prose's point rests on the rules at the end of that prompt."""2from lib.recorded import manifest34recording = manifest("llm-judgments") # the recording's model, settings and both prompts, verbatim5short, guidelines = recording["prompts"]["short"], recording["prompts"]["guidelines"]67print("model:", recording["model"])8print("what the model saw:", recording["sees"])9print("words in the short prompt:", len(short.split()))10print("words in the guidelines prompt:", len(guidelines.split()))11print()12print(guidelines)
python print-judging-guidelines.pymodel: gemma4:12b-it-q4_K_M
what the model saw: lib.store text plus attributes; no images
words in the short prompt: 59
words in the guidelines prompt: 206
You judge product search results for an online furniture and home-goods store. A shopper typed the query and was shown the product. Decide how well the product matches what the shopper asked for.
Exact: the product fully matches the search query.
Partial: the product only matches the target entity of the query, but does not satisfy the modifiers for the query.
Irrelevant: the product is not relevant to the query.
Guidelines:
- First find the target entity: the kind of product the query asks for (a sofa, a lamp, a rug).
- Then find the modifiers: everything else the query asks for, such as colour, size, material, style, brand or a feature.
- Exact needs the right kind of product and every modifier. Partial is the right kind of product with at least one modifier missing or contradicted. Irrelevant is the wrong kind of product, even when it shares words with the query, such as an accessory for the product asked for.
- Read misspelled queries as the shopper meant them.
- Judge only from the product's text and attributes. If a modifier isn't mentioned, decide from what is written, and don't assume it is met.
Query: {query}
Product:
{product}
Answer with the label in JSON.
The guidelines prompt is the longer of the two, at 206 words against 59 for short. Its first two rules spell out WANDS's definition of partial: find the entity, then the modifiers. The accessory rule settles a case that WANDS's own labels split: for clear shower curtain, WANDS lists one set of shower curtain hooks twice, once as partial and once as irrelevant (Expect judges to disagree). The misspelling rule follows WANDS's note. The last rule has no counterpart in WANDS's guidelines, because the store's data holds no images, so the recording shows the LLM text only. Neither prompt has worked examples, which WANDS's guidelines rely on.
Working rule: Write guidelines as definitions, a procedure, a worked example with a reason for each grade, and a rule for each case your judges have disagreed on. Log disagreements and revise the guidelines when one kind keeps coming back. Give an LLM judge the same guidelines as people, plus a rule for what it can't see, and then measure what it does, because a rule you write isn't a rule the judge follows.
kappa で偶然を超えた一致を測る
2人目の判定者を信頼する前に、その判定者が1人目とどのくらいの頻度で一致するかを測る。2人の判定者が同じ評価を付けたペアの割合である観測一致率は、最も分かりやすい数値であるが、実際より良く見せる。互いに独立に当てずっぽうで判定した2人でも、一部のペアでは偶然に一致する。両者が同じラベルを多用する場合には、偶然の一致はさらに増える。**コーエンのカッパ(Cohen's kappa)**は、観測一致率を偶然の影響で補正する指標である。各判定者が自分のラベルの割合を保ったまま、相手とは独立にラベルを選んだと仮定したときに期待される一致率と、観測一致率とを比較する。カッパが 1 であれば完全な一致を表し、0 であれば「偶然に期待される以上の一致がない」ことを表す(scikit-learn documentation)。
kappa = (observed - expected) / (1 - expected)
expected = sum over grades g of (share of pairs judge A gives g) × (share of pairs judge B gives g)
一致の測定に用いる訓練プールは、訓練用クエリについて人が判定したペアからなり、ラベルごとに均等に抽出している。1つのクエリにつき各ラベル最大4件で、合計は 550 ペアである。テストプールは、ストアのランカーの採点のために LLM が評価するペアからなる。各テストクエリについて、第1章の4つのランカーの上位10件に入ったすべての商品を、人が判定したか否かにかかわらず含め、590 ペアである。4つのランカーとは、BM25、Snowflake/snowflake-arctic-embed-m-v1.5 の埋め込みによる意味検索、その2つのハイブリッド、そしてハイブリッドの結果をクロスエンコーダー Alibaba-NLP/gte-reranker-modernbert-base で再ランキングしたものである。LLM 判定者の各測定結果は、それを測ったプールについてのみ成り立つため、本章ではそのつどプールを明記する。
問いは、録画の LLM が、ストアの判定者と同じ評価をどのくらいの頻度で付けるかである。この問いには、訓練プールと short プロンプト(WANDS の3つの定義のみ)で答える。件数の 3×3 の表を手作業で作ってカッパを求め、scikit-learn の cohen_kappa_score で結果を確かめる。
1"""Builds the 3×3 table of the store's grades against the short prompt's on the train pool, then computes observed agreement, chance agreement and kappa from it. The prose's point rests on the printed kappa by hand, which matches the scikit-learn line."""2import numpy as np3from sklearn.metrics import cohen_kappa_score45from lib.agreement import graded_pairs67pairs = graded_pairs("train") # up to 4 human-judged pairs per label per train query8# the grades are nullable integers; plain ones compare and count the way the formulas below expect9human, llm = pairs["human"].astype(int), pairs["short"].astype(int)10grades = [2, 1, 0] # exact, partial, irrelevant11counts = np.array([[((human == row) & (llm == column)).sum() for column in grades] for row in grades])12print("pairs:", counts.sum())13print("rows are the human grades 2, 1, 0 and columns the LLM's, short prompt")14print(counts)1516observed = np.trace(counts) / counts.sum() # the share of pairs on the diagonal17human_share, llm_share = counts.sum(axis=1) / counts.sum(), counts.sum(axis=0) / counts.sum()18expected = (human_share * llm_share).sum() # agreement if the two judged independently19kappa = (observed - expected) / (1 - expected)20print(f"observed agreement, short prompt: {observed:.3f}")21print(f"agreement expected by chance, short prompt: {expected:.3f}")22print(f"kappa by hand, short prompt: {kappa:.3f}")23print(f"kappa from scikit-learn, short prompt: {cohen_kappa_score(human, llm):.3f}")2425other = pairs["guidelines"].astype(int)26print(f"observed agreement, guidelines prompt: {(human == other).mean():.3f}")27print(f"kappa from scikit-learn, guidelines prompt: {cohen_kappa_score(human, other):.3f}")
python kappa-by-hand.pypairs: 550
rows are the human grades 2, 1, 0 and columns the LLM's, short prompt
[[102 85 9]
[ 22 132 46]
[ 3 42 109]]
observed agreement, short prompt: 0.624
agreement expected by chance, short prompt: 0.337
kappa by hand, short prompt: 0.432
kappa from scikit-learn, short prompt: 0.432
observed agreement, guidelines prompt: 0.633
kappa from scikit-learn, guidelines prompt: 0.454
LLM とストアの判定者は、訓練ペアの 0.624 で同じ評価を付けており、偶然だけで生じる一致率は 0.337 である。カッパは、観測一致率からこの偶然による割合を引き、偶然を超えて残る余地で割る。その結果、short では 0.432 となり、scikit-learn の 0.432 と一致する。
guidelines は short よりもやや高い頻度で判定者と一致し、ペアの 0.633 で一致して、カッパは 0.454 である。
これは良い値なのだろうか。カッパを「中程度」や「相当」と呼ぶ尺度は、特定の分野の慣例である。Artstein と Poesio の調査によれば、特定の目的に対して十分な一致水準を選ぶことは「いまだ黒魔術にすぎない」という(Artstein and Poesio, 2008)。
公表されている数値は、基準ではなく文脈を与えるものである。WANDS のアノテーター同士のカッパは、最初の2か月は 0.467、4か月目は 0.826 であった(Chen et al., 2022, Table 2)。
Thomas らは、TREC(Text REtrieval Conference の共同評価)から層化抽出したペアについて、GPT-4 と評価者とのカッパがプロンプトによって 0.20 から 0.64 まで変動することを見いだした。訓練を受けた人間の評価者の2つのグループは、TREC のアドホック文書を2度目に判定した際に 0.52 に達した(Cormack et al., 1998, as reported by Thomas et al., 2024)。各数値は異なる標本から得られたものであり、カッパは標本のラベルの構成に依存する。
実践ルール: 観測一致率だけでなく、カッパを報告し、観測一致率を併記する。測定は、訓練用クエリについて人が判定したペアで行い、用いる閾値は経験則であると明記する。判定者が3人以上の場合や欠損ラベルがある場合は、Krippendorff のアルファを用いる。これは観測された不一致と偶然による不一致を比較し、任意の数の観察者と不完全なデータを扱える(Krippendorff, 2011)。
この部分はまだ翻訳されていないため、英語で表示している。
Give near misses partial credit with weighted kappa
Kappa counts every disagreement the same. The store's grades are ordered, exact above partial above irrelevant, and calling an exact product partial is a smaller error than calling it irrelevant. In nDCG@10 (Score one ranking) it costs half as much gain: one grade instead of two. Weighted kappa gives each disagreement a weight by its distance and compares the weighted disagreement with the weighted disagreement expected by chance (Artstein and Poesio, 2008, section 2.6). With linear weights, a disagreement one grade apart weighs 0.5 and one two grades apart weighs 1:
weighted kappa = 1 - (sum of weight × observed count) / (sum of weight × count expected by chance)
With every disagreement weighted 1, the formula gives plain kappa. scikit-learn's cohen_kappa_score computes all three kinds this way: weight 1 by default, the distance between grades with weights="linear", and its square with weights="quadratic" (scikit-learn source). Scaling the weights doesn't change the result.
For both prompts, the example builds the linear weights by hand on the evenly drawn train pairs of Measure agreement beyond chance, then checks each result against scikit-learn:
1"""Computes linear weighted kappa by hand for both prompts on the train pool and checks each against scikit-learn. The prose's point rests on the two linear weighted kappa lines, which match scikit-learn's, and on the one-grade-apart shares beside them."""2import numpy as np3from sklearn.metrics import cohen_kappa_score, confusion_matrix45from lib.agreement import PROMPTS, graded_pairs67pairs = graded_pairs("train") # up to 4 human-judged pairs per label per train query8grades = [2, 1, 0] # exact, partial, irrelevant9cost = np.abs(np.subtract.outer(grades, grades)) / 2 # 0 on the diagonal, 0.5 one grade apart, 1 two apart10print("disagreement weights, rows and columns 2, 1, 0")11print(cost)1213for prompt in PROMPTS:14 human, llm = pairs["human"].astype(int), pairs[prompt].astype(int)15 # labels fixes the rows and columns to 2, 1, 0 in that order, not the order the grades first appear16 counts = confusion_matrix(human, llm, labels=grades) # rows human, columns LLM17 expected = np.outer(counts.sum(axis=1), counts.sum(axis=0)) / counts.sum() # counts if independent18 weighted = 1 - (cost * counts).sum() / (cost * expected).sum()19 near = cost == 0.5 # cells one grade apart20 print()21 # row 0 is exact and column 2 is irrelevant, so these two corners are the far misses22 print(f"pairs two grades apart, {prompt} prompt: {counts[0, 2] + counts[2, 0]}")23 print(f"disagreements one grade apart, share, {prompt} prompt: {counts[near].sum() / counts[cost > 0].sum():.3f}")24 print(f"one grade apart, share expected by chance, {prompt} prompt: {expected[near].sum() / expected[cost > 0].sum():.3f}")25 print(f"kappa, {prompt} prompt: {cohen_kappa_score(human, llm):.3f}")26 print(f"linear weighted kappa by hand, {prompt} prompt: {weighted:.3f}")27 print(f"linear weighted kappa from scikit-learn, {prompt} prompt: "28 f"{cohen_kappa_score(human, llm, weights='linear'):.3f}")
python weighted-kappa-by-hand.pydisagreement weights, rows and columns 2, 1, 0
[[0. 0.5 1. ]
[0.5 0. 0.5]
[1. 0.5 0. ]]
pairs two grades apart, short prompt: 12
disagreements one grade apart, share, short prompt: 0.942
one grade apart, share expected by chance, short prompt: 0.742
kappa, short prompt: 0.432
linear weighted kappa by hand, short prompt: 0.523
linear weighted kappa from scikit-learn, short prompt: 0.523
pairs two grades apart, guidelines prompt: 30
disagreements one grade apart, share, guidelines prompt: 0.851
one grade apart, share expected by chance, guidelines prompt: 0.664
kappa, guidelines prompt: 0.454
linear weighted kappa by hand, guidelines prompt: 0.531
linear weighted kappa from scikit-learn, guidelines prompt: 0.531
Weighting raises short's kappa from 0.432 to 0.523, and guidelines' from 0.454 to 0.531, and both match scikit-learn's. It raises them because the disagreements sit one grade apart more often than chance would put them there: 0.942 of short's against 0.742, and 0.851 of guidelines' against 0.664.
The prompts also differ in their far misses, the pairs two grades apart: 12 for short and 30 for guidelines. Whether either prompt agrees better is a question for an interval.
Working rule: For ordered grades, report linear weighted kappa next to plain kappa, and count the far misses separately. Weight each disagreement by the gap in gain it costs. With the book's linear gains, that's linear weights. With exponential gains of 0, 1 and 3 (Choose a metric), the gaps are 1, 2 and 3, which neither of scikit-learn's options gives, so build that matrix as the example builds the linear one.
kappaはラベルの構成とあわせて読む
kappaの補正は、各判定者が各ラベルをどの頻度で使うかに依存する。そのため、同じ判定者でも、ラベルの構成が異なる標本では異なるkappaが得られる。1つのラベルが多数を占めると、観測一致率が高いままkappaが低くなることがある。ArtsteinとPoesioはこれを有病率(prevalence)の問題と呼び、次のように述べている。「アノテータが高い割合の項目で一致し、その注釈が実際に高い度合いで正しい場合でも、信頼性係数は低いままとなりうる」(Artstein and Poesio, 2008)。
記録では、train用プールを、train用クエリごとに各ラベルのペアを最大4件まで、均等に抽出して作成した。そのため、プールにはストアの判定よりも多くの exact ペアと irrelevant ペアが含まれている。これがkappaにどう影響するかを見るために、プールがtrain用クエリ全体の判定のラベル構成になるように各ペアへ重みを付け、あらためて測定する。
1"""Measures each prompt's agreement with the store's judges on the train pool, as drawn and reweighted to the label mix of all the train judgments. The prose's point rests on the kappa lines for each mix and on the higher-kappa lines, which change with the mix."""2import numpy as np3from sklearn.metrics import cohen_kappa_score45from lib.agreement import LABELS, PROMPTS, graded_pairs6from lib.store import load_labels, load_queries78pairs = graded_pairs("train") # drawn evenly: up to 4 pairs per label per train query9drawn = pairs["human"].value_counts(normalize=True)10labels = load_labels()11# every judged label for the train queries, not only the pairs that were drawn12natural = labels[labels["query_id"].isin(load_queries("train").index)]["grade"].value_counts(normalize=True)13top = graded_pairs("test")["human"].dropna().value_counts(normalize=True) # the rankers' top 10s, judged pairs14for grade, label in LABELS.items():15 print(f"{label} share, as drawn: {drawn[grade]:.3f}")16 print(f"{label} share, in the train judgments: {natural[grade]:.3f}")17 print(f"{label} share, judged test-pool pairs: {top[grade]:.3f}")1819# each pair counts for its label's share in the judgments divided by its share as drawn20weight = pairs["human"].map(natural / drawn).astype(float) # count each pair as if drawn in that mix21kappas = {}22for prompt in PROMPTS:23 human, llm = pairs["human"].astype(int), pairs[prompt].astype(int)24 print()25 print(f"observed agreement, {prompt} prompt, as drawn: {(human == llm).mean():.3f}")26 print(f"kappa, {prompt} prompt, as drawn: {cohen_kappa_score(human, llm):.3f}")27 print(f"observed agreement, {prompt} prompt, train judgments' mix: {np.average(human == llm, weights=weight):.3f}")28 # sample_weight counts each pair that many times; it is not the linear weights of the last section29 kappas[prompt] = cohen_kappa_score(human, llm), cohen_kappa_score(human, llm, sample_weight=weight)30 print(f"kappa, {prompt} prompt, train judgments' mix: {kappas[prompt][1]:.3f}")31print()32for position, mix in enumerate(["as drawn", "train judgments' mix"]):33 # on a tie, max returns the first prompt, short34 print(f"higher kappa, {mix}: {max(PROMPTS, key=lambda prompt: kappas[prompt][position])}")
python kappa-under-two-label-mixes.pyexact share, as drawn: 0.356
exact share, in the train judgments: 0.234
exact share, judged test-pool pairs: 0.543
partial share, as drawn: 0.364
partial share, in the train judgments: 0.613
partial share, judged test-pool pairs: 0.427
irrelevant share, as drawn: 0.280
irrelevant share, in the train judgments: 0.153
irrelevant share, judged test-pool pairs: 0.030
observed agreement, short prompt, as drawn: 0.624
kappa, short prompt, as drawn: 0.432
observed agreement, short prompt, train judgments' mix: 0.635
kappa, short prompt, train judgments' mix: 0.370
observed agreement, guidelines prompt, as drawn: 0.633
kappa, guidelines prompt, as drawn: 0.454
observed agreement, guidelines prompt, train judgments' mix: 0.573
kappa, guidelines prompt, train judgments' mix: 0.345
higher kappa, as drawn: guidelines
higher kappa, train judgments' mix: short
partial の割合は、抽出されたままのプールでは0.364であるが、trainの判定では0.613である。したがって、重み付けによって partial のペアはより重く、exact と irrelevant のペアはより軽く数えられる。
判定の構成では、shortの観測一致率は0.624から0.635に、kappaは0.432から0.370に変わる。guidelinesでは、観測一致率が0.633から0.573に、kappaが0.454から0.345に変わる。
kappaが高い方のプロンプトは、抽出されたままではguidelinesであり、判定の構成ではshortである。
公表された数値には、その構成が付いて回る。WANDSでLLM判定者を調べた研究として我々が見つけられたのは、1件だけである。その研究は、クエリと商品のペア5,000件を3つのラベルに均等に割り振って抽出している。報告されている正解率は、パラメータ数700億の最良のオープンモデルで0.726、最良のクローズドモデルで0.837であり、いずれも最良の設定で、各ペアに対して取得した16件の実例を用いている(Sachdev et al., 2025, Table 3)。ストアのプロンプトには実例がない。この正解率は、train用プールと同様に、均衡した標本での観測一致率である。したがって、どちらの数値も、ストアの判定のラベル構成にはそのまま当てはまらない。
ストアがLLMに判定させるペアは、ランカーが上位10件に入れた商品、すなわちtest用プールである。判定済みのペアのうち、exact は0.543、partial は0.427、irrelevant は0.030である。これは3つ目の構成であり、種類の異なるペアでもある。これについてはLLMの誤りの向きを読むで測定する。
実践ルール: kappaを報告するときは、必ずラベルの構成も併記すること。構成の異なる標本から得たkappa同士は、自分で得たものでも公表されたものでも、比較してはならない。一致率の標本は、判定者を使う場面と同じ方法で抽出することを推奨する。判定者でランカーの上位10件を採点するのであれば、train用クエリの上位10件からペアを抽出する。
LLMの誤りの方向を読む
カッパは2人の判定者がどれだけ一致するかを示すものであり、どのように食い違うかは示さない。混同行列(confusion matrix)は、2人の判定者の食い違い方を示す。これは件数の表であり、行は店舗の評価の各段階、列はLLMの評価の各段階に対応し、どちらも exact、partial、irrelevant の順に並べる。対角線より上には、LLMが店舗の判定者より低い評価を付けた対が入り、下には、高い評価を付けた対が入る。誤りの多くが下側にある判定者は寛容であり、誤りの多くが上側にある判定者は厳格である。
いくつもの研究が、LLMの判定者は寛容であると報告している。検索拡張生成(取得したテキストから回答を書く方式)を評価するTREC 2024のRAGトラックでは、人間の評価者はオープンソースのLLM判定者であるUMBRELAよりも全体として厳格に見える(Upadhyay et al., 2024a)。Arabzadeh と Clarke の報告によると、GPT-4oを基盤とするUMBRELA(Upadhyay et al., 2024b)は、2019年から2021年のTRECディープラーニングトラック全体で、人間より26%以上多くの文書を完全に関連があると判定した。件数にすると、3,063件対2,429件である(Arabzadeh and Clarke, 2025a)。Yu らは、LLMの判定者が「一貫して関連度のスコアを水増しする」と報告している(Yu et al., 2026)。
すべての研究が一致しているわけではない。Thomas らは、32種類のプロンプトのうち1つを用いて、ラベルで層化した標本で調べた。その結果、LLMのほうがTRECの評価者よりも対を関連なしと判定しやすく、その割合は44%対33%であった(Thomas et al., 2024)。
プロンプトごと、プールごとに混同行列を作ると、LLMがどちらの方向に誤るか、そしてその方向が、均衡させた訓練用の対からランカーの上位10件への移行後も保たれるかが分かる。訓練プールはラベルごとに均等に抽出したものであり、テストプールの判定済みの対は、LLMが評価する第1章の4つのランカーの上位10件である。テストプールの行列はテストクエリについての報告であり、プロンプトを選ぶためのものではない。
1"""Prints the confusion matrix of the store's grades against each prompt's grades, on the train pool and on the judged test pairs, with the counts of lower and higher grades. The prose's point rests on the 'stricter' line for each pool, read with the largest error printed beside it."""2import pandas as pd3from sklearn.metrics import cohen_kappa_score45from lib.agreement import LABELS, PROMPTS, graded_pairs67order = list(LABELS.values()) # rows: the store's grades; columns: the LLM's; both exact first8for pool in ["train", "test"]:9 pairs = graded_pairs(pool).dropna(subset=["human"]) # in the test pool, the pairs people judged10 human = pairs["human"].astype(int)11 print(f"\njudged pairs, {pool} pool: {len(pairs)}\nmean human grade, {pool} pool: {human.mean():.3f}")12 for prompt in PROMPTS:13 llm, name = pairs[prompt].astype(int), f"{pool} pool, {prompt} prompt"14 table = pd.crosstab(human.map(LABELS).rename("human"), llm.map(LABELS).rename(f"llm, {name}"))15 table = table.reindex(index=order, columns=order, fill_value=0)16 errors = {f"{row} called {column}": table.at[row, column] for row in order for column in order if row != column}17 # on a tie, max returns the first cell, in row order18 largest = max(errors, key=errors.get)19 print(table)20 print(f"kappa, {name}: {cohen_kappa_score(human, llm):.3f}\nmean llm grade, {name}: {llm.mean():.3f}")21 print(f"llm grade higher than human, {name}: {(llm > human).sum()}")22 print(f"llm grade lower than human, {name}: {(llm < human).sum()}")23 # a tie counts as not stricter24 print(f"stricter than the store's judges, {name}: {'yes' if (llm < human).sum() > (llm > human).sum() else 'no'}")25 print(f"largest error, {name}: {largest} ({errors[largest]})")
python llm-confusion-matrix.py
judged pairs, train pool: 550
mean human grade, train pool: 1.076
llm, train pool, short prompt exact partial irrelevant
human
exact 102 85 9
partial 22 132 46
irrelevant 3 42 109
kappa, train pool, short prompt: 0.432
mean llm grade, train pool, short prompt: 0.933
llm grade higher than human, train pool, short prompt: 67
llm grade lower than human, train pool, short prompt: 140
stricter than the store's judges, train pool, short prompt: yes
largest error, train pool, short prompt: exact called partial (85)
llm, train pool, guidelines prompt exact partial irrelevant
human
exact 118 53 25
partial 30 98 72
irrelevant 5 17 132
kappa, train pool, guidelines prompt: 0.454
mean llm grade, train pool, guidelines prompt: 0.862
llm grade higher than human, train pool, guidelines prompt: 52
llm grade lower than human, train pool, guidelines prompt: 150
stricter than the store's judges, train pool, guidelines prompt: yes
largest error, train pool, guidelines prompt: partial called irrelevant (72)
judged pairs, test pool: 564
mean human grade, test pool: 1.512
llm, test pool, short prompt exact partial irrelevant
human
exact 252 53 1
partial 57 177 7
irrelevant 2 6 9
kappa, test pool, short prompt: 0.571
mean llm grade, test pool, short prompt: 1.521
llm grade higher than human, test pool, short prompt: 65
llm grade lower than human, test pool, short prompt: 61
stricter than the store's judges, test pool, short prompt: no
largest error, test pool, short prompt: partial called exact (57)
llm, test pool, guidelines prompt exact partial irrelevant
human
exact 261 41 4
partial 76 133 32
irrelevant 3 4 10
kappa, test pool, guidelines prompt: 0.470
mean llm grade, test pool, guidelines prompt: 1.521
llm grade higher than human, test pool, guidelines prompt: 83
llm grade lower than human, test pool, guidelines prompt: 77
stricter than the store's judges, test pool, guidelines prompt: no
largest error, test pool, guidelines prompt: partial called exact (76)
訓練プールでは、LLMは店舗の判定者より厳格だろうか。short では yes、guidelines では yes である。short では 140 件の対を低く、67 件を高く評価しており、guidelines では 150 件を低く、52 件を高く評価している。最大の誤りは、short では exact called partial (85)、guidelines では partial called irrelevant (72) である。
テストプールでは、答えは short では no、guidelines では no である。short では、LLMの評価が高いのは 65 件、低いのは 61 件であり、guidelines では、高いのは 83 件、低いのは 77 件である。LLMの平均評価は、short では 1.521、guidelines では 1.521 であり、判定者の 1.512 と比べられる。最大の誤りは、short では partial called exact (57)、guidelines では partial called exact (76) である。
カッパは、short では 0.571、guidelines では 0.470 であり、訓練プールの 0.432 および 0.454 と比べられる。方向も最大の誤りもカッパも、ラベルの構成が警告するとおり、プールによって変わる。LLMが見たものを比べるでは、両方のプールに当てはまる1つのパターンを見いだす。
また、誤りの方向から、ランカーのスコアがどうなるかは分からない。寛容な判定者は、より多くの商品を関連ありと数えるため、precision@10が上がる(関連する商品を数える)。nDCG@10は、同じ評価から作った理想の上位10件で割るため(1つのランキングを採点する)、評価が上がれば理想も上がりうる。そのため、正味の効果はどちらにも転びうるし、ランカーごとに異なりうる。ランカーの順位の検査では、これをテストプールで測定する。
実践ルール: カッパを読む前に混同行列を読むこと。その際、判定者を実際に使う方法と同じやり方で抽出した対を用い、そのプールについて誤りの方向と最大の誤りを明示する。方向をあるプールから別のプールへ持ち越してはならず、そこからランカーのnDCG@10を予測してもならない。ランカー同士は同じ評価のもとで比較し、LLMの評価によるスコアと人間の評価によるスコアを比較してはならない。
LLMが見たものと評価者が見たものを比較する
評価者が採点できるのは、示された根拠だけである。WANDSの評価者が見たのは、クエリと、商品のID、名前、画像、Webページであり、ガイドラインは、まずクエリを理解するよう求めていた。「まずGoogleで調べることを強く勧める」という記述である(annotation guidelines)。記録がLLMに見せたのは、各商品の名前、クラス、カテゴリ、説明、属性であり、lib.agreement.as_the_llm_sawがそれらを書き出したものである。ストアのサンプルでは説明が約400文字で切られ(data card)、画像は含まれないため、記録はLLMにテキストだけを送った。不一致の一部は、LLMの判定の質ではなく、この差から生じている可能性がある。これは我々の推論である。ここから一つの帰結を検証できる。LLMが書かれた内容に基づいて採点するのであれば、テキストがクエリの求めるものを述べていないexact商品には低い評価を与え、述べているpartial商品には高い評価を与えるはずである。
この検証では、訓練ペア一つと、テストクエリclear shower curtain、そして両方のプールで評価済みのexactとpartialの全ペアを対象とする(the recording)。クエリの各単語がLLMの見た内容にあるかを調べる。内容は、2章の検証と同じ方法で小文字の単語に分割する。
1"""Checks whether the LLM's grades follow the words in each product's text, for one train pair, for the clear shower curtain products, and across both pools. The prose's point rests on the 'share graded lower' and 'share graded higher' lines, which compare pairs whose text has every query word with pairs that miss one."""2import re34from lib.agreement import PROMPTS, as_the_llm_saw, graded_pairs5from lib.store import load_products, load_queries678def words(text):9 """Lowercase word tokens, as chapter 2 matches query words against product text."""10 # runs of letters, digits and underscores, so 7qt is one word and '7 qt' is two11 return set(re.findall(r"\w+", text.lower()))121314products, queries = load_products(), load_queries()15# query 163 is a train query, and product 20718 is the pair the prose follows16print("query:", queries.at[163, "query"]) # a train query17print(as_the_llm_saw(products.loc[20718]))18print("grades from people, short, guidelines:", *graded_pairs("train").set_index(["query_id", "product_id"]).loc[(163, 20718)])1920curtains = graded_pairs("test").query("query_id == 246") # clear shower curtain: every product in a top 1021# whole words only, so 'unclear' doesn't count as saying clear22says = curtains["product_id"].map(lambda product_id: "clear" in words(as_the_llm_saw(products.loc[product_id])))23for kind, group in [("say clear", curtains[says]), ("never say clear", curtains[~says])]:24 print(f"\nclear shower curtain products that {kind}: {len(group)}")25 for column, judge in [("human", "people"), ("short", "the short prompt"), ("guidelines", "the guidelines prompt")]:26 print(f"products that {kind}, graded exact by {judge}: {(group[column] == 2).sum()}")2728for pool in ["train", "test"]:29 pairs = graded_pairs(pool).dropna(subset=["human"]) # in the test pool, the pairs people judged30 # subset: every query word appears in the text the LLM saw31 pairs["every word"] = [words(queries.at[query_id, "query"]) <= words(as_the_llm_saw(products.loc[product_id]))32 for query_id, product_id in zip(pairs["query_id"], pairs["product_id"])]33 # share of each group that the LLM grades below people (exact) or above them (partial), for each prompt34 for label, grade, every_word, direction in [("exact", 2, False, "lower"), ("exact", 2, True, "lower"),35 ("partial", 1, True, "higher"), ("partial", 1, False, "higher")]:36 group = pairs[(pairs["human"] == grade) & (pairs["every word"] == every_word)]37 kind = f"{label} {pool} pairs {'with every query word' if every_word else 'missing a query word'}"38 print(f"\n{kind}: {len(group)}")39 for prompt in PROMPTS:40 moved = group[prompt] < grade if direction == "lower" else group[prompt] > grade41 print(f"share graded {direction}, {prompt} prompt, {kind}: {moved.mean():.3f}")
python llm-grades-follow-written-words.pyquery: dual monitor stand
Name: abramowski monitor stand
Class: Desktop Organizers & Desk Pads
Category:
Description: the monitor stand riser can help !
Attributes: color: white; material: wood; style: modern; width: 23.5; height: 4.64; depth: 9.2
grades from people, short, guidelines: 2 1 1
clear shower curtain products that say clear: 9
products that say clear, graded exact by people: 5
products that say clear, graded exact by the short prompt: 7
products that say clear, graded exact by the guidelines prompt: 7
clear shower curtain products that never say clear: 9
products that never say clear, graded exact by people: 1
products that never say clear, graded exact by the short prompt: 0
products that never say clear, graded exact by the guidelines prompt: 0
exact train pairs missing a query word: 149
share graded lower, short prompt, exact train pairs missing a query word: 0.584
share graded lower, guidelines prompt, exact train pairs missing a query word: 0.483
exact train pairs with every query word: 47
share graded lower, short prompt, exact train pairs with every query word: 0.149
share graded lower, guidelines prompt, exact train pairs with every query word: 0.128
partial train pairs with every query word: 8
share graded higher, short prompt, partial train pairs with every query word: 0.875
share graded higher, guidelines prompt, partial train pairs with every query word: 0.875
partial train pairs missing a query word: 192
share graded higher, short prompt, partial train pairs missing a query word: 0.078
share graded higher, guidelines prompt, partial train pairs missing a query word: 0.120
exact test pairs missing a query word: 128
share graded lower, short prompt, exact test pairs missing a query word: 0.305
share graded lower, guidelines prompt, exact test pairs missing a query word: 0.281
exact test pairs with every query word: 178
share graded lower, short prompt, exact test pairs with every query word: 0.084
share graded lower, guidelines prompt, exact test pairs with every query word: 0.051
partial test pairs with every query word: 42
share graded higher, short prompt, partial test pairs with every query word: 0.548
share graded higher, guidelines prompt, partial test pairs with every query word: 0.667
partial test pairs missing a query word: 199
share graded higher, short prompt, partial test pairs missing a query word: 0.171
share graded higher, guidelines prompt, partial test pairs missing a query word: 0.241
訓練クエリであるdual monitor standについて、ストアの評価者はabramowski monitor standをexactと評価し、両方のプロンプトはpartialと評価した(2 1 1、この順)。LLMが見た内容のどこにも、そのスタンドがモニターを2台支えるとは書かれていない。
clear shower curtainでは、LLMのexact評価は単語の有無に従う。テストプールの商品のうち、LLMが読める箇所にclearと書かれている9について、評価者がexactとしたものは5、shortプロンプトがexactとしたものは7、guidelinesプロンプトがexactとしたものは7であった。9のうち、一度も書かれていないものについては、評価者がexactとしたものが1、shortプロンプトが0、guidelinesプロンプトが0であった。
プール全体で数えても、この傾向は変わらない。shortでは、テキストにクエリの単語が欠けているexactペアに対し、LLMがより低い評価を与える割合は、訓練プールで0.584、テストプールで0.305であった。これに対し、テキストにすべての単語があるexactペアでは、それぞれ0.149と0.084である。
テストプールでは、テキストにクエリの全単語があるペアがより高い評価を受ける割合は0.548で、単語が欠けているペアでは0.171である。テストプールでは、guidelinesも同じように分かれる。exactペアでは0.281に対して0.051、partialペアでは0.667に対して0.241である。
どちらの場合が多いかは、プールによって異なる。訓練プールには、単語が欠けているexactペアが149、全単語を含むpartialペアが8ある。テストプールではそれぞれ128と42である。我々の解釈では、これが誤りの方向がプール間で異なる理由である。この検証は大まかなものであり、複数形やつづりの誤りも単語の欠落として数えられる。guidelinesプロンプトは評価を下げることを求めている。「修飾語が言及されていない場合は、書かれている内容から判断し、満たされていると仮定してはならない」とある。shortプロンプトにはそのような規則はないが、こちらも評価を下げている。
実践ルール: 評価者が根拠にしたフィールドのうち、テキストにできるもの(属性や説明の全文など)はすべてLLM評価者に与え、見えないものは書き残しておくこと。不一致をLLMの誤りとして数える前に、その根拠がLLMの見た内容に含まれていたかを確認する。評価者の根拠が視覚的なものである場合は、この例が両方のプールで示すように、LLMがexact商品をより低く評価するかどうかを測定する。あるいは、モデルが対応していれば画像を与える。
プロンプトがラベルをどれだけ変えるかを測定する
LLM判定器は、モデルとプロンプトを合わせたものである。Thomas らは、1つのプロンプトを言い換えた42通りの間で、平均kappaが0.50(彼らが中程度の一致と呼ぶ水準)から0.72まで広がることを見いだした。彼らは、1つのプロンプトのスコアは、判定器が到達しうる範囲からの1回の抽出にすぎないと警告している(Thomas et al., 2024)。
Arabzadeh と Clarke は、TREC の Deep Learning コレクションで3つのLLMと72のプロンプトを比較し、二値方式とペアワイズ方式はプロンプトの文言に対して最も感度が低く、段階的な関連性判定(このストアが用いる種類)は文言に対して非常に敏感であることを見いだした(Arabzadeh and Clarke, 2025b)。すべてのLLMで最良となる単一のプロンプトはなかったが、UMBRELA は異なるLLMにまたがって段階的な評価で一貫して良好な結果を示した。
2つのプロンプトは定義を共有しており、guidelines はその上に5つの規則を加えたものである(判定ガイドラインを書く)。記録の各プールは、プロンプト間で判定が食い違う箇所を示し、訓練プールは、どちらのプロンプトがストアの判定者とよりよく一致するかを区別できるかどうかを示す。同じクエリに属するペアは独立ではないため、区間の算出では、第3章のブートストラップがクエリを再標本化するのと同様に、訓練クエリ全体を再標本化する。
1"""Counts where the two prompts disagree, their kappa with each other, and how far their kappas with people differ across resampled train queries. The prose's point rests on the 95% interval line, which includes 0 for this recording."""2import numpy as np3import pandas as pd4from sklearn.metrics import cohen_kappa_score56from lib.agreement import LABELS, graded_pairs7from lib.store import load_products, load_queries8910def kappa_gap(sample):11 """Kappa with people under the guidelines prompt, minus kappa under the short prompt."""12 human = sample["human"].astype(int)13 return cohen_kappa_score(human, sample["guidelines"].astype(int)) - cohen_kappa_score(human, sample["short"].astype(int))141516order = list(LABELS.values()) # exact, partial, irrelevant17for pool in ["train", "test"]:18 # the test pool includes pairs nobody judged, so these counts cover every pair19 pairs = graded_pairs(pool)20 print(f"\n{pool} pairs where the prompts disagree: {(pairs['short'] != pairs['guidelines']).sum()} of {len(pairs)}\n"21 f"kappa between the prompts, {pool} pool: {cohen_kappa_score(pairs['short'], pairs['guidelines']):.3f}")22 table = pd.crosstab(pairs["short"].map(LABELS).rename(f"short, {pool}"), pairs["guidelines"].map(LABELS).rename("guidelines"))23 table = table.reindex(index=order, columns=order, fill_value=0)24 cells = {f"{row} under short, {column} under guidelines": table.at[row, column] for row in order for column in order if row != column}25 print(f"{table}\nlargest disagreement, {pool} pool: {max(cells, key=cells.get)} ({max(cells.values())})")2627pairs, products, queries = graded_pairs("train"), load_products(), load_queries()28moved = pairs[(pairs["short"] == 1) & (pairs["guidelines"] == 0)] # partial under one prompt, irrelevant under the other29print("\n".join(f"moved train pairs judged {label} by people: {(moved['human'] == grade).sum()}" for grade, label in LABELS.items()))30# the first five queries in order, not a random sample31for query_id, product_id in moved[["query_id", "product_id"]].drop_duplicates("query_id").head(5).itertuples(index=False):32 print(f" {queries.at[query_id, 'query']:<28} {products.at[product_id, 'name'][:50]}")3334# a fixed seed, so the interval is the same on every run35rng, train_queries = np.random.default_rng(2026), pairs["query_id"].unique()36by_query = {query_id: group for query_id, group in pairs.groupby("query_id")}37# each resample draws train queries with replacement, so some repeat and others are left out38gaps = [kappa_gap(pd.concat([by_query[query_id] for query_id in rng.choice(train_queries, len(train_queries))]))39 for _ in range(2000)] # resample whole train queries40low, high = np.percentile(gaps, [2.5, 97.5])41print(f"kappa with people, guidelines minus short: {kappa_gap(pairs):.3f}\n95% interval over resampled train queries: {low:.3f} to {high:.3f}")
python prompt-disagreement.py
train pairs where the prompts disagree: 122 of 550
kappa between the prompts, train pool: 0.668
guidelines exact partial irrelevant
short, train
exact 122 4 1
partial 31 153 75
irrelevant 0 11 153
largest disagreement, train pool: partial under short, irrelevant under guidelines (75)
test pairs where the prompts disagree: 93 of 590
kappa between the prompts, test pool: 0.712
guidelines exact partial irrelevant
short, test
exact 303 11 1
partial 42 174 37
irrelevant 0 2 20
largest disagreement, test pool: partial under short, exact under guidelines (42)
moved train pairs judged exact by people: 18
moved train pairs judged partial by people: 31
moved train pairs judged irrelevant by people: 26
toddler couch fold out eulah 79 '' cotton rolled arm sofa bed
70s inspired furniture angels moroccan window curtains , oriental wavy cu
7qt slow cooker berghoff international eclipse 7 qt non-stick cove
gnome fairy garden fairy house tea pot fairy garden
wall sconce with usb port 2 piece wall sconce set
kappa with people, guidelines minus short: 0.022
95% interval over resampled train queries: -0.042 to 0.086
2つのプロンプトは、訓練ペアのうち 122 of 550 件、テストペアのうち 93 of 590 件で食い違い、両者の間のkappaは訓練プールで 0.668、テストプールで 0.712 である。
最大の食い違いはプールによって異なる。訓練プールでは partial under short, irrelevant under guidelines (75) であり、ランカーの上位10件からなるテストプールでは partial under short, exact under guidelines (42) である。
short が部分的と判定し、guidelines が無関係と判定した訓練ペアのうち、ストアの判定者は 26 件を無関係と判定して guidelines 側に付き、31 件を部分的と判定して short 側に付き、18 件を完全一致と判定した。この例が挙げる、判定が移ったペアの中には、toddler couch fold out に対するソファベッドと、70s inspired furniture に対する窓用カーテンがある。記録に残るのはラベルであって理由ではないため、こうした名前から、この移動は、種類の違う商品を無関係とする guidelines の規則によるものと推測する。
ストアの判定者とのkappaでは、guidelines が short を 0.022 だけ上回り、再標本化した訓練クエリに基づく95%区間は -0.042 to 0.086 に及ぶ。この区間は0を含むため、訓練プールは2つのプロンプトを区別できず、ストアは両方を保持する。
実践ルール: プロンプトを判定器の一部として扱う。すべてのプロンプトを、モデルのバージョン、設定、回答スキーマとともに一語一句記録する。この記録がマニフェストとスクリプトで行っているとおりである。プロンプトの変更は別の判定器とみなし、その一致度を改めて測定する。少なくとも2つのプロンプトを実行し、LLMによる評価からの結論は、両方が同じ結論を示す場合にのみ信頼する。あるプロンプトを別のプロンプトより選ぶ際は、訓練ペアに基づいて行い、両者の差の区間が0を含まない場合に限る。
この部分はまだ翻訳されていないため、英語で表示している。
Fill unjudged pairs with LLM grades
We consider filling the holes in the human judgments the least risky use of an LLM judge. Keep every human grade, and use the LLM only for pairs nobody judged, which a metric would otherwise count as grade 0 (Count unjudged products). The LLM then decides only what was a guess before.
Of the 590 pairs in the top 10s of chapter 1's four rankers, 26 are unjudged, and BM25's top 10s hold 22 of them, against 3 for semantic retrieval and 6 for the hybrid.
Let each prompt fill them, rescore the four rankers on nDCG@10 (Score one ranking), and rerun chapter 3's planned comparisons on the filled grades:
1"""Fills the pairs nobody judged with each prompt's grades, then rescores the four rankers and the planned verdicts with the filled grades. The prose's point rests on the 'that change' lines, which list the rankers and verdicts that move when the holes are filled."""2from lib.agreement import LABELS, PLANNED, PROMPTS, chapter_one_runs, fill_unjudged, graded_pairs, llm_qrels, planned_verdicts3from lib.metrics import evaluate4from lib.store import load_products, load_queries, qrels567def order(scores):8 """Rankers by mean nDCG@10 over the test queries, best first."""9 return sorted(scores, key=lambda name: scores[name].mean(), reverse=True)101112products, queries, people = load_products(), load_queries("test"), qrels("test")13runs = chapter_one_runs(products, queries)14pairs = graded_pairs("test") # every product in the top 10 of the four runs, per test query15unjudged = pairs[pairs["human"].isna()]16print(f"pairs in the test pool: {len(pairs)}\nof them, unjudged: {len(unjudged)}")17for name, run in runs.items():18 # people[query_id] holds the human judgments for a query, so a product missing from it was never judged19 missing = sum(product_id not in people[query_id] for query_id, ranking in run.items() for product_id in ranking[:10])20 print(f"unjudged products in the top 10s, {name}: {missing}")21lights = unjudged[unjudged["query_id"] == 133] # outdoor light fixtures22print(f"unjudged products for outdoor light fixtures: {len(lights)}\n"23 f"of them, with bulb in the name: {lights['product_id'].map(products['name']).str.contains('bulb').sum()}")24threshold = 0.05 / len(PLANNED) # chapter 3's rule25human = {name: evaluate(run, people)["ndcg@10"] for name, run in runs.items()} # per-query scores26print(f"order, people's grades only: {' > '.join(order(human))}")2728for prompt in PROMPTS:29 counts = ", ".join(str((unjudged[prompt] == grade).sum()) for grade in LABELS) # grades 2, 1 and 030 print(f"\nunjudged pairs graded exact, partial, irrelevant, {prompt} prompt: {counts}")31 print(f"unjudged bulbs graded irrelevant, {prompt} prompt: {(lights[prompt] == 0).sum()}")32 filled = {name: evaluate(run, fill_unjudged(people, llm_qrels(prompt)))["ndcg@10"] for name, run in runs.items()}33 print("\n".join(f"{name} ndcg@10, filled by the {prompt} prompt: {filled[name].mean():.3f}" for name in runs))34 print(f"order, filled by the {prompt} prompt: {' > '.join(order(filled))}")35 # compares the two orders place by place36 moved = [name for name, place in zip(order(filled), order(human)) if name != place]37 print(f"rankers that change place when filled, {prompt} prompt: {', '.join(moved) or 'none'}")38 changed = [pair for pair, established in planned_verdicts(filled, threshold).items()39 if established != planned_verdicts(human, threshold)[pair]]40 print(f"verdicts that change when filled, {prompt} prompt: {'; '.join(' minus '.join(pair) for pair in changed) or 'none'}")
python fill-unjudged-pairs.pypairs in the test pool: 590
of them, unjudged: 26
unjudged products in the top 10s, bm25: 22
unjudged products in the top 10s, semantic: 3
unjudged products in the top 10s, hybrid: 6
unjudged products in the top 10s, reranked: 6
unjudged products for outdoor light fixtures: 8
of them, with bulb in the name: 8
order, people's grades only: semantic > hybrid > reranked > bm25
unjudged pairs graded exact, partial, irrelevant, short prompt: 4, 17, 5
unjudged bulbs graded irrelevant, short prompt: 0
bm25 ndcg@10, filled by the short prompt: 0.754
semantic ndcg@10, filled by the short prompt: 0.833
hybrid ndcg@10, filled by the short prompt: 0.821
reranked ndcg@10, filled by the short prompt: 0.813
order, filled by the short prompt: semantic > hybrid > reranked > bm25
rankers that change place when filled, short prompt: none
verdicts that change when filled, short prompt: none
unjudged pairs graded exact, partial, irrelevant, guidelines prompt: 5, 9, 12
unjudged bulbs graded irrelevant, guidelines prompt: 7
bm25 ndcg@10, filled by the guidelines prompt: 0.745
semantic ndcg@10, filled by the guidelines prompt: 0.834
hybrid ndcg@10, filled by the guidelines prompt: 0.821
reranked ndcg@10, filled by the guidelines prompt: 0.813
order, filled by the guidelines prompt: semantic > hybrid > reranked > bm25
rankers that change place when filled, guidelines prompt: none
verdicts that change when filled, guidelines prompt: none
The prompts disagree about the unjudged pairs. Counted as exact, partial and irrelevant, short grades them 4, 17, 5, and guidelines 5, 9, 12. They part on the unjudged products for outdoor light fixtures in BM25's top 10 (Score every test query): 8 of the 8 have bulb in their names.
guidelines calls 7 of the bulbs irrelevant, and short calls 0. Chapter 1 argued that a bulb isn't a light fixture. Which reading the store's judges would take, nobody knows until they judge the bulbs.
With the holes filled, BM25 scores 0.754 with short and 0.745 with guidelines, against 0.725 on human grades alone, and semantic retrieval scores 0.833 and 0.834, against 0.830.
The order on human grades alone is semantic > hybrid > reranked > bm25. The rankers that change place when short fills the holes are none, and when guidelines does, none. The planned comparisons' verdicts that change are none under short and none under guidelines.
Under human grades, the rankers' mean judged@10, the share of each top 10 that people judged, runs from 0.927 for BM25 to 0.990 for semantic retrieval (Compare runs in a harness).
How far can the filled grades be trusted? The closest evidence is the judged pairs of the same pool, where the LLM's kappa with the store's judges is 0.571 for short and 0.470 for guidelines. On those judged pairs, its grade is lower than the judges' on 61 pairs and higher on 65 with short, and lower on 77 and higher on 83 with guidelines (Read the direction of the LLM's errors).
Working rule: Fill the unjudged pairs in your rankers' top 10s with LLM grades as a diagnostic, under every prompt you run, and report the filled score beside the human-only one with the number of pairs filled. If filling changes the order of two rankers or a verdict, have people judge those pairs. Never let a filled grade replace a human one.
LLMによる評価が各ランカーを同じ順序に並べるかを確認する
2組の判定は多くのラベルで食い違っていても、システムを同じように順位づけることがある。Voorhees は異なる関連性判定の組を用いて TREC の各ランを採点し、「異なる関連性判定の組から得たシステムの順位づけの間には、非常に高い相関が見られた」と報告した(Voorhees, 1998)。LLM による判定でも同じ乖離が見られる。TREC 2023 Deep Learning トラックに対する 42 組の LLM ラベルでは、kappa が約 0.06 から 0.29 まで広がったのに対し、システム順位の相関は約 0.83 から 0.95 の範囲にとどまった(Rahmani et al., 2025, Table 3)。
この相関が Kendall の tau である。システムの対を2つの順序が同じ向きに並べるとき、その対は一致対(concordant)であり、逆向きに並べるとき不一致対(discordant)である。tau は、一致対の数から不一致対の数を引き、全対数で割った値であり、順序が同じなら 1、逆順なら −1 となる。SciPy の kendalltau は、同順位(タイ)も扱える形の τ_b を計算する(SciPy documentation)。
Yilmaz らは、tau が 0.9 以上の順位づけは、少なくとも経験的には実質的に同等と見なされることが多いと述べている(Yilmaz et al., 2008)。一方、Sanderson と Soboroff は、このような閾値で判断することは、この分野が想定してきたほど信頼できないことを見いだした(Sanderson and Soboroff, 2007)。
第1章の4つのランカーを、人間による評価と、各プロンプトの LLM による評価のそれぞれで nDCG@10 により採点すれば、LLM が人間と同じようにランカーを並べるかどうかが分かる。LLM が判定したのはテストプールだけ、すなわちこれらのランカーの上位10件に含まれる商品だけである。そのため、対照として、プールの対だけに限った人間の評価でも採点する。ランカーが4つなら対は 6 通りであり、1対が入れ替わるたびに tau は 0.333 だけ動き、tau の取りうる値は7通りしかない。これは粗い指標である。個々の対では人間からこれほど離れている判定者でも、ランカーの順序は人間と同じになりうる。実際にそうなるだろうか。先に答えを決めておこう。
1"""Scores the four rankers under human grades, under people's grades on the LLM's pairs as a control, and under each prompt, then counts the swapped pairs for each set. The prose's point rests on the 'swapped under' lines, read with the tau lines beside them."""2from itertools import combinations34from scipy.stats import kendalltau56from lib.agreement import chapter_one_runs, llm_qrels7from lib.metrics import evaluate8from lib.store import load_products, load_queries, qrels910products, queries, people = load_products(), load_queries("test"), qrels("test")11runs = chapter_one_runs(products, queries)12short, guidelines = llm_qrels("short"), llm_qrels("guidelines")13pooled = {query_id: {product_id: grade for product_id, grade in people[query_id].items() if product_id in short[query_id]}14 for query_id in people} # people's grades for the pairs the LLM judged, and no others15judgment_sets = {"people": people, "people on the LLM's pairs": pooled, "the short prompt": short,16 "the guidelines prompt": guidelines}17means = {name: {ranker: evaluate(run, judgments)["ndcg@10"].mean() for ranker, run in runs.items()}18 for name, judgments in judgment_sets.items()}19for name, scores in means.items():20 print(f"order under {name}: {' > '.join(sorted(scores, key=scores.get, reverse=True))}")21 for ranker, score in scores.items():22 print(f"{ranker} ndcg@10 under {name}: {score:.3f}")2324orders = [sorted(scores, key=scores.get, reverse=True) for scores in means.values()]25steady = [ranker for position, ranker in enumerate(orders[0]) if all(order[position] == ranker for order in orders)]26print(f"rankers in the same place under every set of grades: {', '.join(steady) or 'none'}")27control = means["people on the LLM's pairs"] # the same pool, human grades28for name in ["the short prompt", "the guidelines prompt"]:29 print("\n".join(f"{ranker}, {name} minus people on the LLM's pairs: {means[name][ranker] - control[ranker]:+.3f}" for ranker in runs))30# people's scores are the reference that every other set of grades is compared with31pairs, reference = list(combinations(runs, 2)), means["people"]32# one swap turns a concordant pair into a discordant one, which moves tau by 2 over the number of pairs33print(f"\npairs of rankers: {len(pairs)}\nchange in tau from one swapped pair: {2 / len(pairs):.3f}")34for name, scores in list(means.items())[1:]:35 swapped = [(first, second) for first, second in pairs # discordant: opposite signs36 if (reference[first] - reference[second]) * (scores[first] - scores[second]) < 0]37 print(f"swapped under {name}: {'; '.join(f'{first} and {second}' for first, second in swapped) or 'none'}")38 # concordant minus discordant, over all pairs; the discordant count is the number of swaps39 print(f"tau by hand, people against {name}: {(len(pairs) - 2 * len(swapped)) / len(pairs):.3f}")40 # SciPy's tau_b, which handles ties; .statistic is the tau value41 print(f"tau from scipy, people against {name}: {kendalltau(list(reference.values()), list(scores.values())).statistic:.3f}")
python kendall-tau-four-rankers.pyorder under people: semantic > hybrid > reranked > bm25
bm25 ndcg@10 under people: 0.725
semantic ndcg@10 under people: 0.830
hybrid ndcg@10 under people: 0.812
reranked ndcg@10 under people: 0.798
order under people on the LLM's pairs: semantic > hybrid > reranked > bm25
bm25 ndcg@10 under people on the LLM's pairs: 0.795
semantic ndcg@10 under people on the LLM's pairs: 0.904
hybrid ndcg@10 under people on the LLM's pairs: 0.885
reranked ndcg@10 under people on the LLM's pairs: 0.869
order under the short prompt: reranked > semantic > hybrid > bm25
bm25 ndcg@10 under the short prompt: 0.832
semantic ndcg@10 under the short prompt: 0.903
hybrid ndcg@10 under the short prompt: 0.900
reranked ndcg@10 under the short prompt: 0.906
order under the guidelines prompt: reranked > semantic > hybrid > bm25
bm25 ndcg@10 under the guidelines prompt: 0.805
semantic ndcg@10 under the guidelines prompt: 0.878
hybrid ndcg@10 under the guidelines prompt: 0.876
reranked ndcg@10 under the guidelines prompt: 0.886
rankers in the same place under every set of grades: bm25
bm25, the short prompt minus people on the LLM's pairs: +0.037
semantic, the short prompt minus people on the LLM's pairs: -0.001
hybrid, the short prompt minus people on the LLM's pairs: +0.016
reranked, the short prompt minus people on the LLM's pairs: +0.037
bm25, the guidelines prompt minus people on the LLM's pairs: +0.010
semantic, the guidelines prompt minus people on the LLM's pairs: -0.026
hybrid, the guidelines prompt minus people on the LLM's pairs: -0.008
reranked, the guidelines prompt minus people on the LLM's pairs: +0.017
pairs of rankers: 6
change in tau from one swapped pair: 0.333
swapped under people on the LLM's pairs: none
tau by hand, people against people on the LLM's pairs: 1.000
tau from scipy, people against people on the LLM's pairs: 1.000
swapped under the short prompt: semantic and reranked; hybrid and reranked
tau by hand, people against the short prompt: 0.333
tau from scipy, people against the short prompt: 0.333
swapped under the guidelines prompt: semantic and reranked; hybrid and reranked
tau by hand, people against the guidelines prompt: 0.333
tau from scipy, people against the guidelines prompt: 0.333
人間の評価では semantic > hybrid > reranked > bm25 となる。対照、すなわち LLM の対に対する人間の評価でも順序は変わらず、tau は 1.000 である。したがって、評価をプールに限っても、順位が動くランカーはない。ただし、すべてのスコアは上がる。BM25 は 0.725 から 0.795 に上がる。理想的な上位10件には、プールに含まれる商品しか入れられないからである。
short での順序は reranked > semantic > hybrid > bm25、guidelines での順序は reranked > semantic > hybrid > bm25 である。short では semantic and reranked; hybrid and reranked が入れ替わり、guidelines では semantic and reranked; hybrid and reranked が入れ替わる。
short の tau は、手計算で 0.333、SciPy で 0.333 であり、guidelines では 0.333 である。
対照と比べると、LLM による評価は4つのランカーを同じ量だけ、同じ向きに動かすわけではない。short では、BM25 は +0.037、セマンティック検索は -0.001、ハイブリッドは +0.016、リランク済みハイブリッドは +0.037 だけ変化する。guidelines では、変化は +0.010、-0.026、-0.008、+0.017 である。判定者はあるランカーのスコアを上げ、別のランカーのスコアを下げるため、ランカー同士の順位が入れ替わる。
short では、セマンティック検索、ハイブリッド、リランク済みハイブリッドがほぼ同点であり、それぞれ 0.903、0.900、0.906 である。tau は2つのランカーのスコアがどれだけ離れているかを無視するため、ほぼ同点どうしの入れ替わりも、最良のランカーと最悪のランカーの入れ替わりと同じ重みで数えられる。
tau はまた、上位での入れ替わりを下位での入れ替わりと同じ重みで扱う。これは Yilmaz らが指摘する弱点である(Yilmaz et al., 2008)。Yilmaz らは、比較した TREC のランについて、システムは「非常によく似た性能を示す。したがって、Kendall の τ 統計量はこれらのシステムによって左右されうる」と述べている(Yilmaz et al., 2012)。
どの評価の組でも位置が変わらないランカーは bm25 である。順序が異なるのは、人間の評価が 0.830、0.812、0.798 と採点する3つのランカーの間だけであり、これらの差は、計画された比較のいずれによっても確立されない(計画された比較を再実行する)。
実践ルール: tau は単独で報告せず、入れ替わった対の一覧とともに報告する。ランカーが少数で、1回の入れ替わりで tau が 0.333 動く場合は、tau を 0.9 と比べて読まない。そのうえで、各評価の組のもとでの計画された比較により、入れ替わった対に差があるかどうかを検定する。
計画した比較をLLMの評価で再実行する
意思決定の根拠となるのは、本書の規則に基づく判定であり、tauが比較する順序ではない。LLMの評価を用いていたら、ストアは同じ判定を得ていただろうか。上位のシステムの比較で問題が生じると予想される。Oteroらは、「LLMに基づく判断は、上位の性能を持つシステムのランキングにおいて公平でない」こと、そして「統計的な差に関する偽陽性の割合が極めて高い」ことを見いだした(Otero et al., 2025)。
第3章の三つの計画した比較では、閾値を0.0167とし、区間は0.9833の水準を用いた。これらをテストプールで人間による評価と各プロンプトによる評価のもとで再実行する。これに、第3章で行った、リランキング付きハイブリッドと意味検索の探索的な比較を加えると、ストアが同じランカーを出荷していたかどうかが分かる。
1"""Runs chapter 3's three planned comparisons, and the exploratory one, under human grades and under each prompt's grades on the test pool. The prose's point rests on the 'verdicts that differ' lines and the count of disagreeing checks."""2from lib.agreement import PLANNED, PROMPTS, chapter_one_runs, llm_qrels # PLANNED: chapter 3's, each stage against the last3from lib.metrics import evaluate4from lib.significance import compare, verdict5from lib.store import load_products, load_queries, qrels67EXPLORATORY = [("reranked", "semantic")] # chosen after seeing test means8threshold = 0.05 / len(PLANNED) # chapter 3's threshold, so that a verdict means the same either way9print(f"planned comparisons: {len(PLANNED)}\np-value threshold: {threshold:.4f}\ninterval level: {1 - threshold:.4f}")1011runs = chapter_one_runs(load_products(), load_queries("test"))12judgment_sets = {"people": qrels("test"), **{f"{prompt} prompt": llm_qrels(prompt) for prompt in PROMPTS}}13established, disagreements = {}, {judges: 0 for judges in judgment_sets}14for judges, judgments in judgment_sets.items():15 ndcg = {ranker: evaluate(run, judgments)["ndcg@10"] for ranker, run in runs.items()}16 for after, before in PLANNED + EXPLORATORY:17 # the interval's level matches the threshold, so each interval and p-value follow one rule18 result, name = compare(ndcg[after], ndcg[before], confidence=1 - threshold), f"{after} minus {before}, {judges}"19 print(f"\n{name}: {result['mean difference']:.3f}\n{name}, permutation p: {result['permutation p']:.3f}")20 # the exploratory comparison gets no t-test, interval or verdict21 if (after, before) in PLANNED:22 print(f"{name}, t-test p: {result['t-test p']:.3f}\n{name}, interval: {result['ci low']:.3f} to {result['ci high']:.3f}")23 checks = verdict(result, threshold)24 established[(judges, after, before)] = checks["established"]25 disagree = [check for check in ["t-test", "interval"] if not checks[f"{check} agrees"]]26 disagreements[judges] += bool(disagree)27 print(f"{name}, established: {'yes' if checks['established'] else 'no'}\n"28 f"{name}, disagrees with the permutation test: {' and '.join(disagree) or 'neither'}")2930print()31for judges, count in disagreements.items():32 print(f"planned comparisons where the t-test or interval disagrees, {judges}: {count}")33for prompt in PROMPTS:34 differ = [pair for pair in PLANNED if established[(f"{prompt} prompt", *pair)] != established[("people", *pair)]]35 print(f"verdicts that differ from people's, {prompt} prompt: {'; '.join(f'{after} minus {before}' for after, before in differ) or 'none'}")
python planned-comparisons-llm-grades.pyplanned comparisons: 3
p-value threshold: 0.0167
interval level: 0.9833
semantic minus bm25, people: 0.105
semantic minus bm25, people, permutation p: 0.001
semantic minus bm25, people, t-test p: 0.003
semantic minus bm25, people, interval: 0.047 to 0.205
semantic minus bm25, people, established: yes
semantic minus bm25, people, disagrees with the permutation test: neither
hybrid minus semantic, people: -0.018
hybrid minus semantic, people, permutation p: 0.125
hybrid minus semantic, people, t-test p: 0.123
hybrid minus semantic, people, interval: -0.048 to 0.006
hybrid minus semantic, people, established: no
hybrid minus semantic, people, disagrees with the permutation test: neither
reranked minus hybrid, people: -0.014
reranked minus hybrid, people, permutation p: 0.382
reranked minus hybrid, people, t-test p: 0.375
reranked minus hybrid, people, interval: -0.053 to 0.020
reranked minus hybrid, people, established: no
reranked minus hybrid, people, disagrees with the permutation test: neither
reranked minus semantic, people: -0.032
reranked minus semantic, people, permutation p: 0.048
semantic minus bm25, short prompt: 0.070
semantic minus bm25, short prompt, permutation p: 0.010
semantic minus bm25, short prompt, t-test p: 0.014
semantic minus bm25, short prompt, interval: 0.016 to 0.146
semantic minus bm25, short prompt, established: yes
semantic minus bm25, short prompt, disagrees with the permutation test: neither
hybrid minus semantic, short prompt: -0.002
hybrid minus semantic, short prompt, permutation p: 0.851
hybrid minus semantic, short prompt, t-test p: 0.861
hybrid minus semantic, short prompt, interval: -0.029 to 0.036
hybrid minus semantic, short prompt, established: no
hybrid minus semantic, short prompt, disagrees with the permutation test: neither
reranked minus hybrid, short prompt: 0.006
reranked minus hybrid, short prompt, permutation p: 0.727
reranked minus hybrid, short prompt, t-test p: 0.714
reranked minus hybrid, short prompt, interval: -0.029 to 0.042
reranked minus hybrid, short prompt, established: no
reranked minus hybrid, short prompt, disagrees with the permutation test: neither
reranked minus semantic, short prompt: 0.003
reranked minus semantic, short prompt, permutation p: 0.847
semantic minus bm25, guidelines prompt: 0.073
semantic minus bm25, guidelines prompt, permutation p: 0.045
semantic minus bm25, guidelines prompt, t-test p: 0.057
semantic minus bm25, guidelines prompt, interval: 0.006 to 0.183
semantic minus bm25, guidelines prompt, established: no
semantic minus bm25, guidelines prompt, disagrees with the permutation test: interval
hybrid minus semantic, guidelines prompt: -0.001
hybrid minus semantic, guidelines prompt, permutation p: 0.929
hybrid minus semantic, guidelines prompt, t-test p: 0.945
hybrid minus semantic, guidelines prompt, interval: -0.045 to 0.037
hybrid minus semantic, guidelines prompt, established: no
hybrid minus semantic, guidelines prompt, disagrees with the permutation test: neither
reranked minus hybrid, guidelines prompt: 0.010
reranked minus hybrid, guidelines prompt, permutation p: 0.657
reranked minus hybrid, guidelines prompt, t-test p: 0.609
reranked minus hybrid, guidelines prompt, interval: -0.024 to 0.076
reranked minus hybrid, guidelines prompt, established: no
reranked minus hybrid, guidelines prompt, disagrees with the permutation test: neither
reranked minus semantic, guidelines prompt: 0.009
reranked minus semantic, guidelines prompt, permutation p: 0.581
planned comparisons where the t-test or interval disagrees, people: 0
planned comparisons where the t-test or interval disagrees, short prompt: 0
planned comparisons where the t-test or interval disagrees, guidelines prompt: 1
verdicts that differ from people's, short prompt: none
verdicts that differ from people's, guidelines prompt: semantic minus bm25
| 指標 | 評価 | 意味検索 − BM25 | ハイブリッド − 意味検索 | リランキング − ハイブリッド |
|---|---|---|---|---|
| 平均差 | 人間 | 0.105 | -0.018 | -0.014 |
| 平均差 | short |
0.070 | -0.002 | 0.006 |
| 平均差 | guidelines |
0.073 | -0.001 | 0.010 |
| 区間 | 人間 | 0.047 to 0.205 | -0.048 to 0.006 | -0.053 to 0.020 |
| 区間 | short |
0.016 to 0.146 | -0.029 to 0.036 | -0.029 to 0.042 |
| 区間 | guidelines |
0.006 to 0.183 | -0.045 to 0.037 | -0.024 to 0.076 |
| 並べ替え検定のp値 | 人間 | 0.001 | 0.125 | 0.382 |
| 並べ替え検定のp値 | short |
0.010 | 0.851 | 0.727 |
| 並べ替え検定のp値 | guidelines |
0.045 | 0.929 | 0.657 |
| t検定のp値 | 人間 | 0.003 | 0.123 | 0.375 |
| t検定のp値 | short |
0.014 | 0.861 | 0.714 |
| t検定のp値 | guidelines |
0.057 | 0.945 | 0.609 |
| 確立 | 人間 | yes | no | no |
| 確立 | short |
yes | no | no |
| 確立 | guidelines |
no | no | no |
ストアで唯一確立された結果がLLMの評価のもとでも残るかどうかは、プロンプトによって決まる。guidelinesのもとでは、人間の判定と異なる判定はsemantic minus bm25であり、これは第3章が確立した唯一の結果である。shortのもとでは、人間の判定と異なる判定はnoneである。
t検定または区間が並べ替え検定と食い違う計画した比較は、人間による評価のもとでは0件、shortのもとでは0件、guidelinesのもとでは1件である。guidelinesのもとでの意味検索 − BM25では、食い違うのはintervalの検査である。
ランカーの順序の比較では、入れ替わった組が二つ見つかった。一つはリランキング付きハイブリッドとハイブリッドの組で、これは計画した比較であり、表からはどの評価のもとでも確立されないことが分かる。もう一つはリランキング付きハイブリッドと意味検索の組で、これが探索的な比較である。人間による評価のもとでは、リランキング付きハイブリッド − 意味検索は-0.032である(並べ替え検定のp値は0.048)。LLMの評価のもとでは、shortで0.003、guidelinesで0.009である。第3章はこの比較をテストの平均を見た後に選んだので、どちらの結果でも何も確立しない。
LLMの審査員は、LLMを用いるランカーを優遇することもある。Balogらは「LLMの審査員がLLMに基づくランカーに対して有意な偏りを示すという初めての実証的証拠」を報告している(Balog et al., 2025)。第1章のランカーはLLMを用いないので、この章ではその偏りを測定できない。本書は、第8章と第9章のLLMに基づくランカーを人間による評価で採点する。
実践ルール: LLMの評価による判定だけを根拠に変更を出荷してはならない。LLMの評価は、判定する価値のある候補を選ぶために用い、決定は人間による評価で行う。二つのプロンプトが異なる判定を出す場合、LLMでは比較に決着をつけられず、人間が決めなければならない。
人手の標本でLLMのスコアを補正する
中間的な方法は、両方の種類の評価を用いるものである。すべてのクエリをLLMで評価し、無作為に選んだクエリの標本を人に判定してもらい、その標本を使ってLLMの誤差を補正する。予測活用推論(prediction-powered inference)は、人手の標本を使ってモデルの予測を厳密に補正する手法であり、その信頼区間は「予測を供給する機械学習アルゴリズムについて何の仮定も置くことなく」成り立つ(Angelopoulos et al., 2023)。平均値に対するこの考え方の単純な形では、全クエリにわたるLLMの平均に、人手の標本における「人の評価からLLMの評価を引いた値」の平均を加える。
corrected = mean over all queries of the LLM score + mean over the human sample of (human score − LLM score)
検索評価では、Oosterhuis らがこの方法で指標の区間を構成しており、「生成された関連度アノテーションは(系統的な)誤差を免れない」と警告している(Oosterhuis et al., 2024)。Takehi らは、予算の範囲内で人に判定させるペアをLLMに選ばせ、その判定でLLMを較正している(Takehi et al., 2025)。
ストアが10 of 30件のテストクエリについて人手の判定を用意できるとする。この例では、その大きさの無作為な集合を2,000回抽出し、それぞれについて、プロンプトごとのLLMの推定値を補正する。対象は第1章のランカーの間の2つの差、すなわち意味検索からBM25を引いた差と、ハイブリッドから意味検索を引いた差である。そして、補正後の各推定値を、人手の標本だけから得られる推定値と比較する。ばらつきとは、抽出を重ねたときの推定値の標準偏差である。このシミュレーションは何も選択しない。
1"""Draws random sets of human-judged test queries and corrects the LLM's estimate of two ranker gaps with each set. The prose's point rests on the 'smaller than the human sample's' lines, read with the correlation lines beside them."""2import numpy as np3import pandas as pd45from lib.agreement import PROMPTS, chapter_one_runs, llm_qrels6from lib.metrics import evaluate7from lib.store import load_products, load_queries, qrels89JUDGED, DRAWS = 10, 2000 # test queries people judge in each draw, and the number of draws10runs = chapter_one_runs(load_products(), load_queries("test"))11people = pd.DataFrame({ranker: evaluate(run, qrels("test"))["ndcg@10"] for ranker, run in runs.items()})12rng = np.random.default_rng(2026)13draws = [rng.choice(people.index, JUDGED, replace=False) for _ in range(DRAWS)] # which queries people judge14print(f"queries judged by people in each draw: {JUDGED} of {len(people)}\ndraws: {DRAWS:,}")1516for after, before in [("semantic", "bm25"), ("hybrid", "semantic")]:17 gap_people = people[after] - people[before] # per-query gaps under people's grades18 print(f"\n{after} minus {before}, people, all queries: {gap_people.mean():.3f}")19 # the spread: the standard deviation over the draws, with numpy's default divisor20 alone = np.std([gap_people[judged].mean() for judged in draws]) # the human sample used alone21 print(f"{after} minus {before}, human sample alone, spread: {alone:.3f}")22 for prompt in PROMPTS:23 llm = {ranker: evaluate(run, llm_qrels(prompt))["ndcg@10"] for ranker, run in runs.items()}24 gap_llm, name = llm[after] - llm[before], f"{after} minus {before}, {prompt} prompt"25 # the LLM's mean over all queries, plus the human sample's average of human minus LLM26 corrected = [gap_llm.mean() + (gap_people[judged] - gap_llm[judged]).mean() for judged in draws]27 print(f"{name}, LLM only: {gap_llm.mean():.3f}")28 print(f"{name}, corrected, mean over draws: {np.mean(corrected):.3f}")29 print(f"{name}, corrected, spread: {np.std(corrected):.3f}")30 print(f"{name}, corrected spread smaller than the human sample's: {'yes' if np.std(corrected) < alone else 'no'}")31 # corrcoef returns a 2×2 matrix; [0, 1] is the correlation between the two lists32 print(f"{name}, correlation of per-query gaps with people's: {np.corrcoef(gap_llm, gap_people)[0, 1]:.3f}")
python correct-llm-scores-with-humans.pyqueries judged by people in each draw: 10 of 30
draws: 2,000
semantic minus bm25, people, all queries: 0.105
semantic minus bm25, human sample alone, spread: 0.045
semantic minus bm25, short prompt, LLM only: 0.070
semantic minus bm25, short prompt, corrected, mean over draws: 0.104
semantic minus bm25, short prompt, corrected, spread: 0.036
semantic minus bm25, short prompt, corrected spread smaller than the human sample's: yes
semantic minus bm25, short prompt, correlation of per-query gaps with people's: 0.641
semantic minus bm25, guidelines prompt, LLM only: 0.073
semantic minus bm25, guidelines prompt, corrected, mean over draws: 0.104
semantic minus bm25, guidelines prompt, corrected, spread: 0.039
semantic minus bm25, guidelines prompt, corrected spread smaller than the human sample's: yes
semantic minus bm25, guidelines prompt, correlation of per-query gaps with people's: 0.692
hybrid minus semantic, people, all queries: -0.018
hybrid minus semantic, human sample alone, spread: 0.016
hybrid minus semantic, short prompt, LLM only: -0.002
hybrid minus semantic, short prompt, corrected, mean over draws: -0.017
hybrid minus semantic, short prompt, corrected, spread: 0.023
hybrid minus semantic, short prompt, corrected spread smaller than the human sample's: no
hybrid minus semantic, short prompt, correlation of per-query gaps with people's: 0.168
hybrid minus semantic, guidelines prompt, LLM only: -0.001
hybrid minus semantic, guidelines prompt, corrected, mean over draws: -0.017
hybrid minus semantic, guidelines prompt, corrected, spread: 0.024
hybrid minus semantic, guidelines prompt, corrected spread smaller than the human sample's: no
hybrid minus semantic, guidelines prompt, correlation of per-query gaps with people's: 0.342
意味検索からBM25を引いた差について、LLMだけによる推定値はshortで0.070であり、人手の評価では0.105である。補正後の推定値は、抽出全体の平均で0.104となり、補正によってLLMの偏りが取り除かれる。
そのばらつきは0.036であり、人手の標本だけの0.045と比べられる。補正後のばらつきは人手の標本のものより小さいか。shortではyes、guidelinesではyesである。LLMによる他のクエリの評価は情報を追加する。クエリごとの差が人手のものと0.641の相関を示すからである。
ハイブリッドから意味検索を引いた差については、補正後のばらつきはshortで0.023、guidelinesで0.024であり、人手の標本だけでは0.016である。人手の標本のものより小さいか。shortではno、guidelinesではnoである。クエリごとの差の相関は、shortのもとで0.168である。
補正はスコアの水準を正すが、不確かさを狭めるのは、LLMのクエリごとのスコアが人のスコアに追随する場合に限られる。ここでは、2つの差のうち差が小さいほうで、その追随が最も弱い。
実践ルール: LLMの評価からスコアを報告するときは常に、無作為に選んだクエリの標本を人に判定してもらい、補正後の推定値を報告する。その標本で、LLMのクエリごとの差が人手の差とどの程度相関するかを確認する。相関が弱い場合は、予算をより多くのクエリの判定に充てる。
本番環境で起こりうる問題
判定器は予告なく変わる。 LLM で判定するストアは、判定を何度も繰り返し実行する。そのため、モデルのバージョン、量子化(モデルの重みを保存する精度)、あるいは言い換えたプロンプトが異なれば、それは別の判定器である。記録の manifest.json には、モデルのダイジェストと両方のプロンプトが一字一句そのまま固定されている。回答スキーマとコンテキスト長は recordings/llm.py と recordings/llm_judgments.py にあるため、これらも記録しておく。これらのいずれかが変わるたびに、同じ人手サンプルで一致度の検証をやり直す。
判定器に合わせて調整したシステムは、その判定器で高く評価される。 Clarke と Dietz は LLM 判定器を悪用するラン(run)を作り、それは「手動評価(28位)よりも自動評価(5位)で有意に高く順位付けされた」(Clarke and Dietz, 2024)。LLM による採点で調整したランカーや、同じ LLM の上に構築したランカーについては、代表スコアを人手の採点で示す必要がある。
商品テキストが判定器を誘導することがある。 Alaofi らは、無関係なテキストに埋め込まれたクエリの語や、そこに書き込まれた指示によって、LLM 判定器が誤誘導されうることを見いだした(Alaofi et al., 2024)。出品者は、判定器に語りかける説明文を書くことができる。すべての評価に人手サンプルを残しておけば、判定器が誤導されたときに一致度の低下として現れる。
テストで較正することは、テストで調整することである。 テストクエリでの人手の採点に合うまでプロンプトを言い換えると、そこでの一致度は意味を失う。プロンプトは訓練クエリで選び、一致度はテストで報告する。
人手の採点もまた真実ではない。 TREC Podcast トラックにおいて、LLM と TREC の評価者の判断が最も食い違った組を、専門家が再判定したところ、LLM の側に付くことのほうが多かったと Mansour らは報告している(Mansour et al., 2026)。人手の採点は、自分で選んだ参照基準として扱い、どちらかを責める前に食い違いの内容を読む。
実践ルール: 判定器を固定し、すべての評価に人手サンプルを残し、何かが変わるたびに一致度を再検証し、調整に用いた判定器でランカーを採点してはならない。
この章で下した決定
後の章で理由が示されない限り、ストアはこれらの決定を維持する。
- すべての主要スコアに人間の評価を用いる。 LLMによる評価は診断用であり、欠けた判定の補完、候補の絞り込み、判定結果の確認に使う。第8章と第9章のLLMベースのランカーは、人間の評価でスコアを付ける。
- 審査役に関する知見はすべて、どのプールのものかを明記する。 カッパ係数と線形重み付きカッパ係数は、観察された一致率とともに、人が判定した学習用ペアで測定し、テスト用プールの判定済みペアについても報告する。ずれの向きと最大の誤差は各プールで読み取り、ランカーのスコアに関わるのは、ランカーの上位10件だけである。
- 2種類のプロンプトを一語一句そのまま記録する。 学習用プールでは両者を区別できないため、ストアは両方を保持し、LLMの評価から導いた結論は、両方のプロンプトが同じ結論を与えたときにだけ信頼する。
- 判定のないペアはLLMの評価で補い、診断として扱う。 人間の判定のみによるスコアと並べて報告する。テスト用クエリでは、補完を行ってもどのランカーの順位も判定結果も変わらない。
- スコアの比較は同じ評価のもとでのみ行う。 同じプールでも、LLMの評価は各ランカーのnDCG@10を同じ量だけ動かすわけでも、同じ向きに動かすわけでもない。そのため、LLMの評価によるスコアを人間の評価によるスコアと比べることはしない。
- タウ係数は入れ替わったペアとともに示し、そのうえで第3章の閾値に基づいて計画した比較を行う。 ランカーが4つの場合、タウ係数は粗い指標にすぎず、判定結果が決め手となる。
- **LLMの評価によるスコアには、それを補正する人間の評価付きクエリの標本と、LLMの評価が不確かさを狭めたかどうかを示す相関を添える。
- この章で示されたこと: LLMの審査役は、欠けた判定の補完と候補の絞り込みには使えるが、その評価がランカーに与える影響は一様ではない。したがって、重要な判定結果には依然として人間の評価が必要である。
この版における本章
第2026.11.10版2026年11月19日時点で例が通過この章の11 例件のうち11件が合格
英語版の書籍(版2026.11.10)から翻訳した。