What you'll learn: how to build a golden set and a regression gate a team can trust, where an LLM judge is biased and how to calibrate it with Cohen's kappa, how to measure retrieval apart from generation, how to grade agents, and what a gate with a finite sample can and cannot detect.
At a glance
Figure 1. The evaluation loop around an AI system
How to read this: the left box is what blocks a bad change, the right box is how production teaches the golden set about cases nobody imagined, and the arrow back keeps the loop honest.
- A golden set is versioned, tagged by slice and labelled against a written rubric.
- An LLM judge is a model under test: calibrate it against human labels first.
- Retrieval metrics need no model call; generation metrics need a judge. Keep them apart.
- A gate decides on a confidence bound and has three outcomes: pass, fail, inconclusive.
- Item count sets the smallest visible drop: about 3.6 points at 400 items, about 16 for a 30-item slice.
The real-world problem
A team changes one sentence in its assistant's system prompt to make answers shorter. Five reviewers read twenty answers each, see no problem, and the change ships. Two weeks later the returns team reports confident but incomplete answers about one product category. The quality average had moved about a point, inside the noise of the sample, and nothing measured that category.
After this page you will be able to
- Build a versioned golden set with slices, a rubric and a hold-out split.
- Calibrate an LLM judge with raw agreement, Cohen's kappa and failure recall.
- Use recall at k, reciprocal rank and nDCG to locate a failure in retrieval rather than generation.
- Compute a Wilson interval and the samples needed to detect a stated drop.
- Design a CI gate with slice reports, position-swapped pairwise judging and an outcome-versus-trajectory split for agents.
Prerequisites and cross-links
- Page 2, the architect mindset: one confidence-interval example (180 of 200 passing), not repeated here.
- Page 5, data and retrieval and page 6, agents, tools and MCP.
- Background: Evaluating RAG systems with RAGAS; judge-call cost: the LLM cost estimator.
Core concepts
Golden sets and how to build them
| Rule | Why |
|---|---|
| Seed from real failures and traffic; every incident adds an item | Teams cannot imagine production's failures |
| Tag items with slices: category, language, tenant, risk class | Slices find what an average hides |
| Write the rubric before labelling; two people label subjective items | Without a rubric, labels drift |
| Split a hold-out set nobody tunes against (the course's recommendation, not a sourced rule) | Otherwise the set measures your editing |
| Version the set; record which version produced each score | Scores compare only on the same set |
How to read this: each row is a working rule and the failure it prevents.
- Anthropic: "design evals that mirror your real-world task distribution" (Define success criteria and build evaluations, as of 2026-10-22).
- Anthropic: "20-50 simple tasks drawn from real failures is a great start" (Demystifying evals for AI agents, 9 January 2026).
Offline and online evaluation
| Offline | Online | |
|---|---|---|
| Answers | "Is this change safe to ship?" | "Is it still working on what users send?" |
| Strength | Repeatable | The real distribution |
| Limit | Sees only the past | Little ground truth: user signals, sampled review, a judge on a sample |
How to read this: offline blocks changes; online finds what the golden set missed and feeds it back (Figure 1).
Regression gates in CI
A regression gate blocks a merge when evidence shows quality dropped. Fix three things in advance: the metric, the comparison (a fixed bar or the current production version) and the rule for noise (a confidence bound, not the point estimate).
Figure 2. A regression gate in CI, including its failure paths
How to read this: the gate decides on a bound per slice and counts judge errors as failures of the evaluation, so a broken judge can never turn a run green.
Step through one run (illustrative counts, computed in the confidence-interval section below).
Check yourself: the judge returns malformed output for a large share of items, and the rest all pass. Can the run be green?
No. A verdict still malformed after one retry is an evaluation error, not a pass, and a run above the agreed error rate is invalid.
Anthropic's agent-eval post (Demystifying evals for AI agents) separates capability evals ("what can this agent do well?", which "should start at a low pass rate") from regression evals, which "should have a nearly 100% pass rate". Give each its own suite and gate.
Human review and label quality
Humans are the reference, but not perfectly consistent: in TREC-8, "assessors have legitimate differences of opinion as to correctness even for fact-based, short-answer questions" (Voorhees and Tice, LREC 2000). Measure reviewer agreement first; if reviewers disagree often, repair the rubric before anything else.
| Grader | Anthropic's description (docs) | Use it for |
|---|---|---|
| Code-based | "fastest and most reliable", but lacks nuance | Schema, citation present |
| Human | "most flexible and high quality, but slow and expensive" | Calibration, hard cases |
| LLM-based | "fast and flexible"; test reliability before scaling | What needs reading |
Evaluating retrieval separately from generation
A wrong answer from a retrieval-augmented system has at least four causes, and one end-to-end score cannot separate them. Each has a different fix and owner.
Figure 3. Locating the failing stage of a wrong answer
How to read this: work down in order, because the first "no" names the stage to fix, and the last branch reminds you that the evaluation itself can be wrong.
Retrieval metrics need labelled passages and no model call; generation metrics need the retrieved passages and a judge. Report both per slice, side by side.
Check yourself: the relevant passage was retrieved, but the token budget trimmed it before the prompt was built. Which branch names the fault?
The second: the passage is not in the final prompt, so it is a context assembly failure. Retrieval recall would look fine, which is why one end-to-end score cannot find it.
Evaluating agents: trajectory versus outcome
Anthropic's post defines the transcript (trajectory) as "the complete record of a trial, including outputs, tool calls, reasoning, intermediate results" and the outcome as "the final state in the environment at the end of the trial". It advises that "it's often better to grade what the agent produced, not the path it took", because valid paths vary; tau-bench compares the final database state with an annotated goal state (Yao et al.).
| What to grade | Example check | Why |
|---|---|---|
| Outcome | Ticket in the right state, refund amount right, no other record changed | Many paths reach it |
| Trajectory, policy steps | Approval step not skipped, no forbidden tool called | Some paths are unacceptable even when the outcome is right |
Agent runs are stochastic. Anthropic defines pass@k as "the likelihood that an agent gets at least one correct solution in k attempts" and pass^k as "the probability that all k trials succeed". Assuming independent trials with success probability p (a simplification), pass@k is 1 - (1 - p)^k and pass^k is p^k.
| With p = 0.9 | pass@3 | pass^3 | pass^8 |
|---|---|---|---|
| Value | 0.999 | 0.729 | 0.43 |
How to read this: at-least-once success climbs toward 1 while all-trials success falls, so an agent that acts on the world needs pass^k (agent loop: page 6; event-driven designs: page 7).
Check yourself: an agent succeeds on each trial with probability 0.9. What is the chance it succeeds on all 8 trials of one task?
About 0.43 (0.9 to the power 8 is 0.4305). A 90% single-trial rate still means at least one failure in eight runs more often than not.
Case files
- A prompt tweak that silently broke one product category. In a composite retail scenario, a prompt change lowered answer quality in one category while the average barely moved. Pattern: eval gates, with a golden set per category and a confidence interval on the gate.
- A RAG assistant that was confident and wrong. In a composite healthcare scenario, a procedure-lookup assistant gave fluent, wrong answers, mostly because it retrieved a superseded passage and stayed faithful to it. Pattern: LLM judge and faithfulness checks, retrieval metrics kept apart from generation metrics, and abstention when evidence is weak.
- Summarisation: nobody agreed what good meant. In a composite public-sector scenario, a summarisation feature could not be improved because there was no shared definition of quality. Pattern: eval design, with a rubric, a calibrated judge, human spot checks and pairwise comparison for model changes.
Under the hood: How an LLM judge works
Intuition
An LLM judge is a model call that returns a grade instead of an answer, so it is a measuring instrument with its own error.
Mechanism
Zheng et al. (arXiv 2306.05685) studied "LLM-as-a-judge" and defined three variants:
| Variant | The judge sees | Used for |
|---|---|---|
| Pairwise comparison | A question and two answers; picks the better or declares a tie | Choosing between versions |
| Single answer grading | One answer; gives a score | Tracking against a bar |
| Reference-guided grading | A reference solution too | Mainly maths |
Their default single-answer prompt tells the judge to "begin your evaluation by providing a short explanation" and to rate from 1 to 10 as "[[rating]]": reasoning first, then a machine-parseable verdict.
Figure 4. One judge call, including a malformed verdict
How to read this: the judge is one remote call with a parse step after it, and the parse step has a defined failure path.
Format has a cost: in the paper's position-bias test, between 0% and 3.8% of judge outputs per configuration had a wrong output format (Table 2, "Error" column).
What this means for architects
| What changes | What you do |
|---|---|
| Every judged item is an extra call (page 4 on latency) | Judge offline or on a sample unless the verdict changes what the user sees |
| Absolute scores "are likely to fluctuate more than relative pairwise results if the judge model changes" | Store judge and prompt versions and raw output with every score; re-baseline when the judge changes |
| A malformed verdict is an evaluation error, never a pass | Set an error-rate limit; a run above it is invalid |
| Anthropic's example code: "Generally best practice to use a different model to evaluate than the model used to generate the evaluated output" | Give the judge its own route behind the model gateway |
Under the hood: Judge biases
Intuition
A judge can prefer an answer for reasons unrelated to quality: its position, its length, or who wrote it. These biases do not average out like noise, and they can line up with the change you are testing.
Mechanism
Zheng et al. measured each bias on 2023-era models (GPT-4, GPT-3.5, Claude-v1). Read the numbers as evidence that the effects exist and can be large, not as properties of any model you use today.
| Bias | Meaning (paraphrased) | What they measured |
|---|---|---|
| Position | Favouring certain positions over others | Two very similar answers, order swapped: consistency GPT-4 65.0%, GPT-3.5 46.2%, Claude-v1 23.8%; Claude-v1 favoured the first position 75.0% of the time |
| Verbosity | Favouring longer responses even when less clear, high-quality or accurate | "Repetitive list" attack on 23 answers: judge failure rate Claude-v1 91.3%, GPT-3.5 91.3%, GPT-4 8.7% |
| Self-enhancement | May favour answers the judge itself generated | GPT-4 favoured itself with a 10% higher win rate than humans gave it, Claude-v1 25%, GPT-3.5 not at all; the authors say their "study cannot determine whether the models exhibit a self-enhancement bias" |
| Limited reasoning | Mis-grading maths and reasoning answers | 10 maths questions (20 judgments): default prompt failed 14/20, chain-of-thought 6/20, reference-guided 3/20 |
How to read this: each row pairs a bias with its 2023 effect size.