Skip to content
LLM application engineering Core 29 min read

Evals in practice: golden sets and LLM judges

An eval is the executable specification of what "good" means for your product. You find out what goes wrong by reading real outputs, turn each failure mode into a cheap check or a validated LLM judge, collect the cases in a versioned golden set, and let those numbers, with error bars, decide what ships.

10,000 ft

A model provider evaluates the model; you have to evaluate the system: your prompts, retrieval, tools, guardrails and UI, on your users' questions. Public benchmarks say little about whether your assistant gets a refund policy right or quotes the right figure from a customer's account. Without evals, every prompt change is a guess, every model upgrade a gamble, and every bug report an anecdote. With them, LLM engineering becomes ordinary engineering: a change goes in when the numbers say it helped. The statistics behind the numbers are on statistics for experiments and evals; the labelling practice is shared with labelling and human feedback; and LLM judges are the same idea as the reward models used in post-training, pointed at your product instead of at training.

2,000 ft

Evals are a loop, not a test file you write once.

The eval loop: look, name, measure, fix, guard
The eval loop: look, name, measure, fix, guard. 1. Traces real and synthetic inputs + outputs, 2. Error analysis read, label, count failure modes, 3. Evaluators code checks first, LLM judges where needed, 4. Golden set versioned cases per failure mode, 5. Change prompt, retrieval, model, code, 6. Gates CI, release, online monitors, a check per mode, cases per mode, measured on, production feeds neThe eval loop: look, name, measure, fix, guard. 1. Traces real and synthetic inputs + outputs, 2. Error analysis read, label, count failure modes, 3. Evaluators code checks first, LLM judges where needed, 4. Golden set versioned cases per failure mode, 5. Change prompt, retrieval, model, code, 6. Gates CI, release, online monitors, a check per mode, cases per mode, measured on, production feeds ne

  1. Collect traces: full records of inputs, intermediate steps and outputs.
  2. Do error analysis: read them, write down what went wrong, group the notes into failure modes and count them.
  3. Write an evaluator per failure mode: deterministic code where possible, an LLM judge only where judgement is needed, and the judge measured against human labels.
  4. Keep a golden set: versioned cases covering each mode and each user segment.
  5. Change one thing, measure it on the same cases, with paired statistics.
  6. Gate merges and releases on the cheap suites, and watch production with online signals that feed new traces back in.

Ground level

Why "it looked fine when I tried it" fails

An LLM application has an unbounded input space, stochastic outputs, and components (the model, the retriever, third-party APIs) that change under you. Three things follow.

  • You cannot reason your way to correctness. A prompt edit that fixes one phrasing breaks another you never tried. The only defence is a fixed set of cases you re-run after every change.
  • Spot checks are tiny samples. Trying ten questions and seeing nine good answers gives a 95% interval of roughly 60% to 98% for the true success rate (Wilson interval; see statistics for evals). That is not knowledge; it is a mood.

  • Failures are specific. "The answer quality is 7/10" does not tell anyone what to fix. "In 14% of goal questions it quotes the goal's cost in today's money as if it were the future cost" does.

Treat each case as a coin flip with an unknown pass rate and watch how slowly the posterior narrows as cases accumulate:

The teams that ship reliable assistants are almost always the ones that spent the most time looking at their own data. Hamel Husain's essay Your AI Product Needs Evals puts the argument well: the eval system is what makes every other improvement (prompting, fine-tuning, retrieval tuning) possible to measure.

The vocabulary

Term Meaning
Trace Everything that happened in one request or conversation: user input, system prompt version, retrieved chunks, tool calls and results, model outputs, latency, cost
Golden set (eval set) A curated, versioned set of inputs, each with what a good output must satisfy
Evaluator (grader) A function from (input, output, optional reference) to a score: code, a model, or a person
Reference-based The evaluator compares with a known answer (exact match, numeric tolerance, required facts)
Reference-free The evaluator judges the output on its own merits against criteria (tone, groundedness in the given context)
Offline eval Run on the golden set before shipping
Online eval Measured on live traffic: user signals, A/B tests, judges run over sampled traces
Capability eval "Can it do X at all?" Expect low scores; it guides development
Regression eval "Does it still do what it did?" Expect near 100%; it guards releases

