00-START-HERE · 01-READING-ROUTES · 31_attribution_and_citation · 33_evaluating_generation Purpose: evaluate retrieval coverage and order at the evidence actually consumed, distinguish judged-pool metrics from full-corpus quantities, and validate scalable relevance judges without confusing illustrative costs or macro-F1 with deployment guarantees.
TL;DR
- At a fixed prefix, precision, recall and set- ignore permutations within that prefix. Changing which documents cross the actual context cutoff can change them.
- Report coverage at the consumed evidence slice and rank quality with explicit cutoffs, grades and query averaging. Token packing and truncation may produce a query-dependent depth rather than one fixed .
- MRR uses only the first qualifying hit. nDCG uses discounted gains through its cutoff and a per-query ideal; neither guarantees that all jointly required evidence is present.
- Missing labels require a judgment strategy, not a mathematical workaround. Judging only a retriever’s candidates does not establish full-corpus recall or a complete ideal ranking.
- Separate prompt exemplars, tuning data and held-out human validation. An LLM judge scales a proxy; human checks, unknown-label reporting and version control remain necessary.
- Balanced, boundary-focused exemplars are a strategy to test, not a guarantee of unbiased judgment or higher macro-.
- Inspect confusion counts, per-class recall/precision, macro-, prevalence and action-specific harms. Accuracy can hide rare failures, while macro- is neither accuracy nor prevalence-invariant.
The story
Think of retrieval as the stage crew for a play. The corpus is a prop warehouse and the query is the scene request. A relevance checklist states which props count under a specified rubric. The checklist may be incomplete or disputed; a label is not an infallible certificate. The retriever sends an ordered cart toward the stage. Set metrics inspect the cart after ten slots. They ask how many correct props are somewhere on it. They do not ask where those props sit. A cart with every needed prop in slots 1 through 4 looks identical to one with the same props in slots 7 through 10. The generator is the actor. In this simplified scene it can access only the first five slots. The first cart delivers all four needed props; the second delivers none inside that cutoff. This is a hard-access example, not a claim that language models invariably prefer earlier context or successfully use every accessible passage. MRR resembles a stage manager who stops scoring at the first qualifying prop. It does not score later requirements or differences above its binary threshold. nDCG keeps scoring gains through the cutoff, but its sum still need not capture interactions between props that are useful only together. Now remove the checklist. Humans or models can propose relevance judgments, but checking only the arriving cart cannot reveal every useful prop still hidden in the warehouse. Precision over judged results may be available while full-corpus recall remains unknown. A small human anchor can help validate a scalable judge; it does not complete the relevance set by itself. Rehearsal examples can influence the judge. Under an IID class mixture, eight draws have expected counts and , and about a chance of no minority example. Four examples per class guarantees prompt representation, not correct decisions. Macro- weights class scores equally, but must still be read with the confusion matrix and uncertainty. The evaluation is one pipeline with separate responsibilities: candidate coverage, final ordering and packing, relevance judgments, and judge validation. Use a shared judgment protocol, distinguish unknowns from negatives, and measure action-specific errors. Balanced examples and one aggregate score cannot certify this pipeline.
Decoder table
| Term | Decoder | Why it matters |
|---|---|---|
| Query | One information need being evaluated | Every relevance set and ranked list is tied to a specific query. |
| Query set | All evaluation queries | MRR averages one reciprocal-rank value per query across . |
| Retrieval-Augmented Generation (RAG) | A generator that answers from retrieved evidence | Retrieval metrics must reflect the evidence slice the generator can read. |
| Relevant set | Units labeled relevant to in declared universe | Incomplete qrels are not a certificate of full-corpus relevance |
| Retrieved set | Set of exactly distinct units in the scored prefix | Shorter lists, duplicates and actual token packing need explicit policies |
| Scored rank depth; production packing may yield query-dependent depth | Use the evidence actually consumed, not merely requested | |
| Corpus size | Total documents that could be retrieved | A huge creates overwhelming numbers of true negatives. |
| Relevant units in the fixed scored prefix | Permuting that prefix preserves its hit count | |
| Cardinality of a declared set | Recall requires a positive relevant-set size | |
| Hit count divided by for an exact- prefix | Do not silently use returned-list precision for a short list | |
| Hit count divided by total relevant count in the chosen universe | A judge seeing only top candidates does not identify the corpus denominator | |
| and | Short names for query-level precision and recall | Avoid confusing the recall value with relevant-set notation |
| score at | Harmonic mean, or the equivalent hit-count form | For no hits use zero by the stated convention; undefined recall remains a separate issue |
| Accuracy | Correct positive and negative calls divided by all calls | It is a trap when rare relevant items are swamped by true negatives. |
| True positive (TP) | A relevant item correctly predicted as relevant | It increases both precision and recall. |
| True negative (TN) | An irrelevant item correctly predicted as irrelevant | Its huge count can make retrieval accuracy misleading. |
| False positive (FP) | An irrelevant item predicted as relevant | It lowers precision. |
| False negative (FN) | A relevant item missed by the system | It lowers recall. |
| Set metric | Fixed-prefix membership score | Moving units across the cutoff can change it |
| Rank metric | Position-sensitive objective over a declared prefix | Swapping equal gains or changing later unscored ranks may leave it unchanged |
| Rank-decreasing weight | Less credit for a hit at a lower position | It turns presence into positional usefulness. |
| Top- context cutoff | Evidence slice actually passed downstream | Partial chunks, filtering and serialization can change the slice |
| Context budget | The token capacity available for the query, instructions, and retrieved chunks | It turns rank position into a practical serving constraint. |
| Position bias | Dependence of reader use on position | Need not be a monotone preference for earlier evidence |
| Candidate depth | Depth handed to a pure selecting/reordering stage | Candidate recall bounds final recall only under the same unit and rubric |
| Reranker | A stage that reorders retrieved candidates | It can improve order but cannot recover an absent document. |
| First qualifying rank | First rank meeting the binary threshold; infinity if none | Cutoff RR is zero when that rank is beyond the cutoff |
| Reciprocal first rank within the cutoff, otherwise zero | Do not average only over queries with a hit | |
| Equal-query mean of cutoff RR, including zero-hit terms | Requires a nonempty declared eligible query set | |
| Binarization threshold | Grade cutoff that turns graded relevance into relevant or not relevant | MRR changes if this threshold changes. |
| Graded relevance | A relevance strength such as 0, 1, 2, or 3 | It preserves more information than a binary label. |
| Rank index | The current position while summing a ranked list | It selects both the relevance grade and its discount. |
| Relevance grade | The judged relevance of the document at rank | It supplies the gain term at that position. |
| Cumulative gain (CG) | Sum of declared gains through the cutoff | Linear gain equals the raw grade sum; other gain maps differ |
| Discounted cumulative gain (DCG) | Gain divided by a logarithmic rank discount, summed through the cutoff | Use the same grade-to-gain mapping as IDCG |
| Ideal DCG (IDCG) | Best prefix gain over the common declared judgment universe | Not each system’s own candidate-only optimum |
| Normalized discounted cumulative gain (nDCG) | DCG divided by positive IDCG | Bounded by zero and one under matched nonnegative gains; zero ideal needs a policy |
| Reciprocal Rank Fusion | Per-candidate sum of offset reciprocal ranks across input lists | Not a per-query sum of all relevant-hit reciprocals |
| Microsoft Machine Reading Comprehension (MS MARCO) passage ranking | A benchmark leaderboard that reports in the source | It demonstrates why first-hit position matters. |
| Text Retrieval Conference (TREC) Deep Learning Track | Chapter-reported graded benchmark example | Reproduce official gain, binary threshold, unknown policy and evaluator version |
| TREC pooling | Judgments over a shared pool of diverse retrieved results | New relevant items can remain outside the pool; unjudged is not verified irrelevant |
| Human panel | Task-specific reference raters with an adjudication protocol | Humans can disagree or share biases; disclose uncertainty and evidence scope |
| Query-document pair | One query joined with one candidate passage for labeling | Evaluation cost scales with query count times candidate depth. |
| Relevance rubric | The written rule that defines a relevant label | Humans and automated judges need the same target definition. |
| Gold set | Human-labeled reference cases with separate development/assessment roles | A starting hundred labels is not a statistical adequacy guarantee |
| Large language model (LLM) | A general language model used here to judge relevance from a prompt | It can scale labels after human calibration. |
| Zero-shot judge | Prompted judge without worked examples | Can receive an explicit rubric but still needs validation |
| Few-shot exemplars | Development examples selected for the judge prompt | Keep final validation cases separate; token cost is part of the call |
| In-context learning | Behavior adjustment from prompt examples without retraining | It lets a small gold set guide a much larger evaluation stream. |
| Pseudo- | Judge-positive subset within the assessed pool | Does not automatically supply full-corpus recall or a complete IDCG |
| Judge calibration | Empirical validation/alignment to the intended judgment rubric | Agreement is not the same as calibration of probability scores |
| Recalibration | Repeating a human agreement check on fresh samples | It catches model updates and task drift. |
| Agreement rate | Fraction of labels matching a declared human reference | Can hide minority failures and shared bias; inspect class errors and uncertainty |
| Judge drift | A change in labeling behavior after model or traffic changes | It can look like a retrieval regression without fresh human checks. |
| Trained classifier judge | A supervised model trained on labeled relevance data | It trades up-front label cost for cheap, fast repeated inference. |
| Corrective Retrieval-Augmented Generation (CRAG) evaluator | Fine-tuned T5-large pair scorer, followed by confidence thresholds | Correct/Incorrect/Ambiguous are triggered actions; scores are not guaranteed calibrated probabilities |
| Cosine similarity threshold | A geometric embedding-score decision rule | CRAG instead learns a relevance scorer and thresholds its scores |
| Out-of-distribution risk | Failure when live queries differ from training data | It limits trained judges and motivates separate evaluation slices. |
| Haystack evaluation harness | Existing tooling named for the semi-automatic judge workflow | It shows that the calibration pattern can use established infrastructure. |
| Attribution judgment | Whether specified evidence supports a resolved claim | Not identical to query-document relevance or world truth |
| AttributionBench | Historical binary judge benchmark | A macro score is not an error probability or a model ceiling |
| Class imbalance | One label appears much more often than another | It can inflate accuracy and distort exemplar sampling. |
| Class index | One label in a -class judgment task | It keeps each class’s confusion counts separate. |
| Class count | Number of possible labels | It is the divisor in macro-. |
| True positive for class , | Correct prediction of class | It enters class-specific precision and recall. |
| False positive for class , | Incorrect prediction of class | It lowers precision for class . |
| False negative for class , | Missed example of class | It lowers recall for class . |
| Per-class precision, | Correct class- predictions divided by all class- predictions | It asks how trustworthy that predicted label is. |
| Per-class recall, | Correct class- predictions divided by all true class- examples | It exposes a judge that misses the rare class. |
| Per-class , | Harmonic mean of class- precision and recall | It balances both failure types within one class. |
| Macro- | Equal-weight mean of fixed per-class F1 scores | Not accuracy, error probability or invariant to evaluation prevalence |
| Majority class | The more common label | A judge can guess it and earn misleading accuracy. |
| Minority class | The rarer label | Its recall reveals whether the judge catches uncommon failures. |
| Proportional exemplars | Prompt examples drawn at the gold set’s natural class rate | They can reproduce the existing imbalance. |
| Stratified exemplars | Prompt examples selected with declared class representation | Guarantees representation, not improved held-out performance |
| Boundary exemplar | Example near a meaningful rubric distinction | May help or be ambiguous; keep representative anchors and independent tests |
| Base rate | The natural frequency of each label in a dataset | A prompt can copy this shortcut instead of learning the distinction. |
| Class weighting | One supervised-learning strategy to change class influence | Weighting, resampling and exemplar design all need independent validation |
| Independent and identically distributed draw | Independent draws from the same class mixture | Eight draws at have means and , not fixed counts |
| In-distribution slice | Evaluation data like the exemplar source | Strong performance here may reflect surface-pattern fit. |
| Out-of-distribution slice | Held-out domain different from development data | Tests particular transfer, not proof of a universal learned rule |
| Fine-grained information insensitivity | Missed fine-grained distinctions in a selected prompting-error audit | of selected GPT-3.5 CoT errors, not all fine-tuned deployment errors |
| Information access mismatch | Differences in evidence/context access or annotation scope | in that selected audit; input parity is not a guaranteed cure |
| Concurrency | Number of simultaneous calls | Elapsed time also requires adequate latency, rate/token limits and scheduling |
Core mechanics
Mathematical conventions
Use one declared evaluation unit: a document, passage or deduplicated evidence group. For query , let be the evaluation universe, the binary relevant set, and a ranked prefix of exactly distinct units. Let be its set and . In the basic formulas ; shorter lists require a declared denominator/padding policy. Duplicates must not earn repeated gain merely by occupying more ranks. Recall requires . When no relevant unit is known, distinguish truly unanswerable queries from incomplete judgments; declare an exclusion/zero convention and report their count. For nDCG, fix the grade-to-gain function, logarithmic discount, judgment universe and zero-IDCG policy. For MRR, fix a binary threshold and cutoff. Treat unjudged units as unknown, not proven irrelevant. Averages below give equal weight to each eligible query, not each document pair. Query-weighted and pooled-count metrics differ. Compare systems on the same queries, relevance protocol and source versions; use paired query-level uncertainty analysis when queries are the independent sampling units. Ten thousand pair labels from five hundred queries are not ten thousand independent query outcomes. Keep full precision through all calculations and round only the reported result. Judge agreement, probability calibration, relevance, claim support and answer truth are distinct. Human labels have uncertainty too. Historical results and hand-constructed confusion matrices do not prove a prompted-model ceiling or an exemplar strategy’s causal effect. Cost examples exclude unspecified overhead and require their stated price, token and scheduling assumptions.
32.1 Set metrics vs rank metrics
What it measures
Fix query and the conventions above. Define and as precision and recall, reserving for the relevant set. The formulas assume exactly distinct returned units and positive relevant-set size where recall is used:
For a no-hit prefix with and , set using the count form; the literal harmonic-mean expression is . Recall is undefined when unless an explicit reporting convention is imposed. A truly empty prediction list also has undefined ordinary precision; that is not the same situation as a nonempty prefix with zero hits. With fewer than results, fixed- precision pads missing positions as nonrelevant, whereas returned-list precision divides by the actual returned count. Name the convention. Query averaging also matters. One query with one of one relevant item recovered and another with zero of one hundred gives mean query recall , but pooled-count recall . Do not change the weighting silently. Plain accuracy is:
As a deliberately misleading corpus-wide binary classification metric, mark every unretrieved document negative. With and four relevant documents, retrieving nothing gives , and :
The decimal is exact for these integer counts. The original source’s is not the same value. This all-negative classifier has zero recall, and empty-list precision needs its own convention; high corpus accuracy does not imply useful retrieval. True negatives dominate this corpus-wide classification construction. Accuracy can still be informative for a relevance judge on a declared labeled population, but it must be interpreted with prevalence and class errors rather than treated as retrieval success. At a fixed cutoff, these set metrics depend only on , and . Permuting the same prefix preserves them. Moving a relevant document across the cutoff changes the prefix and can change the metrics; “order-blind” does not mean cutoff-independent. Rank metrics score positions within a declared cutoff. Reciprocal rank awards only to the first qualifying hit. DCG sums gain times through rank . Swapping equal-gain items, or changing ranks after a metric has stopped scoring, need not change a rank-aware metric.
Why it matters
A production prompt is limited by tokens and serialization, not necessarily a fixed number of documents. Measure the final packed evidence after filtering, deduplication and truncation; record partial chunks and per-query depth. Relevance does not guarantee successful reader use, and position effects need not decrease monotonically from the start of context. The worked example fixes four relevant chunks and a ten-document result set. System A puts the four hits at ranks 1 through 4. System B puts the same four hits at ranks 7 through 10. At , both systems score:
For this toy, use a -token total budget and exactly five complete -token chunks: chunk tokens leave for the question, instructions, delimiters and any reserved output. Whether that is feasible depends on the actual tokenizer and request layout; it is not a measured universal “4k prompt” configuration. At , System A has precision and recall one; System B has both zero. At depth ten, their first-hit reciprocal ranks are:
The chapter’s historical MS MARCO passage-ranking example reports MRR@10, illustrating a first-hit objective rather than set accuracy. Benchmark relevance definitions, pooling and official evaluator versions are part of that result; it is not a universal objective for every RAG task.
Failure without it
A dashboard using only set metrics at depth ten calls these two orders a tie, while their set metrics at the actual five-item cutoff already distinguish them. Rank metrics add information within a fixed prefix; the wrong cutoff is a separate measurement error. An accuracy dashboard can reward a retriever that returns nothing. A pure reranker that only selects/reorders candidates cannot recover an absent unit. If its output set with , then . Thus candidate recall bounds final recall under the same unit and relevance definition. Query expansion, additional search or generated evidence changes that assumption. A single number therefore cannot establish that a retriever change helped downstream use.
Cost and decision rules
Once prefix labels, relevant-set size and IDCG are available, hit counts, first hit and DCG can be accumulated in one prefix pass. Obtaining valid labels and the ideal normalizer may cost much more. A shared candidate pool improves consistency, but a pool missing relevant units does not supply a full-corpus denominator.
- Evaluate the evidence actually consumed, including token packing and per-query cutoffs. Curves over depth or token budget remain useful for diagnosis even after an operating point is fixed.
- Pair coverage with an appropriate rank metric and a downstream task check. A rank-aware automated judge still requires validation and an explicit target.
- Do not use all-corpus accuracy to approve retrieval. For judge accuracy, disclose the evaluated class mixture, class errors and costs; a deliberately balanced test is not the only permissible population.
- Compare systems against shared, versioned judgments and a sufficiently broad pool. Labeling each system’s own output separately can create different denominators and selection bias.
- Measure candidate recall and final-prefix quality separately, even in a simple pipeline. Report no-answer cases, unjudged results, uncertainty and the limits of the labeled universe.
32.2 MRR, nDCG, and derived
What MRR measures
For each query, let be the first rank whose grade meets the declared binary threshold, and let when there is no such unit. The recall function remains . The cutoff version is:
For a nonempty eligible query set , MRR@k averages one term per query, including zero-hit queries:
MRR stops scoring after the first qualifying document. It ignores later hits and distinctions among grades that meet the same threshold. It also gives no credit for a hit below its cutoff. Do not average only over successful queries; that changes the metric. For one query with hits at ranks one and ten, is not MRR; the reciprocal-rank term is one. Nor is an arbitrary sum of all relevant-hit reciprocals automatically Reciprocal Rank Fusion. RRF assigns each candidate a score such as across input lists containing , with a declared offset . It is a different, per-candidate fusion operation.
What nDCG measures
Use illustrative grades under an explicit rubric. Fix a nonnegative gain function with . This chapter’s worked numbers use linear gain ; another common choice is . Different gains change values and potentially system comparisons; use the same choice in DCG and IDCG. Cumulative gain sums the grades:
CG uses grades but ignores permutations of the same prefix. DCG adds the logarithmic rank discount:
The plus one keeps rank 1 undiscounted:
The discount weight is , not the denominator itself. It is one at rank one; the denominators at ranks two and ten are about and . For integer ranks it decays more slowly than after rank one. This is a chosen utility model, not a measurement that a generator uses evidence according to that exact law. Let be grades sorted in descending order over the declared evaluation universe, not merely the current retriever’s candidates. Using the same gain and cutoff gives
If there are fewer than units, pad the ideal list with zero gains under the declared policy. Incomplete qrels supply an ideal over known judgments, not a certified corpus-wide optimum. Dividing by each system’s own candidate-only ideal can hide retrieval failures and make comparisons inconsistent.
With nonnegative gains, the same discount and an ideal covering all evaluated units, the score lies in . A value of one means optimal gain through this cutoff, possibly under many tied orders; it says nothing about later ranks or full recall. When IDCG is zero, the ratio is undefined. Choose and report a zero/exclusion convention and the affected query count, rather than silently dropping failures or asserting every query is normalizable.
Why the three metrics disagree
There are exactly two positive-grade documents in the declared universe: A has grade three and B grade one. All others have grade zero. Use , linear gain and, initially, binary threshold for recall and MRR. Configuration X puts B at rank 1 and A at rank 4. Configuration Y puts A at rank 1 and B at rank 4. At threshold one, both have RR@10 equal to one and recall@10 equal to one. For a one-query set, the MRR values also tie. If relevance instead requires grade at least two, X’s first qualifying hit is at rank four and Y’s at rank one, giving versus one. The claimed tie depends on the threshold. For Configuration X:
For Configuration Y:
The ideal order puts A at rank 1 and B at rank 2:
The normalized scores are:
The difference, calculated before rounding, is approximately nDCG units. These are ratio scores, not probabilities of a correct answer. The displayed three-decimal summaries are and , with gap about ; do not use rounded DCG/IDCG as if they were exact inputs. The chapter uses TREC Deep Learning’s graded judgments and nDCG@10 as a historical benchmark example. Reproduce a benchmark with its official grade mapping, gain function, unjudged policy and evaluator; the linear-gain worked toy is not a claim that every official scorer uses this exact convention.
Failure without it
MRR can equal one when the first hit is present but two of three jointly required supporting chunks are absent. Per-item relevance metrics do not fully describe evidence complementarity, redundancy or whether a complete support set survives packing. Add a task-specific all-required-evidence or answerability check where needed. With graded data, MRR also ignores how strong its first qualifying hit is. That limitation depends on the chosen threshold; it is not correct to claim that every positive-grade hit must count under every benchmark’s binary relevance rule. CG has the same order blindness as a set sum. Raw DCG depends on available gains and grades, as well as rank. Per-query normalization supports a declared cross-query aggregation but does not make tasks identical. Report which eligible queries are averaged and whether the aggregate is equally query-weighted. nDCG does penalize missing high-gain items when the common ideal includes them; it is not purely ordering within the returned set. But nDCG alone does not establish full recall. With three equal relevant items and , a relevant first hit gives nDCG@1 equal to one and recall@1 equal to . Separately, if only a grade-one candidate is retrieved while a grade-three source is absent, candidate-only nDCG@1 is one but full-universe linear-gain nDCG@1 is . These are different denominators.
Cost and decision rules
With prefix grades and a precomputed normalizer, MRR and DCG are linear-time prefix reductions. Computing IDCG requires knowing the relevant grades over the chosen universe and selecting/sorting their best prefix; it is not obtained just by reordering one system’s results. The harder cost may be judgment completeness and agreement, not summing the formulas.
- Choose rank and coverage metrics from the task. nDCG handles graded utility but does not by itself guarantee complete multi-hop evidence; MRR is suitable for a declared first-hit objective.
- Fix binary thresholds, gain functions, discount, cutoff, duplicate handling and query weighting before comparing releases. Report any change in these definitions.
- Score the actual consumed slice and useful depth/token-budget curves. A good deep score need not imply a good shallow prefix.
- Measure both candidate-depth coverage and final-prefix coverage where both matter; candidate recall is not final recall.
- Use shared per-query IDCG over a declared judgment universe. Do not normalize by a global constant or by each system’s own result list. Report incomplete/unjudged cases and zero-IDCG handling.
32.3 Evaluating without ground truth
What changes when is missing
A metric needs the labels it actually uses. Precision at a fixed prefix needs that prefix’s binary labels; MRR@k needs qualifying-hit labels through . Full-corpus recall additionally needs the total relevant-set size. nDCG needs a graded ideal over a declared universe. Without adequate judgments these target quantities cannot be evaluated exactly, although partial, pooled or estimated metrics can be reported with their limits. One of three sources must supply labels:
- Humans label query-document pairs using a rubric, with adjudication and uncertainty where needed.
- A prompted LLM proposes labels or grades, checked against independent human judgments.
- A trained classifier supplies a validated proxy, with training-data and distribution-shift limitations. Implicit feedback or other weak labels are additional proxies, not automatic replacements for relevance judgments. Binary labels are insufficient to reproduce an arbitrary graded nDCG target. Humans provide task-specific reference judgments, not error-free truth. Expertise, ambiguity, source access, time budget and inter-rater disagreement matter. Reusing a stable judgment pool can avoid relabeling unchanged pairs every release, but new results, changed content and rubric changes require maintenance. A zero-shot judge can receive a fully explicit rubric without worked examples; zero-shot does not necessarily mean an unstated standard. Without validation, however, its application of that rubric remains unverified. Mere entity mention may be inadequate when the task requires answering the query or supplying a particular kind of evidence. A small human set helps develop the rubric and select examples, but does not automatically fix judge error. Separate prompt exemplars and tuning cases from locked held-out validation; shared queries, documents and near-duplicates can leak information across splits. Fresh human checks measure drift and disagreements, with enough minority/graded cases for the intended claim. CRAG fine-tunes a T5-large retrieval evaluator to score each question-document pair. The original paper uses positive/negative training targets and , with inference scores in , then upper/lower thresholds to trigger Correct, Incorrect or Ambiguous actions. At list level, a high-scoring document can trigger Correct; all scores below the lower threshold trigger Incorrect; other cases are Ambiguous. This is not an embedding cosine threshold or simply a direct three-class gold-label predictor. Its score is not automatically a calibrated probability.[1]
Why calibration matters
A validated judge can amortize human supervision, while remaining a fallible proxy. Check relevance decisions at the intended granularity, evidence scope, domain and class mixture; a good claim-support judge is not automatically a good query-document relevance judge. The default pipeline has four steps:
- Define the unit, relevance rubric, grade scale, evidence scope and treatment of unknowns.
- Label a starting human set—roughly one hundred pairs is a workflow suggestion, not a statistical guarantee—and separate development from held-out assessment.
- Select a bounded exemplar set from development data; fix the judge model, prompt, parsing and grade mapping.
- Judge a shared, appropriately broad candidate pool and validate on held-out/fresh human cases. Record error types, uncertainty, unjudged coverage and version changes. The judge’s positive labels form a pseudo-relevant set only within the assessed universe. If it sees only the top twenty returned items and labels one relevant, dividing that hit by that one known positive gives pool recall one. The same observed labels are compatible with nine additional relevant corpus items never judged, in which case corpus recall is . More labels on the same selected cart do not identify the unseen denominator. Pool across diverse systems, add targeted or probability-sampled assessment where appropriate, and report any completeness assumptions. Sampling weights and uncertainty are needed for design-based corpus estimates. The chapter names Haystack’s evaluation tooling as one possible harness. Tool choice does not establish human agreement, complete qrels, unbiased pooling or a calibrated probability model; those are evaluation-design responsibilities.
Worked cost example
For a one-system illustrative pass, take held-out queries and exactly twenty distinct candidates per query. This produces pair-judgment occurrences, not a complete set of relevance judgments for the corpus:
For a comparison, judge a shared union of candidates; its size need not remain ten thousand. Deduplication and cached labels may reduce calls, while adjudication and changed content can add work. The following budget assumes ten thousand fresh, one-call pairs each pass. For one human judgment per pair, assume two judgments per minute, or per rater-hour. Training raters, agreement checks and adjudication are excluded:
At a hypothetical per rater-hour, retaining full precision:
One rater requires approximately eight-hour workdays. Ten equally productive parallel raters require about hours of ideal elapsed labeling time, not total rater-hours. Coordination and adjudication add time. In a separate short-pair LLM toy, assume total input tokens—including the query, passage, instructions, delimiters and chosen exemplars—and twenty output tokens per call. This is not the earlier -token-chunk prompt. Prices are hypothetical: per million input tokens and per million output tokens. If the actual few-shot layout does not fit, increase the input budget rather than omit it from the bill.
Ten thousand calls process input and output tokens. Their generation bill is:
Assume fixed one-second service per call, fifty available slots, adequate rate/token limits and negligible overhead. Then ideal batched elapsed service is:
Fifty calls per second requires about input and output tokens per second under this layout; concurrency alone does not supply that throughput. A human sample of one hundred pairs at the same pace takes fifty minutes, or rater-hour, costing . Split its development and held-out uses appropriately; its size does not certify judge quality. Across ten fresh passes, the human-only labeling bill is , with rater-hours. This assumes unchanged throughput, ten thousand new judgments each pass and no label reuse. For the LLM path, explicitly collect one hundred human labels before pass one and refresh with another hundred before passes four, seven and ten: four samples total. Keep sample uses independent of held-out scoring. The ten-pass bill is
Using the rounded sample price gives , but that is not the full-precision result. Machine service totals minutes. The four samples add human minutes; with one rater and serial service, combined work is minutes, or about hours. “Under one hour” describes machine service alone, not this human-inclusive serial workflow. Parallel human work or pre-existing labels can change elapsed time, but not eliminate labor. The one-pass human/LLM token-bill ratio is about , but the ten-pass ratio including these four human samples is only . Ideal one-pass elapsed ratios are with one human rater and with ten raters; neither is a universal latency claim. Thus “three orders of magnitude in total cost and latency” does not describe every ledger above. If extra input tokens per call were omitted from the -token layout, the same price adds per ten-thousand-call pass. For , generation rises from to . All budgets still omit rubric development, expert adjudication, judge selection, retries, infrastructure and resulting error costs, and do not establish equal label quality. Pooling diverse top-ranked results is a practical benchmark strategy, not proof of exhaustive relevance coverage. New systems can find relevant unjudged items outside an older pool. Maintain and audit qrels, and distinguish an unjudged-as-zero scoring convention from a verified negative label.
Failure without it
A judge with no held-out agreement and error analysis produces an unvalidated proxy, whether zero-shot or few-shot. Agreement alone can also be high when both judge and reference share a bias or one class dominates. Judge model/prompt changes and traffic shifts can change scores even if retrieval is unchanged. Pin and log versions, retain comparable labeled cases, and use fresh checks; no fixed recalibration interval guarantees stability. Retraining a retriever against disputed or adaptively optimized judge labels can fit proxy errors. Keep independent human evaluation and avoid reusing a public tuning pool as the sole release test. A trained classifier can fail after a domain shift even when it was reliable on its training distribution.
Cost and decision rules
- Start with an explicit rubric and independent validation. One hundred labels is a planning suggestion, not a prevalence-free accuracy guarantee; rare classes or many domains can need much more.
- Separate exemplar selection, prompt/model tuning and final assessment. Retain representative easy cases as well as useful boundary cases; audit grade agreement for graded metrics.
- Validate after judge changes and monitor drift using risk-appropriate fresh samples. A pinned model does not freeze the query/source distribution.
- Compare prompted and trained judges on actual latency, total cost, error types and domain transfer. Neither architecture is restricted to one mandatory serving/evaluation role.
- Use human adjudication where stakes or disagreement warrant it. Reuse sound stable labels, expand pools for new results, and do not call top-candidate pseudo-recall full-corpus recall.
- Set gates from uncertainty and action-specific harm, not raw agreement alone. If a gate fails, diagnose rubric, evidence, prompt or model problems before trusting proxy improvements.
32.4 Judge design, class balance, and macro-
What accuracy hides
The following claim-support judge is a separate illustrative task: it labels a generated claim against its cited passage. Query-document retrieval relevance can require a different rubric or graded labels; transferring this judge is a hypothesis to validate, not an identity between tasks. On a -attributable population, an always-attributable judge has exactly accuracy and zero recall for non-attributable cases. With the two classes fixed and zero unsupported-class F1, its macro- is , not . A mostly-positive judge need not have those exact counts, so inspect its actual confusion matrix. Accuracy pools both classes:
For each class in a declared fixed class set, compute one-versus-rest counts. Precision and recall require positive denominators; declare a convention when no cases are predicted or present. The count form of F1 avoids a spurious when both computed precision and recall are zero:
Then it gives every class equal weight:
With two fixed classes, the class represented by twenty cases counts equally in the macro average to the one with one hundred eighty. But class precision depends on prevalence, so macro- is not invariant to the evaluation base rate. Identical class recalls give macro- on balanced labels but about at a mixture. Report per-class counts and the actual evaluation population, not just an equal-weight average. AttributionBench reports a historical fine-tuned GPT-3.5 result near binary macro-. That is not an error probability of one in five, a present-day ceiling or a mathematical limit for few-shot prompts. For example, counts give macro- but accuracy . A prompted result above a published reference requires a fair independent evaluation, not automatic distrust solely because it exceeds that number.[2]
Why exemplar balance matters
Prompt construction chooses the exemplar distribution; it does not choose the class balance of independently sampled evaluation traffic. Prompt examples may shift the judge’s label prior or threshold, but a behavioral effect must be measured rather than assumed. For eight IID draws with minority probability , let . Then and the majority expectation is , not a guaranteed seven-to-one draw. Moreover,
Sampling without replacement from exactly one hundred eighty majority and twenty minority examples is hypergeometric instead, with zero-minority probability . Do not substitute an IID probability as an exact finite-population result. Selecting four exemplars per class guarantees representation in that eight-example prompt. Boundary cases can reveal distinctions, while representative easy cases can anchor the rubric. Neither balancing nor hard examples guarantees better classification, removes every shortcut or calibrates production probabilities. Validate selection and ordering on independent data, and preserve the intended evaluation base rate. The original AttributionBench error audit examined selected GPT-3.5 chain-of-thought prompting errors, not three hundred errors from the separately fine-tuned system. It reports fine-grained information insensitivity, including missed nuance and inference problems. The selection uses up to fifty errors per dataset and class balancing for several sets; these are not unbiased production error proportions.[2] A further is information-access mismatch, including evidence/context differences and possible label issues. If support is scored only against the generator’s snippet, adding unseen full-page evidence changes the target rather than proving that the snippet supported the claim. Align authorized evidence and annotation scope, repair labels where justified, and measure whether an intervention actually reduces errors; access parity does not guarantee a cure.[2] The benchmark uses four in-distribution and three held-out out-of-distribution datasets. This tests particular transfers; success does not prove that a system learned a general rule rather than shortcuts, or cover every future shift.[2]
Worked class-balance example
Use the same held-out triples for both hand-constructed configurations: attributable and twenty non-attributable. Rows are true labels and columns predictions, each ordered as attributable , then non-attributable :
These are stipulated outcome counts, not measured results or predictions derived from the exemplar ratios. Their values illustrate metric behavior. They do not establish that stratifying examples caused the difference or that a published macro score bounds either configuration. Configuration 1 uses seven attributable exemplars and one non-attributable exemplar. The judge correctly calls 171 of 180 attributable pairs. It correctly calls 6 of 20 non-attributable pairs. The recalls are and . It predicts 185 cases as attributable. That total is 171 correct calls plus 14 missed non-attributable cases. It predicts 15 as non-attributable. That total is 6 correct calls plus 9 missed attributable cases.
The accuracy coexists with only recall for unsupported cases: fourteen of twenty broken citations are falsely accepted. The macro average exposes a class problem but does not by itself quantify its harm or set a safe action threshold. Configuration 2 uses four exemplars from each class. Configuration two correctly labels of attributable cases and fifteen of twenty non-attributable ones. Recalls are exactly and . It predicts 170 cases as attributable. That total is 165 correct calls plus 5 missed non-attributable cases. It predicts 30 as non-attributable. That total is 15 correct calls plus 15 missed attributable cases.
Computed before rounding, the macro change is approximately score units, or points on a percent-scaled score. The three-decimal summaries are and , not . Accuracy increases percentage points, from to . Majority recall falls about points while minority recall rises points; false accepts fall from fourteen to five, while false rejections rise from nine to fifteen. Twenty minority cases leave substantial sampling uncertainty. Under an IID within-class Bernoulli illustration, nominal Wilson intervals for recall are about for six of twenty and for fifteen of twenty. These are separate recall intervals, not an interval or paired significance test for the change. Aggregate confusion matrices do not identify which individual predictions changed. Use paired item-level or query-clustered comparisons, depending on sampling, and account for prompt selection on development data. A historical result is neither a ceiling nor a substitute for this analysis.
Failure without it
Accuracy can approve a judge that misses every minority-class case. Proportional prompt sampling can underrepresent a rare class; balanced sampling can shift other behavior too. Evaluate the resulting confusion matrix and production harm rather than assuming that one prompt ratio must win. Boundary examples can teach useful distinctions but may be ambiguous or unrepresentative. Include clear anchors, adjudicate uncertain labels, and keep the release test separate from the cases used to select prompts. The interview scenario stipulates a macro- drop from in distribution to on a new domain while new-domain accuracy is . The macro difference is seventeen score points, not a relative loss. Because the domains and possibly their prevalence differ, inspect per-class rates, samples and costs; the numbers alone do not identify the cause or a universal shipping rule. If necessary evidence is absent, examples alone cannot reveal its specific missing contents reliably. But access mismatch can also involve ambiguity, scope or labels; a fuller input is not a guaranteed fix. Decide whether the intended target is snippet faithfulness or broader external verification before changing evidence.
Cost and decision rules
The attribution-judge example supplies no end-to-end serving bill. Balanced selection, adjudication, prompt-token length, validation and error costs belong in its budget; one judge’s macro score is not a production correctness or risk estimate.
- Report class counts, precision/recall, macro-, accuracy, prevalence and uncertainty. Choose release gates from action-specific false accepts/rejections and harm, not a universally sufficient headline score.
- Test balanced and boundary-focused exemplars while retaining representative anchors. Trained models can use weighting or resampling, but these are alternatives to validate, not guaranteed replacements for good examples or data.
- Hold out prompt/model selection from the release test. Do not reject a sound independent result merely because it exceeds a historical reference score.
- Validate relevant domain and traffic slices and monitor future shift, even for a presently narrow domain. No finite OOD set proves general robustness.
- A macro score in the sixties can motivate investigation, not an automatic diagnosis that the prompt alone is wrong. Check evidence, rubric, human disagreement, domain shift and minority errors before deciding the remedy.
Diagrams
Figure 32.1
| Rank | System A | System B | Inside top-5 generator cutoff |
|---|---|---|---|
| 1 | — | Yes | |
| 2 | — | Yes | |
| 3 | — | Yes | |
| 4 | — | Yes | |
| 5 | — | — | Yes |
| 6 | — | — | No |
| 7 | — | No | |
| 8 | — | No | |
| 9 | — | No | |
| 10 | — | No |
Figure : The same four relevant units occur in each ten-item list. Set metrics at ten tie, but recall at the consumed five-item prefix is one for A and zero for B. RR@10 is one versus ; RR@5 is one versus zero. This is a fixed-size hard-access toy, not a general token-packing or reader-use guarantee.
Figure 32.2
| Metric view | Rank 1 | Rank 2 | Rank 3 | Rank 4 | Rank 5 | Rank 6 | Rank 7 | Rank 8 | Rank 9 | Rank 10 | Result |
|---|---|---|---|---|---|---|---|---|---|---|---|
| , threshold | Grade 1 | — | — | Grade 3; not scored | — | — | — | — | — | — | |
| Linear-gain | Grade 1 | — | — | Grade 3 | — | — | — | — | — | — |
Figure : For configuration X, binary threshold one makes RR@10 equal to one; it ignores the grade-three hit at rank four. Linear-gain DCG includes that hit. Its value about is DCG, not nDCG; division by the shared ideal gives nDCG about . At threshold two, RR@10 instead equals .
Figure 32.3
Diagram description and source
flowchart TB
A["Human rubric and development labels"] --> B["Choose bounded exemplars; pin judge and prompt"]
B --> C["Judge a shared pool; unjudged corpus remains unknown"]
C --> D["Scoped proxy metrics, not automatic full-corpus recall"]
H["Separate held-out human labels; grades and minority cases"] --> V["Validate errors, uncertainty and drift"]
C --> V
V -. "Fresh checks; tune only on development data" .-> A
Figure : Human development labels and held-out validation have different roles. Automated labels scale the assessed pool, not its completeness. The starting one-hundred-pair budget is a workflow illustration, not a guarantee of valid graded metrics or a statistically adequate rare-class audit.
Figure 32.4
Diagram description and source
flowchart LR
A1["Evaluation population: 180 attributable, 20 non-attributable"] --> A2["Example prompt: 7 majority and 1 minority"]
A2 --> A3["Stipulated counts: 171, 9, 14, 6"]
A3 --> A4["Macro-F1 0.639922; minority recall 0.30"]
B1["Same evaluation population; do not rebalance test traffic silently"] --> B2["Example prompt: 4 per class"]
B2 --> B3["Stipulated counts: 165, 15, 5, 15"]
B3 --> B4["Macro-F1 0.771429; minority recall 0.75"]
A4 --> V["Illustrative comparison, not a causal experiment or ceiling"]
B4 --> V
Figure : The constructed matrices illustrate how class errors affect macro- and accuracy. They are not predictions deduced from prompt balance. Eight IID draws at a rate have expectations and ; a specific seven-to-one prompt is one possible draw. Four-per-class selection guarantees representation, not higher held-out quality. Compute from exact counts before rounding; configuration two rounds to .
Whiteboard pack
Drawing order
- Declare the query universe, relevance unit, unknown labels and binary/graded rubric.
- Draw a candidate list and the actual token-packed slice, with fixed only for the toy.
- Write set metrics and their zero/short-list conventions; distinguish query means from pooled counts.
- Show four hits at ranks one to four versus seven to ten, then score both at ten and five.
- Define RR@k, MRR@k, gain, DCG and a shared per-query IDCG, including zero-IDCG handling.
- Show how candidate-only normalization can conceal missing evidence and how perfect shallow nDCG can coexist with low recall.
- Separate human development examples from held-out judge validation; leave unjudged corpus items unknown.
- Write both exact confusion matrices, minority errors and macro-, without claiming prompt balance caused the difference.
- Finish with machine-token cost, human calibration labor and uncertainty as separate ledger lines.
Spoken script
First declare relevance and the evidence actually consumed. Set metrics describe overlap at a cutoff; rank metrics describe selected positional utility. MRR stops at the first qualifying hit. nDCG sums gains and divides by a shared per-query ideal, but does not certify complete support. Missing judgments remain unknown: labeling only retrieved candidates cannot identify corpus recall. A human-validated judge can scale a pooled proxy, with separate prompt-development and held-out cases. Check class errors, uncertainty and action costs rather than accuracy or macro-F1 alone. Balanced exemplars are worth testing, not a guarantee. Include human calibration labor before claiming large cost or latency savings.
Interview traps
1. Two retrievers have identical and . Which one ships?
The two depth-ten set numbers do not decide. At ten, both have precision , recall one and . At the consumed five-item prefix, A has recall one and B zero; their RR@5 values are one and zero. RR@10 is one versus . Check the final token-packed evidence, rank quality, downstream task success and uncertainty before shipping; a fixed-prefix toy does not decide every production trade-off.
2. Derive recall, MRR, and nDCG instead of quoting them.
Recall divides prefix hits by the total relevant count in a declared universe, when positive. RR@k is the reciprocal first qualifying rank if within , otherwise zero; MRR averages over all eligible queries including failures. DCG sums a fixed nonnegative gain over , and nDCG divides by the same gain’s per-query ideal when positive. Declare thresholds, gains, unknowns, zero-IDCG and query weighting. Perfect nDCG through a short cutoff does not prove complete or joint evidence coverage.
3. There is no ground-truth relevant set. Can retrieval still be evaluated?
Yes, but specify what can be measured. Human or automated judgments can label a pool; held-out human validation is needed before treating model labels as a useful proxy. Top-result labels alone do not establish the full recall denominator or corpus-wide ideal. In the separate ten-thousand-call cost toy, one human pass is about rater-hours and ; the LLM token bill is and ideal service seconds. Across ten passes plus four human samples, the LLM path is about and hours of serial combined work—not an all-in under-one-hour guarantee or matched label-quality result.
4. A judge reaches accuracy on a gold set. Do you ship it?
Do not ship from accuracy alone. A majority-only judge already earns accuracy. On a -case population with positives, accuracy could mean all positives correct but only two of twenty negatives detected: minority recall . Request the confusion matrix, class metrics, independent validation and action-specific risk. The constructed prompt comparison gives macro- versus , not proof of a causal benefit or a universal ceiling. Missing evidence or changed scope needs diagnosis, not merely more examples.
5. The reranking team says it can fix retrieval order. Does retrieval-stage evaluation still matter?
Yes. For a pure subset/reordering stage, final relevant hits cannot exceed candidate relevant hits under the same unit/rubric. Evaluate candidate recall, final consumed-prefix recall and rank quality separately, against common judgments. A reranker-only ideal must not be substituted for a corpus/pooled ideal when claiming end-to-end quality. Additional retrieval changes the candidate boundary; incomplete qrels limit any claimed ceiling.
Key numbers
| Topic | Value or explicit assumption | Meaning and limits |
|---|---|---|
| Accuracy trap | , ; exact | All-negative corpus classification has zero recall; source decimal corrected |
| Set-ranking example | Four relevant units at one–four versus seven–ten | Same ten-item set, different prefixes |
| Set metrics | , | ; both orders tie |
| Production cutoff | A recall one, B recall zero; RR@5 also one versus zero | |
| Prompt slice | chunk tokens | total leaves for all other reserved positions; toy only |
| Reciprocal rank | versus | At five, B has zero reciprocal rank rather than one seventh |
| False MRR calculation | Not MRR and not automatically RRF; one query contributes only its first hit | |
| Relevance scale | Grades | Toy uses linear gains; declare the rubric and mapping |
| MRR threshold examples | Thresholds or | X/Y RR@10 tie at threshold one, but are versus one at threshold two |
| Log discounts | ; denominators, not discount weights | |
| Graded example | Grades one and three exchanged between ranks one and four | At cutoff ten, MRR and recall tie only under the stated binary threshold |
| DCG | versus | Linear DCG computed before rounding |
| IDCG | Common linear-gain ideal: grade three then grade one | |
| nDCG | versus | Difference nDCG units, not answer probabilities |
| nDCG range | when IDCG is positive | Matched nonnegative gains/universe required; zero ideal needs an explicit policy |
| Multi-hop warning | Three required chunks with two absent | MRR@1 and nDCG@1 can both be one while recall@1 is |
| Dashboard prompt | MRR to | A score-unit rise alone does not establish better coverage or generation |
| Human gold anchor | Roughly one hundred starting human labels | Development/held-out separation required; no universal adequacy guarantee |
| Production evaluation | pair occurrences | Top-result labels do not complete corpus relevance judgments |
| Human throughput | judgments per rater-hour | rater-hours per ten-thousand-judgment pass |
| Human rate | per rater-hour | Full-precision one-pass bill |
| Human wall time | eight-hour days, one rater | Ten parallel raters need ideal elapsed hours, not that total labor |
| LLM prompt | input, twenty output tokens | Includes all prompt/exemplar positions in this separate short-pair toy |
| LLM prices | input, output per million | Hypothetical rates, not verified current provider prices |
| LLM call cost | per call | token bill per ten-thousand-call pass; not total evaluation cost |
| LLM concurrency | Fifty slots, one-second calls; | Ideal service assumes sufficient request/token limits and negligible overhead |
| Calibration cost | labels; rater-hour | per sample before rounding |
| Ten human passes | ; rater-hours | Ten fresh human passes with no label reuse |
| Ten LLM passes | ; machine minutes | Four human samples add minutes; combined serial work is about hours |
| Scaling gap | About versus | One-pass token-only cost ratio versus ten-pass ratio including calibration; not one universal scaling gap |
| Disagreement probe | observed disagreement in the source scenario | Inspect denominator, uncertainty, class mix, evidence and labels before retraining |
| Accuracy scene | accuracy on a -positive set | On two hundred cases, it could catch only two of twenty minority failures |
| AttributionBench result | About binary macro- | Historical fine-tuned result; not one-in-five error probability or prompted ceiling |
| Error analysis | selected prompting errors | fine-grained, access mismatch; not a random fine-tuned deployment audit |
| Dataset slices | Four ID and three held-out OOD datasets | Tests those transfers, not proof of universal rule learning |
| Gold class split | attributable, twenty non-attributable | Fixed 200-case evaluation mixture, separate from prompt selection |
| Proportional prompt | Seven majority and one minority exemplar | Stipulated configuration, not the exact expectation of eight IID draws |
| Stratified prompt | Four exemplars per class | Guaranteed prompt representation, not guaranteed minority recall |
| Proportional calls | , | , ; macro about , accuracy |
| Stratified calls | , | , ; macro , accuracy |
| Majority recall trade | to | Majority recall falls about points in the constructed matrices |
| Minority recall gain | to | Minority recall rises 45 points; the causal effect of prompt balance is unmeasured |
| Prompt-rework signal | A macro score in the sixties | Investigate rubric, data, evidence and action risk; not a universal prompt-only rework rule |
| Out-of-distribution probe | to macro; OOD accuracy | Stipulated seventeen-point shift, not seventeen-percent relative loss; diagnose class/traffic changes |
00-START-HERE · 01-READING-ROUTES · 31_attribution_and_citation · 33_evaluating_generation