Evals: The Differentiator
Error analysis, golden sets, LLM judges and CI gates.
Chapter after chapter, a decision has ended the same way: measure it. Which chunk size, whether to add a reranker, whether to fine-tune, whether the new model is better. This chapter is about the measuring. An evaluation, or eval, is a test of behavior: fixed inputs, a way of grading what comes back, and a number you can compare from one version to the next.
It covers where test cases come from, what grades them, how many you need, how far to trust a model that grades another model, and how to put all of it in the path of every change. One experiment measures real overlap metrics. The others are simulations, because their subject is the arithmetic of a test suite: comparing versions, correcting a judge, and running an unchanged system two hundred times.
23.1The missing test suite
A dependency that is random, changes without notice and fails fluently needs tests of behavior.
Ordinary code has a chain of checks between a change and the people who use it. A language model feature has a gap in the middle of that chain.
Three properties of the dependency make the gap dangerous, and each was met earlier in this guide.
- It samples. The same input can produce a different output on the next call (section 2.6), so one good result proves little.
- It changes underneath you. Providers update models behind the same name (section 1.6). A 2023 study ran the same prime-number questions through the same GPT-4 endpoint in March and June and saw accuracy fall from 84% to 51%, with no announcement.
- It fails fluently. A wrong answer reads exactly like a right one (section 2.11). Nothing crashes, so nothing alerts.
A suite does two jobs. Capability evals are tasks the system fails today, a hill to climb, where 40% is useful information. Regression evals are behavior it must keep, where anything short of nearly 100% is a problem. Capability cases that pass reliably move into the regression suite.
This is also where the moat of section 1.8 is built. Everyone rents the same models; nobody else has your users’ real requests with graded expectations. That set turns “should we switch models?” into an afternoon’s work.
Common take“We’ll add evals before launch, once the feature works.”
Sharper take“Without evals I can’t tell whether it works. The first test set comes before the second prompt, because every change after that is a guess without it.”
23.2Error analysis comes first
Read what the system did before deciding what to measure.
The common first move is to pick generic metrics, such as helpfulness and coherence on a scale of one to five. The numbers move, and nobody can say what a fall from 3.9 to 3.7 means or what to change. The method that works starts from the outputs themselves. Shreya Shankar and Hamel Husain call it error analysis.
- Collect about a hundred traces, full records of single requests (Chapter 24), sampled across real traffic, or synthetic before launch (section 23.4).
- Note the first thing that went wrong in each failing trace, in one line: “quoted last year’s returns window”.
- Group the notes into five to ten failure modes, each named and defined in a sentence that two people would apply the same way.
- Count the traces in each mode. The counts are your priorities.
- Stop when new traces stop producing new modes, often somewhere between fifty and a hundred.
The result looks like this. The table is illustrative, for a support assistant, after reading 120 traces.
| Failure mode | A typical note | Traces | How to check it (section 23.3) |
|---|---|---|---|
| Outdated policy cited | “quoted last year’s returns window” | 14 | Code: the cited document is the current version |
| Asks for what it was already given | “asked for the order number twice” | 11 | A judge, with one narrow question |
| Wrong tool arguments | “searched by email when given an order ID” | 8 | Code: compare with the expected call |
| Promises what policy forbids | “offered a refund at six weeks” | 6 | Code for amounts and dates, a judge for wording |
| Missed handoff | “angry customer, never offered a person” | 5 | A judge |
| Broken formatting | “markdown table sent to an SMS channel” | 3 | Code |
Three rules make the result usable.
- Grade each failure mode pass or fail. A 3 out of 5 means different things to different people, and to the same judge on different days. Whether the answer cited an outdated policy can be agreed on, counted and fixed.
- Let one person with domain knowledge decide what good means: a support lead, a lawyer, a clinician. Committees produce vague criteria.
- Write the criteria after reading, not before. A 2024 study by Shankar and colleagues found that people’s idea of a good output shifts as they grade; they called it criteria drift.
Common take“We’ll track helpfulness, relevance and coherence on a scale of one to five.”
Sharper take“I read a hundred traces first and named what actually goes wrong. Each failure gets its own pass-or-fail check, and the counts tell me what to fix first.”
23.3Three kinds of grader
Use the cheapest grader that can grade the property.
| Grader | Grades well | Cost and speed | How far to trust it |
|---|---|---|---|
| Code: exact match, schema validation (section 11.4), numeric tolerance, “do the tests pass”, “does the cited ID exist” | Anything with a right answer or a checkable property | Nearly free, milliseconds | Completely, for what it checks |
| A model as judge, with a narrow rubric | What resists code: whether claims are supported, whether the question was answered, tone | Cents, seconds | Only after calibration (section 23.7) |
| People with domain knowledge | The definition of good; labels that calibrate judges; spot checks | Expensive, days | The reference, though people disagree too |
Use the first row wherever it will do. Extraction accuracy is a comparison of fields, not a judge’s opinion. A suite that costs hundreds of dollars a run, and so runs weekly, is usually asking a judge questions that code could answer on every commit.
Decompose before judging. “Is this a good answer?” is the vague question judges handle worst. Split it: valid JSON (code)? Every claim supported by the context (a judge, one narrow question)? The question answered (another)? For retrieval systems this split is the triad of section 16.9.
When a reference answer exists, the old shortcut is an overlap metric. BLEU, from machine translation, and ROUGE, from summarization, count word sequences shared with the reference (section 4.1). I scored five answers against “Refunds are available within 30 days of purchase if the item is unused” with the standard rouge-score and sacrebleu packages.
Correct answers
Wrong answers
The two correct answers score lowest. The three wrong ones score highest: one changes a number, one adds “not”, one turns “unused” into “used”. Overlap measures wording, and the errors that matter are usually one word or one number. A reference is still useful: check the facts that matter in code (does the answer say 30 days?), and give the reference to a judge for the rest.
Common take“We have reference answers, so we’ll score with ROUGE.”
Sharper take“Overlap rewards a wrong answer that copies the reference’s wording. I check the facts that matter in code, and give the reference to a judge for the rest.”
23.4Building the test set
Real cases first, each tagged with the slice it protects.
A test set, often called a golden set, is the most valuable thing an AI team owns. Its cases come from three sources, in order of value.
- Production traces. Real phrasing, real typos, the real mix of requests.
- Incidents and complaints. Every diagnosed failure (section 15.9) becomes a permanent case, so the same bug cannot return unnoticed.
- Synthetic cases. Cheap coverage of situations that are rare in traffic or that do not exist yet.
Synthetic cases need method. Asked for fifty test questions, a model writes fifty variations of one polite question. Choose dimensions first, such as customer type, issue, channel and mood, generate one request per combination, and discard the unrealistic ones. Synthetic requests come out cleaner than real ones, so tag them and report them separately.
Each case is a record, not just an input.
{
"id": "refund-0412",
"input": "bought the blue kettle 5 weeks ago, it leaks, can i return it",
"expected": { "decision": "no_refund", "offers": ["repair", "warranty_claim"] },
"checks": ["decision_matches", "no_invented_policy", "offers_alternative"],
"slices": ["refund", "outside_window", "product_defect"],
"source": "production, September 2026",
"added_because": "incident 311: a refund was promised at six weeks"
}Slices are the unit of protection. If one request in twenty is about refunds and half of those go wrong, the overall score falls by only 2.5 points. Tag every case with its slices, report each slice separately, and give every slice you must protect at least fifty cases; even then, an 80% slice score carries a margin of about eleven points (section 13.8). Whole sets usually hold two hundred to a thousand cases.
Keep it clean. Test cases must not appear, even as near-duplicates, among few-shot examples or fine-tuning data (section 17.6); compare embeddings to find them. Tune freely against a development set and look rarely at the test set, so that it still measures something you have not fitted.
Keep it alive. Add a case for every incident, and re-sample from production every quarter, because traffic drifts even when the system does not.
Common take“We have fifty test cases and we’re at 94%.”
Sharper take“Which slices? If refunds have six cases, that score can’t show anything about refunds. I tag every case, give each slice I must protect at least fifty, and add a case from every incident.”
23.5Comparing two versions
Run both on the same cases, and count the cases where they differ.
Section 13.8 showed how noisy one score is. The everyday question is different: is version B better than version A? Both run on the same cases, and most cases come out the same either way. Only the cases where the two versions disagree carry information about which is better.
To measure how much that matters, I simulated it. Version A passes 75% of cases. Version B is truly better, at 80%: it fixes 35% of A’s failures and breaks 5% of A’s passes, so that, as in real suites, most cases behave the same under both. Both versions ran on the same n cases, 20,000 times for each size. The results were analyzed two ways. Unpaired: compare the two pass rates with the standard test for two proportions, as if they came from different test sets. Paired: look only at the cases where the versions disagree, and ask whether B wins significantly more of them (McNemar’s test).
- paired: count the cases where the versions differ
- unpaired: compare the two totals
Same data, different arithmetic. At 400 cases the paired analysis detects the improvement 82% of the time and the unpaired one 32%. To detect it four times in five, the unpaired analysis needs about 850 cases and the paired one about 390. Comparing totals treats the cases both versions pass, or both fail, as noise, when they are the settled part of the comparison.
Report a difference with an interval. The bootstrap needs no formulas: resample the cases with replacement, recompute the paired difference, repeat a few thousand times, and read off the middle 95%.
import random
def paired_difference(a, b, n_boot=4000, seed=0):
"""a, b: 0/1 results of two versions on the same cases, in the same order.
Returns B minus A, with a 95% bootstrap interval."""
rng = random.Random(seed)
n = len(a)
diff = (sum(b) - sum(a)) / n
boots = []
for _ in range(n_boot):
idx = [rng.randrange(n) for _ in range(n)]
boots.append(sum(b[i] - a[i] for i in idx) / n)
boots.sort()
return diff, boots[int(0.025 * n_boot)], boots[int(0.975 * n_boot)]
# B fixed 14 cases and broke 8, out of 300
a = [1] * 220 + [0] * 14 + [1] * 8 + [0] * 58
b = [1] * 220 + [1] * 14 + [0] * 8 + [0] * 58
print(paired_difference(a, b)) # about +0.02, with an interval that includes zero
When several cases share a source, such as ten questions about one document, resample whole groups instead of single cases, or the interval comes out too narrow. And every slice has its own, smaller n.
Common take“Version B scored 81% and A scored 79%, so B is better.”
Sharper take“On the same 300 cases, B fixed 14 and broke 8. That is within noise. I report the paired difference with an interval, and I don’t call a winner until the interval excludes zero.”
23.6Models as judges
A second stochastic model, with documented biases.
A judge is a model given an output, the evidence to check it against and a rubric, and asked for a verdict. It is also a language model, so everything in Chapter 2 applies to it, and its biases are well documented. The first three below were measured in 2023 by Lianmin Zheng and colleagues, in the paper that introduced MT-Bench.
| Bias | What happens | Countermeasure |
|---|---|---|
| Position | Comparing two answers, the judge favors one slot, often the first | Run both orders; count a win only if it survives the swap |
| Length | Longer answers score higher regardless of quality | Say in the rubric that padding is a defect; check scores against length |
| Self-preference | The judge favors outputs in its own model family’s style | Use a judge from a different family than the system it grades |
| Deference | Confident, authoritative claims are accepted; sycophancy is a scar of preference tuning (section 2.9) | Tell the judge the answer may be wrong, and give it the evidence to check against |
| Vague rubric | The judge invents its own standard, differently on each run | One criterion per judge, pass or fail, with examples of each |
| Silent update | The provider updates the judge’s model and every score shifts | Pin the judge’s model version like a dependency; recalibrate on every change |
Position effects are not limited to comparisons. A 2026 study found them in single-output rubric scoring too, where the order in which the score options are listed plays the part of the slot.
A judge prompt that works has a recognizable shape: one criterion, a pass or fail verdict, worked examples of both, the evidence supplied, and reasoning written out before the verdict.
You are checking one thing: whether every factual claim in the ANSWER is
supported by the CONTEXT. Ignore style, tone and length.
PASS: every claim about policy, prices, dates or amounts appears in the CONTEXT.
FAIL: any such claim is missing from the CONTEXT or contradicts it.
The ANSWER may be wrong even if it sounds confident.
[two answers that pass and two that fail, each with its reasoning written out]
CONTEXT: {context}
ANSWER: {answer}
First list each claim, and quote the part of the CONTEXT that supports it or
say that nothing does. Then give the verdict as JSON:
{"verdict": "pass" | "fail", "unsupported": ["..."]}Reasoning comes before the verdict for the reason in section 13.5: a verdict written afterward can depend on it. For choosing between two variants, a pairwise question (“is B better than A?”) is more reliable than two absolute scores; for tracking quality over time, use absolute pass-or-fail checks, which have a fixed scale. Either way the judge is a prompt in its own right: versioned, reviewed and tested on its own test set, the subject of the next section.
Common take“We use the strongest model as the judge, so the scores are reliable.”
Sharper take“Strength doesn’t remove the biases. I swap positions, use a judge from a different family, pin its version, and trust its scores only after measuring it against human labels.”
23.7Calibrating a judge
Measure how often it agrees with people, then correct for its errors.
Have a person with domain knowledge label 100 to 200 outputs, pass or fail, for the one criterion the judge checks. Split them into the judge’s prompt examples, a development set for improving the rubric, and a test set for reporting the result once. Include failures on purpose: at a 90% pass rate, two hundred random outputs hold only about twenty.
Then report the true positive rate, the share of good outputs the judge passes, and the true negative rate, the share of bad outputs it fails. Raw agreement, the number people usually quote, flatters. Consider a judge checked against 200 human labels.
| Person: pass | Person: fail | |
|---|---|---|
| Judge: pass | 150 | 30 |
| Judge: fail | 10 | 10 |
The judge agrees with the person on 80% of outputs, and so would a judge that passed everything, since 160 of the 200 are good. Cohen’s kappa, which measures agreement beyond chance, is 0.23. The true negative rate shows the problem plainly: the judge catches 10 of the 40 failures, and catching failures is its job. Improve the rubric until both rates are high. And measure two people against each other first: their agreement is the ceiling, and if experts often disagree, the criterion is not defined yet.
Even a good judge distorts what it reports. I simulated a lenient judge, the usual direction, that passes 93% of good outputs and fails 72% of bad ones. For five versions of a system with true pass rates from 50% to 90%, I labeled 200 outputs by hand, measured the judge’s two rates on them, then had it grade 2,000 production outputs.
- the judge’s raw pass rate
- corrected, with 95% interval
- equal to the truth
Two distortions show. The judge compresses: across 40 points of true quality it reports a range of 28. In general a true difference of d shows up as d × (TPR + TNR − 1), here 0.65 of it, so a real ten-point improvement appears as about six and a half. And it pulls toward the middle, overstating the weakest version by ten points.
Both can be undone. If the judge reports a pass rate p, the true rate is about
true rate = (p + TNR - 1) / (TPR + TNR - 1)with TPR and TNR measured on the labeled set. In the figure the corrected estimates land within four points of the truth, with 95% intervals from a bootstrap over both sets. The intervals are six to eight points either way, and nearly all of that comes from the 200 labels: the true negative rate rests only on the failures among them, about twenty at 90% quality. Label more failures, not more outputs. Recalibrate whenever the judge’s model or prompt changes, or the system’s failures change shape.
Common take“Our judge agrees with humans 80% of the time.”
Sharper take“What share of the failures does it catch? Agreement flatters a judge on a set that is mostly passes. I report both rates, and correct the production pass rate for them.”
23.8Gates in CI
Every change runs the suite, and the gate knows how noisy the suite is.
The wiring is the one from section 13.8. A pull request that touches prompts, retrieval settings, model versions or tools runs the suite, the gate compares the result with the main branch, and a diff shows which cases flipped. promptfoo is a widely used open-source runner for this, with a cache so unchanged calls are not paid for twice; OpenAI agreed to acquire it in March 2026 and said the open-source project would continue. Braintrust, LangSmith, Langfuse, DeepEval and Inspect cover similar ground, and a few hundred lines around pytest will also do.
# promptfooconfig.yaml
prompts:
- file://prompts/refund_reply_v7.txt # prompts live in the repository
providers:
- anthropic:messages:<pinned-model-id> # the model in production, pinned
- openai:chat:<candidate-model-id> # a second column: "should we switch?"
defaultTest:
options:
provider: openai:chat:<pinned-judge-id> # the judge, pinned like a dependency
tests: file://cases/*.yaml # the test set, one file per slice
# cases/refund.yaml (one case)
- description: refund-0412, outside the window, defective product
vars: { message: file://inputs/refund-0412.txt }
metadata: { slices: [refund, outside_window] }
assert:
- type: is-json # code
- type: javascript # code: the decision itself
value: JSON.parse(output).decision === 'no_refund'
- type: not-icontains # code: no invented promise
value: full refund
- type: llm-rubric # a judge, one narrow criterion
value: Offers a repair or a warranty claim, and does not promise a refund.The hard part is that the suite is noisy. I simulated 300 cases against a system whose outputs vary from run to run: most cases pass or fail reliably, and 35 are flaky, passing somewhere between 20% and 80% of the time. Then I ran the identical configuration 200 times.
Nothing changed between runs, and the pass rate ranged over seven points, with a standard deviation of 1.2. Then I compared three gates on 4,000 simulated pull requests of each of two kinds: ones that change nothing, and ones that introduce a real regression, breaking nine reliable cases, three points.
| Gate | Blocks a change that did nothing | Catches the real regression |
|---|---|---|
| Strict: the score must not fall at all | 45% | 94% |
| Banded: it may fall by up to two standard deviations of the run-to-run difference, measured from five repeat runs | 5% | 43% |
| Per case: no case that passed in each of the last ten nightly runs may fail, confirmed by two re-runs | 1% | 100% |
The strict gate blocks nearly half of all harmless changes. Engineers learn to re-run it until it passes, and then a real regression gets re-run through like everything else. The band stops false alarms but is blunt: a three-point regression hides in the flaky cases’ noise more often than not. Tracking cases works far better, because a case that passed every night for ten nights and now fails twice in a row is a signal, not weather. Keep both kinds, though: this regression broke reliable cases, and a change that makes many flaky cases slightly worse shows only in the total, so keep a banded gate on the overall score and on each protected slice.
Test at production settings, not at temperature zero for convenience. Quarantine flaky cases and fix them; the cause is often an ambiguous expectation. And run the suite nightly against the provider even when you have deployed nothing, which is how the silent update of section 23.1 gets caught by you instead of your users.
Common take“The eval gate is flaky, so we re-run it until it passes.”
Sharper take“Then it isn’t a gate. I measure the run-to-run spread and gate the total with that band, and I gate per case on the cases that have always passed. A failure there means something.”
23.9Offline and online
The test set gates the deploy, and live traffic tests the bet.
| Offline: the test set, before deploying | Online: live traffic, after deploying | |
|---|---|---|
| Measures | Quality on known cases | The effect on real behavior and on the business |
| Speed | Minutes, on every change | Days to weeks before a difference is significant |
| Catches | Regressions, failing slices | Shifts in traffic, changes in how people use the product, inputs nobody imagined |
| Blind to | Cases nobody thought to include | Why a number moved |
Online, quality cannot be observed directly, so you measure proxies, and each has a bias worth naming whenever you quote it.
- Thumbs up and down: rare, and skewed toward people who are annoyed.
- Retries and regenerations: a user asking again usually means the answer failed.
- Rephrased follow-ups: the same question in new words is a strong failure signal.
- Escalation to a person, and task completion: close to what the business cares about, and slow to move.
- How much of a draft the user kept: for writing features, the edit distance between the draft and what was sent.
Be honest about sample size: detecting a two-point change in a noisy proxy takes tens of thousands of sessions, so a small product should A/B test only coarse metrics and lean on the test set. Watch guardrail metrics alongside every quality change, such as 95th-percentile latency, cost per request and refusal rate; a gain that doubles the cost is a different decision (Chapter 28). Between deploys, run reference-free checks on a sample of production traces, by slice; Chapter 24 builds that monitoring.
When offline and online disagree, the disagreement is information. Offline up and online flat: the test set no longer looks like live traffic, or its cases have leaked into prompts or training data. Offline flat and complaints rising: the set is missing the slice that is failing, so turn the complaints into cases. The field corrects the test set, and then the test set protects the field.
Common take“The evals went up nine points, so users will notice.”
Sharper take“The evals say it’s safe to ship. Whether users notice is an online question, and if the two disagree, my test set has drifted away from real traffic.”
23.10Retrieval, agents and conversations
Grade the parts where labels exist, and the whole by its outcome.
Composite systems are evaluated in two layers: code-graded metrics for components wherever labels exist, judges and outcomes for the whole. When the end-to-end number moves, the components say where, which automates the bisection of section 15.9.
- Retrieval systems. Recall at k and reciprocal rank for the retriever (section 14.10); the three triad scores for the whole (section 16.9).
- Agents, by component. Router accuracy against labeled routes; tool-call validity against the schema and reality (section 19.2); single-step choices: given this state, was this the right tool?
- Agents, end to end. Task success in a sandbox with known starting state, judged on the final state: the refund record exists, it is at most €100, the confirmation email was logged.
Do not assert on the path the agent took. Agents find valid routes nobody anticipated, and the sequence of tool calls varies from run to run (section 2.6). A test that requires lookup, then policy check, then refund fails a correct agent that checked the policy first. Read trajectories for diagnosis, such as loops and repeated calls; gate on outcomes.
Agents also need more than one run per task, and the way runs are combined has to match the product.
- pass@k: at least one attempt succeeds
- pass^k: every attempt succeeds
pass@k is the chance that at least one of k attempts succeeds, which fits work where something checks the attempts and keeps the best, such as code with tests. pass^k, introduced with the τ-bench agent benchmark in 2024, is the chance that all k succeed, which fits customer-facing agents, where every customer gets one attempt. At 90% per attempt, pass@8 is near 100% and pass^8 is 43%. Real failures cluster on hard tasks rather than striking independently, so run each task several times and measure.
Conversations are tested with a simulated user: a model plays the customer from a scenario card giving the goal, what the customer knows, their manner and when they give up. Grade the whole conversation and find the first turn that went wrong. Simulated users are more cooperative than real ones, so compare a sample with real conversations. Long tasks and voice have their own measurements (sections 20.9 and 22.10).
Common take“Our agent eval checks that it calls lookup_order, then check_policy, then issue_refund.”
Sharper take“That fails a correct agent that checked the policy first. I assert on the final state in a sandbox: the refund exists, it is under the cap, the email was logged. And I run each task several times, because one pass says little.”
23.11Benchmarks and red teams
Public scores say which models to try; your own cases say which to ship.
A public benchmark answers “which models are worth testing on my data?”, not “which is best for my product?”, and its number needs care.
- Contamination. Benchmark questions leak into training data (section 8.1), and scores rise without ability rising. In February 2026 OpenAI stopped reporting SWE-bench Verified, a widely used coding benchmark. It audited 138 problems that its models often failed and found that 59.4% had flawed tests or descriptions, and it reported signs that models had seen the benchmark in training.
- Saturation. When the leading models all score above 90%, the differences between them are mostly noise and label errors.
- The harness. The same model scores differently with different prompts, tools, attempt counts and time limits. Check whether a reported score is from one attempt or the best of many.
- Preference leaderboards. Head-to-head votes measure what voters prefer, which length and style move. A 2025 study, “The Leaderboard Illusion”, documented providers testing many private variants and publishing the best score.
- Distribution. Your users do not ask benchmark questions.
So keep a private model-selection set drawn from your own test set. When a model ships, run it slice by slice with your prompts, and plot quality against cost per request and latency, as in section 10.6. That is the afternoon that section 1.6 promised.
Red-team and safety evals are the adversarial part of the test set: injections hidden in documents and tool results (Chapter 26), attempts to extract the system prompt or another customer’s data, requests that must be refused, jailbreak phrasings. Open-source tools such as garak and PyRIT, and promptfoo’s red-team mode, generate attack variants at volume. Measure both directions: attacks that succeed, and legitimate requests refused, such as a support assistant that will not explain how to kill a process. Every attack that succeeds once becomes a permanent case.
Common take“The new model tops the leaderboard, so we’ll switch.”
Sharper take“The leaderboard says it’s worth an afternoon. I’ll run it on our test set, slice by slice, with our prompts, and check cost and latency. Then we’ll know.”
23.12The flywheel
Every failure becomes a case, and the set compounds.
Assembled, the pieces of this chapter form a loop.
Every “measure it” in earlier chapters plugs into this loop, and every incident strengthens the test set. Teams can place themselves on a ladder.
| Level | What it looks like |
|---|---|
| 0. Impressions | Someone tries a few inputs before a release |
| 1. A test set | Real cases with code checks, run by hand |
| 2. Gates | CI gates per slice, with bands measured from repeat runs |
| 3. Calibrated judges | Judges for what code cannot check, each measured against human labels |
| 4. Online | Sampled checks on production traces, proxies, A/B tests |
| 5. The flywheel | Incidents become cases routinely, dashboards per slice, a model change is an afternoon’s decision |
Most teams are at level 0 or 1. The costs of the higher levels, labeling hours and judge calls, are visible up front and the benefits arrive later, which is why teams under-invest. Chapter 25 extends the loop, turning the same labels into training data.
Common take“Evals are the QA step before a release.”
Sharper take“Evals are how the product steers. Every incident becomes a test that runs forever, which is why a model change takes us an afternoon and not a quarter.”
Key takeaways
- A language model samples, changes under the same name and fails fluently. Evals are the tests of behavior that ordinary code gets from compilers and unit tests.
- Start with error analysis: read about a hundred traces, name the failure modes, count them, and give each one a pass-or-fail check.
- Use the cheapest grader that works: code first, a judge for what code cannot check, people to define good and to calibrate the judge.
- Overlap metrics measure wording. In a real measurement, three wrong answers scored ROUGE-L 0.89 to 0.96 and two correct ones 0.00 and 0.48.
- Tag every case by slice and protect each slice with at least fifty cases. Add a case from every incident.
- Compare versions on the same cases, case by case. In simulation, a paired analysis needed about 390 cases to detect a real five-point gain where comparing totals needed about 850.
- A judge has documented biases. Report its true positive and true negative rates against human labels, not raw agreement, and correct its pass rate for them.
- Suites are noisy. An unchanged system ranged over seven points in 200 runs; a strict gate blocked 45% of harmless changes. Gate the total with a measured band, and gate per case on reliable cases.
- Judge agents by the final state in a sandbox, not by the path. Use pass^k when every user gets one attempt.
- Public benchmarks say which models to try. Your own test set says which to ship.
Check your understanding
-
Your judged groundedness pass rate sat at 86%, give or take a point, for two quarters. Over three weeks it rose to 93%, with no deploys to prompts, retrieval or the model, no movement in code-checked metrics, and a flat retry rate. A product manager wants to announce a quality win. What do you check first, and how do you settle it?
Answer outline
Suspect the instrument first. Did the judge’s model change? Check the model identifier logged with each run; an alias that moved to a new snapshot shifts every score. Did its prompt or settings change? Check their version history. Did traffic shift toward easier requests? Compare the slice mix before and after. To settle it, re-run the judge on the human-labeled set: if its true positive or true negative rate moved, the rise is a measurement change, and the corrected pass rate (section 23.7) shows whether anything real remains. Then pin the judge’s version.
-
A reranker ships after the test set showed +7 points overall with every slice green. Over three weeks online, retries fall from 4.1% to 3.4%, but escalations to a person rise from 6% to 9%, concentrated among enterprise customers, whose tickets say “the answer cites the wrong contract version”. The test set has no slice for customer type and was last refreshed from production eight months ago, before multi-contract enterprise accounts launched. Diagnose, and say what changes.
Answer outline
The set no longer matches traffic: it predates the accounts where the failure lives and has no slice to expose it (section 23.4). The proxies disagree because they measure different people: most users get better rankings and retry less, while enterprise users get confident answers from the wrong version and escalate instead of retrying. The tickets describe the stale blend of section 15.7, several versions indexed without a filter, perhaps worsened because the reranker promotes the most similar version regardless of date; the fix is effective-date metadata and filtering (section 15.8). Add a customer-type slice of at least fifty multi-contract cases built from the tickets, re-sample the set quarterly, and track escalations by segment as a guardrail metric.
-
You put a support agent’s eval into CI: 30 scripted scenarios, a gate of at least 27 passing, each test asserting that the transcript contains the expected sequence of tool calls. The same commit passes 25 to 29 times out of 30 on different runs, engineers re-run until it is green, and a real regression, a refund-cap check dropped from a tool, slipped through. Explain the two design errors and redesign the suite.
Answer outline
First error: asserting on the path, so correct agents that take another valid route fail; assert on the final state in a sandbox instead: the refund record, its amount against the cap, the logged email (section 23.10). Second error: a gate with no measured noise band, which teaches people to re-run until green (section 23.8). Redesign: run each scenario five times, measure the spread on an unchanged commit and set the band from it, and add a per-case gate on scenarios that pass every night. The dropped cap check needed no model at all to catch: a code test that submits an amount over the cap to the refund tool and expects a refusal, backed by the action gate of section 19.4.
Further reading
- Shreya Shankar and Hamel Husain, Evals for AI Engineers (O’Reilly, 2026): error analysis, building and validating judges, and continuous evaluation. The primary reference for this chapter.
- Chip Huyen, AI Engineering, chapters 3 and 4: evaluation methodology, AI as a judge, and evaluating whole systems.
- Lianmin Zheng and others, “Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena” (2023): the paper that measured position, length and self-preference bias.
- Evan Miller, “Adding Error Bars to Evals” (2024): confidence intervals, clustered cases and paired comparisons, with the formulas.
- Anthropic, “Demystifying evals for AI agents” (2026): graders for agents, capability and regression suites, and grading outcomes instead of paths.