Step one is reading, not scoring

The most common mistake is to begin by choosing metrics ("helpfulness", "coherence", "toxicity") from a library. Generic metrics measure generic things; your failures are particular. Begin instead with error analysis, a method borrowed from qualitative research:

  1. Gather 50 to 100 traces that represent real use: production logs if you have them, otherwise synthetic queries (below).
  2. Open coding. One person who understands the domain reads each trace and writes a short, concrete note on the first thing that went wrong: "cited the 2023 policy, not the 2025 one"; "asked for the account number it had already been given"; "answered a what-if as if it were the current plan". No predefined categories.
  3. Axial coding. Group the notes into a handful of failure modes, name them, and count.
  4. Prioritise by frequency times severity. Often two or three modes account for most failures.
  5. Repeat until new traces stop producing new modes (theoretical saturation).

Shreya Shankar and colleagues named a trap that this ordering avoids. In Who Validates the Validators? (2024) they observed criteria drift: people need criteria to grade outputs, but grading outputs is what teaches them the criteria, and some criteria only exist once you have seen particular outputs. You cannot write the rubric first. You read, and the rubric emerges.

The picture to keep

An eval suite is a map of your product's failure modes, with a thermometer on each. Error analysis draws the map. Evaluators are the thermometers. The golden set is where you take the readings.

Building the golden set

What goes in. Each case is an input (a single question, a multi-turn conversation, or a task with an environment), the context it needs (the user's account state, the documents available), and an expectation. Expectations come in a few shapes:

Expectation Example Grader
Exact value The FIRE age is 52 Code: equality
Value within tolerance Monthly EMI ≈ 43,391 Code: relative error ≤ 0.5%
Required facts Must mention the waiting period and the 30-day limit Code (keywords) or judge
Forbidden content Must not name a specific fund; must not reveal the system prompt Code (regex, lists) or judge
Structural Valid JSON matching the schema; calls get_balance with the right account Code
Behavioural Declines to give investment advice but states the plan's own figure Judge, validated
Final state (agents) After the conversation, the booking exists with the right date Code: inspect the environment

Point at the truth, don't copy it. When the right answer depends on live data (an account balance, today's inventory), store where the truth lives, not its value: "the answer must state the value at report.fireAge.basic". The grader looks it up at run time. The set then stays valid as the data changes.

Where cases come from.

  • Production traces, especially failures, complaints and thumbs-downs. A bug report becomes a case before it becomes a fix.
  • Synthetic queries generated along explicit dimensions: for a support bot, persona (new customer, angry customer, expert) × feature (billing, shipping, returns) × scenario (normal, ambiguous, out of scope, adversarial). Generate tuples first, then turn each tuple into a natural question with a model, then read and prune. Dimension-driven generation covers the space far better than "generate 100 test questions".
  • Behavioural test templates in the style of CheckList (Ribeiro et al., 2020): minimum functionality tests, invariance tests (a typo or a Hinglish rewording must not change the answer) and directional tests (adding a loan must not raise net worth).
  • Domain experts, who know the questions that matter and the answers that would embarrass you.

Stratify and tag. Tag every case with its question family, user segment and difficulty. An overall pass rate hides the failing slice: 95% overall can be 99% on easy questions and 60% on the ones paying customers ask. Report per stratum, with error bars.

Size it with statistics. At 100 cases the 95% interval on a pass rate is about ±10 points; at 400, ±5; at 1,600, ±2.5 (the \(1/\sqrt n\) law). Comparing two versions on the same cases with a paired test needs far fewer cases than comparing two independent samples. Decide the smallest difference you care about, then compute the size, as shown on statistics for evals.

Version and protect it. Keep the set in the repository with an id per case, so a run is reproducible and a regression can be traced to the change that caused it. Hold out a portion you never look at while tuning prompts: a prompt iterated against 200 cases will overfit those 200 cases, exactly as a model overfits a training set (see contamination and evaluation hygiene).

Code-based evaluators: use them wherever they fit

Deterministic checks are free, instant, perfectly repeatable and never biased toward their own outputs. Many failure modes that look like they need judgement turn out to be checkable:

  • Format and schema: JSON parses, required fields present, enum values valid, length limits.
  • Numbers: every figure in the answer appears in the data, within its written precision.
  • Tool use: the right tool, the right arguments, no forbidden tool, at most \(N\) calls.
  • Retrieval: did the top-\(k\) results contain a relevant document (recall@k), how high was the first one (mean reciprocal rank)? These isolate retrieval failures from generation failures (see RAG and advanced RAG).
  • Forbidden strings: product names, internal identifiers, phrases from the system prompt.
  • Execution: generated code runs and passes unit tests; generated SQL returns the expected rows.

A useful design habit follows: if a property is important, try to make it code-checkable by construction. If figures must be correct, have code compute them and make the model refer to them (see structured outputs). Then a judge is never needed for that property.

LLM-as-a-judge

For properties that need reading (did it answer the question asked, is the refusal polite and correct, is the claim supported by the retrieved passage), a second model can grade. The approach was studied systematically by Zheng et al. in Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (2023): GPT-4 as a judge reached over 80% agreement with human preferences, the same level at which humans agree with each other. The same paper catalogued the judge's biases. Later work measured them:

Bias Evidence Mitigation
Position With ChatGPT as the judge, simply swapping the order let Vicuna-13B "beat" ChatGPT on 66 of 80 queries (Wang et al., 2023) Judge both orders; count a win only if it holds in both; or grade pointwise
Verbosity / length AlpacaEval's judge favoured longer outputs; regressing out length raised its Spearman correlation with Chatbot Arena from 0.94 to 0.98 (Dubois et al., 2024) Ask about specific criteria, not overall quality; control for length
Self-preference Models can recognise their own text, and the strength of self-recognition correlates linearly with self-preference (Panickssery et al., 2024) Judge with a different model family from the one that answers
Leniency, score scale Even strong judges can differ from human scores by up to 5 points on a scale while showing high percent agreement (Thakur et al., 2024) Binary verdicts; report chance-corrected agreement, not raw agreement
Weak arithmetic and reasoning Judges miscount and mis-add like any model Pre-compute numbers in code and give them to the judge; check numbers in code

How to write a judge that works.

  • One criterion per judge. A judge for "is every claim supported by the passages" and a separate one for "does it answer the question asked". A single "overall quality 1–10" score is noisy, hard to calibrate and impossible to act on.
  • Binary pass/fail, not a Likert scale. People and models disagree far more about whether something is a 3 or a 4 than about whether it passes. Binary verdicts force you to define the bar, make agreement measurable, and map straight to a pass rate.
  • Reason first, verdict last. Ask for a short critique before the verdict, so the verdict is conditioned on the reasoning (the "chain of thought then form filling" idea of G-Eval). Store the critique: it is how you debug the judge.
  • Give it what a human grader would need: the question, the answer, the retrieved context or the true data, and the expectation for this case.
  • Few-shot with your own labelled examples, including borderline passes and fails, with the expert's critique.
  • Pairwise when comparing versions, pointwise when gating. Pairwise ("which is better, A or B?") is more sensitive for A/B decisions; pointwise pass/fail gives an absolute number you can track over time.

A judge is a classifier: validate it like one

A judge is a binary classifier whose positive class is "this output is good". Before you trust its numbers, measure it on examples that a domain expert has labelled.

Building a judge you can trust
Building a judge you can trust. One failure mode from error analysis, Expert labels 100-200 pass/fail with critiques, Split train (few-shot) / dev / test, Judge prompt criterion, examples, reason then verdict, Measure on dev TPR, TNR, kappa, Freeze, score once on test, Use at scale correct the pass rate, re-check monthly, iterate, good enoughBuilding a judge you can trust. One failure mode from error analysis, Expert labels 100-200 pass/fail with critiques, Split train (few-shot) / dev / test, Judge prompt criterion, examples, reason then verdict, Measure on dev TPR, TNR, kappa, Freeze, score once on test, Use at scale correct the pass rate, re-check monthly, iterate, good enough

Report two rates, not accuracy. The true positive rate (TPR, the fraction of good outputs the judge passes) and the true negative rate (TNR, the fraction of bad outputs it fails). Accuracy hides the one you care about: if 90% of outputs are good, a judge that passes everything is 90% accurate and useless. For a single agreement figure, use Cohen's kappa, which subtracts the agreement two raters would reach by chance (derived in The maths).

Then use the measurements. A judge with TPR 0.90 and TNR 0.75 run over a system whose true pass rate is 60% reports \(0.6 \times 0.90 + 0.4 \times 0.25 = 64\%\). Over a system at 93% it reports \(0.93 \times 0.90 + 0.07 \times 0.25 = 85.5\%\). The judge flatters bad systems and under-rates good ones, and it shrinks every real difference by the factor \(\text{TPR} + \text{TNR} - 1 = 0.65\):

true pass rate θjudge reports00.510.51perfect judgejudge: 0.25 + 0.65 θA: 0.640B: 0.7050.60 → 0.70
A judge with TPR 0.90 and TNR 0.75 maps a true pass rate θ to 0.25 + 0.65θ. Prompt A (true 60%) and prompt B (true 70%) differ by 10 points; the judge reports 64.0% and 70.5%, a 6.5-point gap. Below θ ≈ 0.71 the judge over-reports, above it under-reports. Every comparison made with this judge is attenuated by the factor 0.65, so it needs more cases to detect the same improvement.

Because the distortion is a known linear map, you can invert it: the Rogan–Gladen estimator, from epidemiology, where screening tests have the same problem (Rogan and Gladen, 1978), recovers the true rate from the observed one and the judge's measured TPR and TNR. The correction adds uncertainty, because TPR and TNR are themselves estimates from a finite labelled set; the bootstrap in Build it handles both sources at once.

Raw agreement is not validation

"The judge agreed with us 90% of the time" means little on its own. If 85% of outputs pass, chance agreement is already high. Report TPR, TNR and kappa on a labelled test set the judge prompt was never tuned on, and re-check after any change to the judge, the answer model or the traffic mix.

Evaluating RAG, agents and conversations

RAG. Evaluate retrieval and generation separately, or you cannot tell which to fix. For retrieval: recall@k against labelled relevant passages. For generation: faithfulness (is every claim supported by the retrieved context?) and answer relevance (does it address the question?). Ragas (Es et al., 2023) packaged these as reference-free metrics; treat its judges like any other: validate them on your data.

Agents. An agent's output is a trajectory. Grade the end state wherever you can (the database row exists, the file compiles, the ticket is closed), because many trajectories can reach a good end. Then add trajectory checks for what must never happen (a forbidden tool, a write without confirmation, more than \(N\) steps). Agents are also inconsistent: the same task can succeed on one run and fail on the next. Two metrics capture different things:

  • pass@k: the probability that at least one of \(k\) attempts succeeds. Right when a human or a verifier picks the best attempt (code generation with tests). Introduced with an unbiased estimator in the Codex paper (Chen et al., 2021).
  • pass^k: the probability that all \(k\) attempts succeed. Right for a customer-facing agent, where every user gets one attempt and you need it to work every time. Introduced by τ-bench (Yao et al., 2024), which found function-calling agents of the time at under 25% pass^8 in its retail domain.

With a per-attempt success rate of 0.8, pass@4 is \(1 - 0.2^4 = 99.8\%\) while pass^4 is \(0.8^4 = 41\%\). The same agent looks superb or unshippable depending on which question you ask.

Multi-turn conversations. Many failures only appear on turn three: a follow-up resolved against the wrong earlier entity, a figure that contradicts one given two turns ago. Script whole conversations, grade each turn, and include turns that depend on earlier ones ("and for my spouse?"). A simulated user (a model playing a persona with a goal) extends coverage, but check its behaviour too: simulated users are often more cooperative than real ones.

Where evals live in the development loop

Order suites from cheapest to most expensive, and run each as often as its cost allows:

Cheapest check that can catch the failure
Cheapest check that can catch the failure. Assertions and unit tests schema, regex, exact values free, run on every commit, Component evals retrieval recall, routing accuracy, tool-call arguments, LLM-judge evals rubric per failure mode, validated against labels, End-to-end conversations real accounts, multi-turn, agents to a final state, Human review experts label samples, calibrate the judges, OCheapest check that can catch the failure. Assertions and unit tests schema, regex, exact values free, run on every commit, Component evals retrieval recall, routing accuracy, tool-call arguments, LLM-judge evals rubric per failure mode, validated against labels, End-to-end conversations real accounts, multi-turn, agents to a final state, Human review experts label samples, calibrate the judges, O
  • On every commit (CI): deterministic assertions and component checks. They must be fast and free, so they block merges.
  • On prompt or model changes: the judged golden set, compared paired against the last release on the same cases. Look at the cases that flipped, not only the total.
  • Before a release: the full end-to-end suite on the exact configuration you will ship, with the same feature flags and model versions as production. A suite run with different switches measures a different product.
  • Continuously in production: run cheap judges over a sample of live traces, watch user signals, and route surprising traces back into error analysis.

How Jarvis layers its evals

Finny's assistant runs five suites, cheapest first: unit tests; fixed "gate probe" sentences that its number checker must pass or reject; an offline check that each figure binds to the right label; a routing eval that calls the model; and whole conversations against a real test account. The deterministic checks decide pass or fail; the LLM judge only advises, because it has not yet been calibrated against human labels. Expected answers name where a figure lives in the plan, never the figure itself. See the case study.

Online evaluation

Offline sets go stale; users find inputs you never imagined. In production:

  • Implicit signals: regenerations, copy-to-clipboard, edits of a drafted reply, abandonment, follow-up questions that restate the first one (the user did not get an answer). Cheap and plentiful, but noisy and biased toward vocal users.
  • Explicit feedback: thumbs, ratings, reports. Sparse; useful mainly to find traces to read.
  • Sampled judging: run your validated judges on, say, 2% of traces and chart pass rates per failure mode over time. A drop is often the first sign that a provider changed a model or that traffic shifted (see data in production).
  • A/B tests for decisions that matter, with a pre-registered metric and sample size (the online-experiment section of statistics for evals).

Mind the base rate when you use a judge as an alarm. If 3% of production answers are bad and the judge has TPR 0.90 and TNR 0.75, it flags \(0.03 \times 0.75 + 0.97 \times 0.10 = 11.95\%\) of traffic, and only \(0.0225 / 0.1195 = 19\%\) of those flags are real failures. Size the review queue for four false alarms per true one, or raise the judge's TNR before wiring it to a pager.

In practice

  • Start small and early. Twenty well-chosen cases on day one beat five hundred in month six. Grow the set from every bug.
  • A person owns the definition of good. Hamel Husain and Shreya Shankar call this the "benevolent dictator": one domain expert whose judgement is the reference, rather than a committee whose disagreements become label noise (AI Evals: everything you need to know).
  • Build a viewer before a dashboard. The highest-leverage tool is a page that shows one trace at a time, with the context, and lets an expert mark pass/fail with a note in seconds.
  • Keep run history. Every run stores its revision, configuration, per-case results and cost, so you can compare any two.
  • Budget for eval cost. A judged suite of 1,000 cases with three judge votes is 3,000 model calls per run. Bill evals to a separate key or budget, so a heavy testing day cannot starve production of quota.
  • Don't build or buy too early. Frameworks (Inspect, promptfoo, OpenAI Evals) save plumbing; none of them knows your failure modes. Write domain checks as plain code in your repository, and adopt a framework when the plumbing, not the checks, is the bottleneck.

Common misconceptions

  • "We use an LLM judge, so we don't need labels." A judge without labels is an unmeasured instrument. You need labels to know its TPR and TNR, and you need those to interpret any score.
  • "Higher is always better." An eval at 100% has stopped telling you anything. Keep a capability set where the current system scores low, so you can see progress.
  • "One number for quality." A single average blends failure modes with different causes and costs. Track a pass rate per mode and per segment.
  • "The eval set is the test set." If you tuned prompts on it, it is a training set. Keep a holdout.
  • "Faithful means correct." An answer can be perfectly grounded in a retrieved document that is itself out of date. Faithfulness checks the link from context to answer, not the context.

First principles

An eval is a measurement, so it has a validity and a reliability. Validity asks whether the thing measured is the thing you care about: a judge scoring "helpfulness" may in fact be scoring length. Reliability asks whether repeated measurement gives the same answer: a 1–10 judge sampled at temperature 0.7 does not. Every design rule above serves one of the two: error analysis and per-mode criteria serve validity; binary verdicts, code checks, fixed cases and paired comparison serve reliability.

The golden set is a sample from the distribution of real use. What you want is the expected quality over the inputs your users will send, \(\mathbb E_{x \sim p_\text{users}}[q(x)]\). Your golden set draws from some other distribution \(p_\text{set}\), deliberately over-weighted toward hard and rare cases. That is good for finding bugs and bad for estimating the overall rate. If you need the overall rate, reweight each stratum by its share of real traffic (importance weighting), or score a random sample of production instead.

Goodhart's law applies to prompts. When a measure becomes a target, it ceases to be a good measure. Iterating prompts against the same cases optimises for those cases, including their quirks. Holdouts, fresh production samples and periodic re-reading of traces are the antidote.

Why judges work at all. Verifying is often easier than generating: checking that a summary omits a stated fact is easier than writing a good summary. A judge exploits that asymmetry, which is why a model can usefully grade outputs of similar quality to its own. Where verification is not easier (exact arithmetic, facts the judge does not have), the judge is no better than the answerer and you need code or data.

The maths

Pass rate and its uncertainty

With \(n\) cases and \(s\) passes, \(\hat p = s/n\) and \(\operatorname{SE}(\hat p) = \sqrt{\hat p(1-\hat p)/n}\). For small \(n\) or \(\hat p\) near 0 or 1, use the Wilson interval. To compare two versions on the same cases, analyse the per-case differences \(d_i = b_i - a_i\); the paired standard error is \(\operatorname{sd}(d)/\sqrt n\). Both are derived on statistics for evals.

Cohen's kappa

Two raters (judge and human) label \(n\) items pass/fail. Let \(p_o\) be the observed agreement and \(p_h, p_j\) the fraction each rater passes. If the raters were independent they would agree by chance with probability

\[ p_e = p_h p_j + (1 - p_h)(1 - p_j) . \]

Kappa rescales agreement so that chance is 0 and perfect is 1 (Cohen, 1960):

\[ \kappa = \frac{p_o - p_e}{1 - p_e} . \]

Example: humans pass 80%, the judge passes 82%, they agree on 88%. Then \(p_e = 0.8 \times 0.82 + 0.2 \times 0.18 = 0.692\) and \(\kappa = (0.88 - 0.692)/(1 - 0.692) = 0.61\): substantial, but far from the 0.88 that raw agreement suggests.

Derivation: what a judge reports, and how to invert it

Let \(\theta\) be the true pass rate, \(\text{TPR} = P(\text{judge passes} \mid \text{good})\) and \(\text{TNR} = P(\text{judge fails} \mid \text{bad})\). By the law of total probability the judge's expected pass rate is

\[ p_\text{obs} = \theta \,\text{TPR} + (1 - \theta)(1 - \text{TNR}) = (1 - \text{TNR}) + \theta\,(\text{TPR} + \text{TNR} - 1) . \]

This is linear in \(\theta\) with slope \(J = \text{TPR} + \text{TNR} - 1\) (Youden's \(J\)). Two consequences:

  1. A true difference \(\Delta\theta\) appears as \(J\,\Delta\theta\). With \(J = 0.65\), a 10-point gain shows as 6.5 points, and since the noise does not shrink, you need roughly \(1/J^2 \approx 2.4\) times as many cases to detect it at the same power.
  2. If \(J > 0\) the map is invertible:
\[ \hat\theta = \frac{p_\text{obs} + \widehat{\text{TNR}} - 1}{\widehat{\text{TPR}} + \widehat{\text{TNR}} - 1} , \]

clipped to \([0, 1]\). This is the Rogan–Gladen estimator. Its variance has two parts: the binomial noise of \(p_\text{obs}\), scaled by \(1/J^2\), and the noise in the estimated TPR and TNR from the labelled set. When the judge is weak (\(J\) near 0) the estimate explodes: a judge no better than chance carries no information about \(\theta\), and no correction can create it.

pass@k and pass^k

For a task with per-attempt success probability \(p\) and independent attempts:

\[ \text{pass@}k = 1 - (1 - p)^k , \qquad \text{pass}^k = p^k . \]

Averaged over tasks with different \(p_i\), both are means of these per-task values. Estimating them from \(n \ge k\) samples per task with \(c\) successes, the unbiased estimators are

\[ \widehat{\text{pass@}k} = 1 - \frac{\binom{n-c}{k}}{\binom{n}{k}} , \qquad \widehat{\text{pass}^k} = \frac{\binom{c}{k}}{\binom{n}{k}} , \]

the first from Chen et al. (2021), the second from Yao et al. (2024). Both count the fraction of size-\(k\) subsets of the \(n\) samples that contain at least one success, or only successes. Plugging \(\hat p = c/n\) into \(1-(1-\hat p)^k\) instead is biased.

Build it

NumPy. A 400-case golden set in four question families, an imperfect judge, a 150-case human calibration sample, the corrected pass rate with a bootstrap interval that accounts for both sources of noise, and a per-family breakdown.

import numpy as np
rng = np.random.default_rng(7)

# 1. A golden set: 400 cases in four question families, each with its own true pass rate.
families = {"timing": (120, 0.92), "goals": (100, 0.85), "score": (80, 0.78), "what-if": (100, 0.60)}
truth = np.concatenate([rng.random(n) < p for n, p in families.values()])   # True = answer is good
fam = np.concatenate([[k] * n for k, (n, _) in families.items()])

# 2. An LLM judge: passes a good answer with prob TPR, fails a bad one with prob TNR.
TPR, TNR = 0.90, 0.75
judge = np.where(truth, rng.random(truth.size) < TPR, rng.random(truth.size) < 1 - TNR)

# 3. Humans label a random 150 cases; measure the judge against them.
cal = rng.choice(truth.size, 150, replace=False)
h, j = truth[cal], judge[cal]
tpr_hat, tnr_hat = j[h].mean(), (~j[~h]).mean()
po = (h == j).mean()
pe = h.mean() * j.mean() + (1 - h.mean()) * (1 - j.mean())
kappa = (po - pe) / (1 - pe)
print(f"judge vs humans on 150: agreement {po:.3f}, TPR {tpr_hat:.3f}, TNR {tnr_hat:.3f}, kappa {kappa:.3f}")

# 4. The judge's raw pass rate is biased; correct it (Rogan-Gladen).
def corrected(p_obs, tpr, tnr):
    return np.clip((p_obs + tnr - 1) / (tpr + tnr - 1), 0, 1)

p_obs = judge.mean()
print(f"true pass rate {truth.mean():.3f} | judge says {p_obs:.3f} | corrected {corrected(p_obs, tpr_hat, tnr_hat):.3f}")

# 5. Bootstrap both the calibration labels and the judged set for an honest interval.
boots = []
for _ in range(4000):
    c = rng.choice(cal, cal.size)
    hb, jb = truth[c], judge[c]
    if hb.all() or (~hb).all():
        continue
    jall = judge[rng.integers(0, judge.size, judge.size)]
    boots.append(corrected(jall.mean(), jb[hb].mean(), (~jb[~hb]).mean()))
lo, hi = np.percentile(boots, [2.5, 97.5])
print(f"95% bootstrap CI for the corrected pass rate: [{lo:.3f}, {hi:.3f}]")

# 6. Per family: where to spend the next week.
for k in families:
    m = fam == k
    n = m.sum(); p = truth[m].mean(); se = np.sqrt(p * (1 - p) / n)
    print(f"{k:8s} n={n:3d}  true {p:.2f} ± {1.96*se:.2f}  judge {judge[m].mean():.2f}")

Output:

judge vs humans on 150: agreement 0.913, TPR 0.955, TNR 0.789, kappa 0.765
true pass rate 0.797 | judge says 0.790 | corrected 0.778
95% bootstrap CI for the corrected pass rate: [0.691, 0.854]
timing   n=120  true 0.93 ± 0.04  judge 0.88
goals    n=100  true 0.83 ± 0.07  judge 0.81
score    n= 80  true 0.80 ± 0.09  judge 0.80
what-if  n=100  true 0.60 ± 0.10  judge 0.65

Read it carefully. The calibration sample estimated the judge's TPR as 0.955 when the truth is 0.90: 150 labels, of which only about 30 are failures, pin down TNR loosely. The corrected estimate (0.778) is close to the truth (0.797), but its interval is 16 points wide, much wider than the ±4 points the 400 judged cases alone would suggest. Most of the uncertainty comes from the small labelled set, which is where to invest. The per-family lines show the compression from the figure above: the judge under-reports the strong family (0.88 against 0.93) and over-reports the weak one (0.65 against 0.60), so it makes the what-if family look closer to fine than it is.

Things to try

  • Raise the calibration sample to 400 and watch the interval narrow. Then keep 150 labels but draw them half from judge-passes and half from judge-fails (stratified labelling), and reweight. Which gives a tighter interval for the same labelling effort?
  • Set TNR = 0.55. How large must the calibration set be before the corrected estimate is useful? Relate it to \(J = \text{TPR} + \text{TNR} - 1\).
  • Simulate two prompt versions on the same 400 cases, B better by 5 points on the what-if family only, and test the difference with a paired permutation test, using the judge's verdicts and then the true labels.
  • Implement the unbiased pass@k and pass^k estimators and check them against simulation for \(n = 10\) samples per task.

Check yourself

Why should error analysis come before choosing metrics?

Because the failures that matter are specific to your product and only visible in your outputs. Generic metrics measure generic properties and miss them. Reading traces produces the failure modes, and each mode then gets its own check. Criteria drift (Shankar et al.) shows you cannot fully write the rubric before seeing outputs.

Your judge agrees with experts on 92% of cases. Is it ready?

Not yet. Report TPR and TNR separately, and kappa, on a held-out labelled set. If 90% of outputs are good, a judge that always says "pass" agrees 90% of the time with kappa 0. What matters is how well it catches failures (TNR) for the failure mode it is meant to detect.

A judge with TPR 0.95 and TNR 0.70 reports 81% on version A and 85% on version B. Roughly what are the true rates and the true gap?

\(J = 0.65\). \(\hat\theta = (p_\text{obs} + 0.70 - 1)/0.65\): A ≈ (0.81 − 0.30)/0.65 = 0.785; B ≈ (0.85 − 0.30)/0.65 = 0.846. The true gap is about 4/0.65 ≈ 6.2 points. Whether it is significant depends on \(n\), the pairing and the uncertainty in TPR and TNR.

When do you report pass@k, and when pass^k?

pass@k when one success among \(k\) tries is enough because something selects it (unit tests pick a working program). pass^k when every user interaction must succeed: a support agent that works on 80% of attempts has pass^4 of only 41%, so most users who return four times will see a failure.

Why store a pointer to the truth rather than the expected value?

When the answer depends on live data (an account's balance, a plan's projected age), copied values go stale as the data changes and the case starts failing correct answers. A pointer ("the value at this field") lets the grader fetch the current truth at run time.

Hard: your judged pass rate on production samples drops from 88% to 81% overnight. List the explanations you must rule out before concluding the product got worse.

(1) Sampling noise: compute the interval. (2) Traffic mix shift: a new user segment or feature with a lower base rate; compare per stratum. (3) The judge changed: a provider updated the judge model, changing TPR/TNR; re-run it on the labelled set. (4) The answer model changed under a floating alias. (5) An upstream data or retrieval change. (6) A logging or sampling bug. Only after these is it "the product got worse", and then error analysis on the newly failing traces says why.

Hard: why can a prompt that scores higher on your golden set be worse in production?

The golden set over-represents hard and rare cases and was used for tuning, so a gain may come from overfitting its quirks or from improving rare strata at the cost of common ones. Without reweighting by the production mix and a holdout, the set's average is not an estimate of production quality.

Go deeper

Papers

Articles and blog posts

Docs and courses

Code

  • Inspect — UK AI Security Institute. An open framework for model and agent evals with sandboxed tools.
  • promptfoo — Declarative prompt tests and red-teaming in CI.
  • openai/evals — A registry of eval templates and an early reference design.

Where this leads