CCDV-P M4: Evaluation Engineering and Quality Assurance
Offline and online evals, calibrating LLM judges with Cohen's kappa, stratified datasets, release gates, A/B tests, recall and fairness for Claude apps.
Modules 1 to 3 were about building, wiring and observing a Claude application. This module is about a different question: how do you know that a change is an improvement before every user receives it? That is evaluation engineering. At the Professional level the interesting problems are not "how do I write one eval" but "how do I trust the measurement itself, and what does the measurement have to say before a release is allowed to ship."
Anthropic-specific statements below come from the official pages listed under Where to verify. The statistics and release-process material is standard engineering practice. All names, systems and numbers in the examples are invented for teaching, and any number that is only an illustration is labelled as one.
4.1 Offline sets, online sampling and shadow mode
Principle. Three kinds of evidence answer three different questions, and none replaces the others.
Evidence
Where it comes from
Answers
Weakness
Offline eval
A curated, labelled set you control
"Did this change break or fix known cases?"
Frozen in time; can drift away from real traffic
Online sampling
A sample of live traffic, graded after the fact
"How is production behaving right now?"
Labels arrive late; users already saw the output
Shadow mode
The candidate runs on live inputs, its output is logged but never shown
"What would the candidate have done on real traffic?"
Costs extra inference; no user reaction to measure
Mechanism. Run the candidate prompt or model in shadow beside the current version on a sample of real requests. Store both outputs with the same trace id, then grade the pair offline with the same graders you use on the curated set. You see real-world inputs, including the strange ones nobody put in the golden set, without exposing a single user. Anthropic's guidance on building evals says to design them to mirror the real task distribution and to include edge cases such as overly long, irrelevant or ambiguous input. Shadow traffic is the cheapest way to keep that promise as the product changes.
Figure 1. Shadow mode: the candidate sees real traffic, the user never sees the candidate
How to read this: the top row is what the user gets. Follow the dashed copy down to the candidate, whose output goes only to the trace store, and then follow the loop that turns new failures into offline cases.
TIP
Picture it: A restaurant tests a new recipe by cooking it in the back for every real order, tasting it, and still sending out the old dish. Diners are never at risk, and the kitchen learns how the new dish copes with real orders. The analogy stops at cost: the kitchen pays for every extra plate, just as shadow mode pays for extra inference.
A useful habit is to feed the offline set from production. When online sampling or a support ticket exposes a new failure, the case is added to the offline set so that the failure cannot silently return. Module 3 called this turning an incident into a regression eval.
Exam angle. A scenario says a team wants "confidence on real traffic" before changing the model that classifies insurance claims, and offers: grow the offline set, send 5% of users to the new version, or run it in shadow. When the question stresses "without affecting any customer" the answer is shadow mode.
Common trap: Choosing a small live rollout because it feels cautious. A rollout exposes real users to the unknown candidate. Shadow mode measures first and exposes later.
4.2 Graders: deterministic first, then calibrated judges
Principle. Use the cheapest grader that can reliably decide the question. The order of preference is: deterministic check, then a model-based grader with a rubric, then human review for what neither can settle.
Anthropic's eval guidance lists the same families: code-graded checks (exact match, string match, schema checks), human grading, and LLM-graded checks. It also advises automating where you can, and notes that more automatically graded questions are usually better than fewer hand-graded ones. For LLM grading it recommends, as a best practice, evaluating with a different model from the one that produced the output.
Mechanism. Deterministic validators are your hard gates, because they never disagree with themselves. If the application asks Claude for JSON, parse it and validate it against the schema in code. The Claude API can constrain output to a JSON Schema (output_config.format with "type": "json_schema", or strict: true on a tool), and the documentation says the output then follows the schema. It also lists cases where the output might not match: a refusal (stop_reason: "refusal") and a response cut off at max_tokens (stop_reason: "max_tokens"). So the schema gate in your eval harness still reads stop_reason and counts a refusal or truncation as a failed case, not as an empty pass.
Figure 2. Which grader decides this question?
flowchart TD
accTitle: Choosing a grader
accDescr: A question about an output is first sent to a deterministic check if code can decide it. If not, a rubric-based LLM judge is used, but only after its agreement with human labels has been measured. If a rubric cannot settle the question, a person reviews it.
Q1{"Can code decide it?"}
D["Deterministic check: schema, exact match"]
Q2{"Can a written rubric decide it?"}
J["LLM judge with a rubric"]
Q3{"Judge agreement with humans measured?"}
C["Calibrate first, then use the scores"]
U["Scores can feed a gate"]
H["Human review"]
Q1 -->|yes| D
Q1 -->|no| Q2
Q2 -->|yes| J
Q2 -->|no| H
J --> Q3
Q3 -->|no| C
Q3 -->|yes| U
C --> U
How to read this: start at the top and take the first exit that applies. Code is always tried first, and a judge's scores only count once they have been checked against people.
For qualities code cannot judge, such as tone, completeness or faithfulness to a source, use an LLM judge with a written rubric:
You grade a support reply. Use only the rubric below.
Rubric (score each 0 or 1):
1. Faithful: every factual claim appears in the provided policy excerpt.
2. Actionable: the reply tells the customer the next step.
3. Safe: no promise of a refund the policy does not allow.
Return JSON: {"faithful": 0|1, "actionable": 0|1, "safe": 0|1, "reason": "<onesentence>"}
A judge without a rubric drifts toward whatever sounds good. A judge with a rubric is still only a measurement instrument, and instruments need calibration. That is the next section.
Exam angle. A scenario describes an eval where "the summaries look better" according to an LLM judge, and asks what must be true before the judge's scores gate a release. The expected answer: the judge has a rubric and its agreement with human labels was measured on a labelled sample.
Common trap: Trusting a judge because it is a strong model. Strength is not calibration. A strong judge can still apply your criteria differently from your reviewers.
4.3 Agreement beyond chance with Cohen's kappa
Principle. Raw agreement flatters a judge. If 75% of items are truly "pass", a judge that says "pass" almost every time will agree with humans most of the time by luck. Cohen's kappa corrects for the agreement you would expect by chance:
kappa = (p_o - p_e) / (1 - p_e)
where p_o is observed agreement and p_e is the agreement expected from the two raters' own pass rates.
Worked example (illustrative data). A team labels 100 support replies pass or fail with a human reviewer and with an LLM judge.
Human: pass
Human: fail
Row total
Judge: pass
60
15
75
Judge: fail
5
20
25
Column total
65
35
100
Observed agreement: p_o = (60 + 20) / 100 = 0.80.
Judge pass rate 0.75, human pass rate 0.65.
Chance agreement: p_e = 0.75 x 0.65 + 0.25 x 0.35 = 0.4875 + 0.0875 = 0.575.
Kappa: (0.80 - 0.575) / (1 - 0.575) = 0.225 / 0.425 = 0.529, which is about 0.53.
Picture it: A weather forecaster in a desert says "dry" every day and is right almost every time. The forecaster has no skill at all, because dry was the likely answer anyway. Kappa asks how much better a judge is than always guessing the common answer. The analogy is loose on one point: kappa uses both raters' own pass rates, not a single fixed guess.
Reading the number. Compare it to the inter-annotator agreement between two human reviewers on the same items. That human-to-human kappa is the practical ceiling: if two experts only reach 0.62 with each other, demanding 0.9 from a judge is unreasonable, and a judge at 0.53 still has a gap to close. Look at the disagreements. Here the judge passes 15 replies that humans failed, which is the dangerous direction for a quality gate. Add those cases as examples or sharpen the rubric, then re-measure.
Recalibrate on change. Calibration belongs to a particular judge model and a particular rubric. When either changes, including when you move the judge to a newer model, rerun the comparison against human labels before you trust the scores. If the average score jumps while the system under test did not change, suspect the instrument first.
Exam angle. Questions give a confusion table and ask for kappa, or give an 80% raw agreement and ask whether the judge is "good enough". They also give a judge-model upgrade and a score shift, and ask for the first step.
Common trap: Reporting raw agreement or correlation alone, or treating a score shift after a judge change as a real quality change.
4.4 Datasets that look like production
Principle. An eval set is a sample. If the sample does not match the population, the headline number does not describe production. Stratify the set by the dimensions that matter (topic, difficulty, language, customer tier, input length) and keep each stratum large enough to read by itself.
Worked example (illustrative data). A team's eval set is 97% English and 3% Spanish tickets. The system passes 96% of English cases and 62% of Spanish cases.
Eval-set pass rate: 0.97 x 0.96 + 0.03 x 0.62 = 0.9312 + 0.0186 = 0.9498, about 95%.
In production, Spanish tickets are 22% of traffic: 0.78 x 0.96 + 0.22 x 0.62 = 0.7488 + 0.1364 = 0.8852, about 88.5%.
The eval says 95% and users experience 88.5%. Worse, the Spanish segment sits at 62% and the aggregate hides it. Fixing this takes two moves: build the set to reflect the production mix (or reweight by it), and report and gate per segment, not only in aggregate.
Mechanism. Derive strata from production logs, not from the team's imagination. Sample each stratum, label it, and record the stratum on every case so that the harness can emit a per-segment table. Refresh the strata when traffic changes. Anthropic's guidance on eval design, mirroring "your real-world task distribution", is the same idea stated briefly.
Figure 3. From production logs to a per-segment report
How to read this: follow the solid path from real traffic to a table with one row per segment. The red dashed arrow is the shortcut to avoid, a single blended number.
TIP
Picture it: A restaurant hands out its satisfaction card only at lunch and finds 95% of guests happy. The dinner crowd, a different kind of customer, quietly hates the slow service. The card was real, but it sampled the wrong population. An eval set is that card: it only speaks for the people it was handed to.
NOTE
On call, 3 a.m.: Nadia Okafor owns the support classifier at Tidewell Telecom, an invented company. The eval dashboard says about 95% and she signs off the release. Two weeks later Spanish-speaking customers fill the complaints queue. She opens the per-segment table: English passes 96%, Spanish passes 62%, and Spanish tickets are 22% of real traffic, which puts production near 88.5%. The set was 97% English, so the average never showed it. She rebuilds the set from the production mix and gates each segment. Invented example.
Exam angle. The scenario shows a strong aggregate score and a complaint from one group. The answer rebuilds or reweights the set and breaks the metric down by segment.
Common trap: Adding more cases of the same kind. A thousand more English tickets raise confidence in a number that was never the problem.
4.5 Release gates
Principle. A release gate turns evidence into a decision before anyone is tempted to argue. Not all gates are equal, and the exam expects you to tell them apart.
Gate type
Example
Failure means
Can it be overridden?
Hard gate
Schema validity, safety suite, no policy-violating output on the red-team set
Do not ship
No. Not by seniority, not by deadline
Approval gate
Quality score, per-segment regression
Ship only with a named approver, a written reason and an expiry date
Yes, with a record
Advisory gate
Cost per task, latency budget
A warning in the release notes
It never blocks
# Illustrative thresholds; yours come from your own risk analysis.gates:-name:schema_validitykind:hardrule:"pass_rate == 1.0"-name:safety_suitekind:hardrule:"failures == 0"-name:task_qualitykind:approvalrule:"no segment drops more than 2 points versus baseline"-name:cost_per_taskkind:advisoryrule:"within 10 percent of budget"rollback:"redeploy the previous prompt version id; rehearsed, documented"
Figure 4. How the three gate types decide a release
flowchart TD
accTitle: Release gate decision flow
accDescr: A candidate is checked against hard gates first. Any hard failure blocks the release with no override. If hard gates pass, approval gates are checked. A failed approval gate needs a named approver, a written reason and an expiry date, otherwise the release is blocked. Advisory gates only add warnings to the release notes. A passing release goes out as a staged rollout with a rollback ready.
S(["Candidate results"])
H{"Any hard gate failed?"}
B["Block the release, no override"]
A{"Any approval gate failed?"}
P{"Named approver, reason, expiry?"}
V{"Any advisory gate over?"}
N["Add a warning to the release notes"]
R["Staged rollout, rollback ready"]
S --> H
H -->|yes| B
H -->|no| A
A -->|yes| P
A -->|no| V
P -->|no| B
P -->|yes| V
V -->|yes| N
V -->|no| R
N --> R
How to read this: the first diamond is the hard gate. A hard failure ends the story there, while the later gates can bend the outcome but never replace it.
TIP
Picture it: At an airport, passport control is a hard gate, because nobody boards without it. A gate agent can allow a late passenger on with a note in the record, which is an approval gate. The sign saying the lounge is busy is advisory. The analogy has one gap: a real airport rarely logs an expiry date for the agent's exception.
NOTE
On call, 3 a.m.: Priya Raman runs releases at Kestrel Claims, an invented insurer. On Thursday the candidate prompt raises the quality score by 2 points, one safety-suite case now fails, and cost per task is over budget. A director asks for an exception because the quality gain is large. Priya points to the gate table: safety is a hard gate, so there is no exception path, and the cost warning only goes in the notes. The team fixes the failing case on Friday and ships on Monday. Invented example.
Mechanism. Gates run in the same pipeline that builds the release. The result is recorded with the version of the prompt, model, tools and eval set, so that a later reader can reproduce it. A documented, rehearsed rollback is part of the gate design: if the only way back is "ask the one engineer who remembers", the release is not safe. Version prompts like code so that rollback is a redeploy, not an edit.
Exam angle. A candidate improves the quality score by two points, but one case in the safety suite now fails, and the cost advisory is over budget. The right answer blocks the release: the safety gate is hard, the quality gain does not offset it, and the cost warning is not what decides.
Common trap: "Approve it with an exception and an expiry date." That mechanism exists for approval gates. A hard safety gate has no exception path.
4.6 A/B tests and flaky results
Principle. An A/B test compares two versions on live users. Statistical significance tells you the difference is unlikely to be noise within the traffic you measured. It does not tell you that the traffic was representative.
Mechanism. Check three things before reading the p-value:
Duration. Cover at least one full business cycle. A test that ran for three weekdays says nothing about weekends or month-end.
Traffic mix. The arms must be randomised over the same population, and the population must include the segments that matter (new users, large accounts, other languages).
The right metric. A click on "thumbs up" is not task success. Pair a user-facing metric with a graded quality sample and a guardrail metric such as refusal rate.
Figure 5. Questions to ask before trusting an A/B result
flowchart TD
accTitle: A/B test representativeness checks
accDescr: A significant A/B result is only trusted if the test covered a full business cycle, the arms were randomised over the same population including the segments that matter, and the metric was task success with guardrails. Any no answer means extending or redesigning the test instead of shipping on the p-value.
S(["Significant result"])
Q1{"Covered a full business cycle?"}
Q2{"Arms drawn from the same population?"}
Q3{"Key segments included?"}
Q4{"Task success plus guardrail metrics?"}
OK["Evidence supports a staged rollout"]
NO["Extend or redesign the test"]
S --> Q1
Q1 -->|yes| Q2
Q1 -->|no| NO
Q2 -->|yes| Q3
Q2 -->|no| NO
Q3 -->|yes| Q4
Q3 -->|no| NO
Q4 -->|yes| OK
Q4 -->|no| NO
How to read this: the p-value is only the starting arrow. Every diamond below it must say yes before the result counts as evidence about production.
Flaky results. Model outputs vary, so a single run of an eval case can pass today and fail tomorrow without any change. Treat variance as data: run each case several times, report the pass rate with its spread, and gate on the rate. A case that passes 3 times in 10 is a finding, not noise to be rerun until it goes green. Rerunning only failures until they pass is a way of measuring the retries, not the system.
Exam angle. "The test reached 99% significance on 40,000 sessions in three days" is followed by a question about whether to ship. The expected reasoning notes that none of those days included the month-end billing spike, so the sample did not represent production.
Common trap: Equating a small p-value with a safe release.
4.7 Asymmetric costs and fairness
Principle: asymmetric costs. Accuracy treats every error as equal. In many systems they are not. Missing a safety-critical report is far worse than escalating a harmless one. When the costs are asymmetric, choose the metric and the threshold around the expensive error, which usually means high recall on the critical class.
Worked example (illustrative data). Among 1,000 incoming field reports, 50 describe a hazard. The classifier flags 40 reports, of which 35 are real hazards.
An accuracy of 98% looks excellent while 30% of hazards are missed. Gate on recall for the critical class (and watch precision so the review queue stays workable), tune the threshold toward recall, and accept more false alerts. Where possible add a deterministic backstop, such as a keyword rule that always escalates, for the cases you can never miss.
Principle: fairness. Equal accuracy across groups can hide unequal harm. Compute the false positive rate and false negative rate for each group. These are the numbers that describe what people in each group experience.
Worked example (illustrative data). A transaction-screening classifier is tested on two customer groups of 1,000 cases each, 800 legitimate and 200 fraudulent.
Group X
Group Y
False positives (legit blocked)
24 of 800 = 3%
56 of 800 = 7%
False negatives (fraud missed)
36 of 200 = 18%
4 of 200 = 2%
Errors in total
60
60
Accuracy
94%
94%
Accuracy is identical, but group Y's honest customers are blocked more than twice as often, and group X's fraud goes undetected nine times as often. The report must show the rates per group, and the decision about thresholds must weigh each error type and be reviewed by the people who own the policy. Do not average the groups together.
Exam angle. Scenarios give equal accuracy, or an excellent aggregate, and ask what the evaluation should report. The answer is the per-group error rates (and per-group recall for the critical class).
Common trap: Declaring the system fair because overall accuracy is the same for every group.
4.8 Building a dataset on an annotation budget
Principle. Labels are the scarce resource. Spend expert time where an error would be costly or the case is ambiguous, and use cheaper methods for the routine bulk.
Mechanism. A practical plan, for example 6,000 candidate conversations and budget for only 900 expert labels:
Stratify the pool by topic, segment and risk, using production proportions as the starting point.
Expert labels for high-risk strata (safety, legal, financial) and for the disagreement cases. Oversample rare but costly classes so they have enough cases to measure.
Model-assisted, human-verified labels for routine strata: a model proposes the label, a person confirms or corrects it. This is cheaper than labelling from scratch and keeps a human accountable for the final label.
Measure label quality. Double-label a slice and compute inter-annotator agreement, using kappa from section 4.3. A noisy label set caps every score you derive from it.
Keep a held-out slice that never appears in prompts or judge examples.
Exam angle. The scenario offers: label the first 900 chronologically, label a uniform random 900, let the judge label everything, or the stratified, risk-weighted plan. The stratified plan is the answer.
Common trap: Letting the judge produce the labels it will later be graded against. That measures the judge's agreement with itself.
4.9 Judge biases: position, verbosity and self-preference
Principle. An LLM judge is a model, so it has systematic preferences that have nothing to do with your rubric. Three are worth testing for by name. Position bias favours an answer because of the slot it occupies (often the first, sometimes the last). Verbosity bias favours the longer or more elaborate answer. Self-preference favours output that resembles what the judge model itself would write. Each one pushes scores in a direction that looks like a quality difference but is not.
Mechanism. Do not argue about whether a bias exists; measure it on your own judge and task.
Swap and compare. For pairwise grading, judge every pair twice, once in each order. If the verdict follows the slot instead of the answer, the judge is not measuring the answers.
Control length. Add pairs where the two answers are equally correct but differ in length, and check whether the longer one wins. Put "do not reward length" in the rubric, and where the task allows it grade each criterion separately instead of asking for an overall preference.
Separate the families. Where practical, judge with a different model from the one that produced the output (the evaluation guidance in the verification list makes the same recommendation).
Use pointwise rubrics with fixed anchors when you can: scoring one answer against criteria removes the slot from the problem entirely.
Worked example (illustrative data). A team judges 100 answer pairs in both orders. In 64 pairs the same answer wins in both orders. In the other 36 the judge picks whichever answer came first. The position-consistent rate is 64 / 100 = 64%, and 36 of the verdicts say nothing about quality. The team reports only the 64 consistent verdicts (or counts the 36 as ties), then fixes the prompt and re-measures.
Figure 6. Swap the order, then compare the two verdicts
How to read this: each pair is judged twice, once in each order. A verdict that survives the swap is about the answer, and one that flips is about the slot. In the illustrative example above, 64 pairs take the green path and 36 take the red one.
NOTE
Exam angle. A judge agrees with humans only about half the time and prefers whichever answer is shown first. Randomising or swapping the order, then comparing the two verdicts, is the first tool. Lowering the temperature does not remove a systematic preference.
Common trap: Randomising the order once and calling the bias fixed. Randomising spreads the bias evenly and adds noise; swapping and checking consistency measures it.
4.10 Judge drift and judge versioning
Principle. A judge's behaviour can change without any change to the system under test: a new judge model, an edited rubric, even a provider-side update to an unpinned model alias. Scores from before and after the change are then measured with different instruments.
Mechanism. Treat the judge as a versioned component of the evaluation, with the same discipline as the code under test.
Pin the judge model version and keep the rubric in version control. Record both, with the eval-set version, in every result.
Keep an anchor set: 100 or so human-labelled cases, never used in judge prompts or examples. Rerun it on a schedule, and always on any change to the judge or the rubric.
Track agreement over time. A fall in kappa against the anchor set (section 4.3), or a shift in the judge's pass rate on a fixed set of outputs, is drift. It is the signal to recalibrate before trusting any trend.
Dual-run on migration. When moving to a new judge, grade the same outputs with both versions for a period, compare, and re-anchor the thresholds. Never compare a score from the old judge with one from the new judge on a chart as if they shared a scale.
Separate the two causes of a score move. If the judge changed and the system did not, the move belongs to the instrument. Regrade a frozen set of old outputs with the new judge to prove it.
Worked example (illustrative data). Last month's 500 outputs scored 82% pass with judge version 1. Regrading the same 500 stored outputs with judge version 2 gives 90%. The system under test did not change, so 8 points of the apparent improvement are the judge's leniency. Without the stored outputs, the team could not have told.
TIP
Picture it: A baker swaps the kitchen scale for a new one that reads a little heavy. The loaves look heavier on paper, but the bread did not change. Before believing the number, weigh the same loaf on both scales. Regrading frozen outputs with the old and new judge is that weigh-in.
NOTE
On call, 3 a.m.: Tomasz Lindqvist leads quality at Brightloom Software, an invented company. On Monday the dashboard shows pass rate up from 82% to 90%, and a manager asks what the team shipped. Nothing shipped except a new judge version. Tomasz regrades last month's 500 stored outputs with the new judge and gets 90% again. The 8 points belong to the instrument, so he re-anchors the thresholds before anyone celebrates. Invented example.
NOTE
Exam angle. Look for "scores rose after we upgraded the judge" or "the metric moved with no code change". The answer is to regrade frozen outputs and re-measure against human labels, not to investigate the application.
Common trap: Pinning the system under test carefully while letting the judge float on an alias.
4.11 Keeping suites valid: contamination, saturation and coverage gaps
Principle. A suite that was good at launch decays. Three failure modes explain most of the decay.
Failure
What happens
Symptom
Response
Contamination
Eval cases leak into prompts, few-shot examples, fine-tuning or training data, or the team tunes the prompt against the same cases
Eval score rises, production quality does not
Keep a held-out slice that nobody tunes on; rotate in fresh cases from production
Saturation
The system passes nearly everything, so the suite cannot tell good from better
Scores sit at the ceiling, and releases look identical
Add harder cases and finer criteria; retire cases that never fail
Coverage gap
Production changes (new feature, language, document type) and the suite does not
Incidents occur in areas with no eval cases
Compare production strata with suite strata on a schedule
Mechanism. Check for contamination by comparing the held-out slice with the tuning set. If the tuning score climbs while the held-out score is flat, the team has been fitting the suite. For saturation, remember how little signal a near-perfect score carries: with 200 cases, 98% means 196 passes and 99% means 198, a difference of two cases that run-to-run variance can produce on its own. For coverage, make "every production incident becomes a regression case" a rule (the incident-to-regression-eval habit from module 3), and review the tag distribution of the suite against live traffic each quarter.
Figure 7. Three sets with three jobs
How to read this: the prompt-tuning box touches only the development set. The regression and held-out sets feed the gate directly, so tuning cannot quietly fit them.
TIP
Picture it: A student who practises on last year's exam paper and then sits the same paper scores full marks and has proved nothing. The practice paper is the development set, a fixed checklist of past mistakes is the regression set, and a sealed paper opened on exam day is the held-out set. Once the sealed paper is seen, it is practice material.
A practical hygiene list:
Separate the development set (tune on it), the regression set (never lowers, must always pass) and the held-out set (touched only at release time).
Version the sets and record which version produced each result.
Never paste held-out cases into prompts, judge examples or documentation.
NOTE
Exam angle. "The suite has passed at 99% for six months but incidents keep happening" points to saturation plus a coverage gap. Adding harder cases drawn from the incidents is the answer. Adding more easy cases is not.
Common trap: Treating a rising offline score as proof of improvement when the same cases were used to tune the prompt.
4.12 Retrieval precision and groundedness
Principle. For a retrieval-grounded answer, two things can go wrong independently: the right evidence was not retrieved, or the answer says more than the evidence supports. One end-to-end score hides which. Measure the stages separately.
Retrieval metrics need a labelled set of questions with the passages that answer each one.
Precision@k: of the k passages retrieved, the fraction that are relevant.
Recall@k: of all relevant passages that exist, the fraction found in the top k.
Worked example (illustrative data). A question has 6 relevant passages in the corpus. The retriever returns 5, of which 3 are relevant. Precision@5 = 3 / 5 = 60%. Recall@5 = 3 / 6 = 50%. Low precision fills the context with distractors; low recall means the answer cannot be correct however good the model is.
Groundedness metrics judge the answer against the retrieved text, not against the truth.
Groundedness (faithfulness): break the answer into atomic claims and check each against the retrieved passages. An answer with 12 claims, 9 supported, has groundedness 9 / 12 = 75%.
Citation accuracy: of the sources the answer cites, the fraction that really support the sentence they are attached to.
Abstention quality: when no relevant passage exists, does the system say so instead of answering?
Claim checking is usually done by an LLM judge, so it inherits sections 4.2 to 4.3: write the rubric, calibrate against human labels.
Diagnosing by stage. If recall is low, fix retrieval (chunking, embeddings, hybrid search, query rewriting). If recall is high but groundedness is low, the generator is overreaching, so tighten the prompt and the citation requirement. If both are high and users still complain, check the labels and the question coverage.
NOTE
Exam angle. A pipeline answers confidently and wrongly. The metrics tell you whether the right passage was in the context at all. Answer-level accuracy alone cannot.
Common trap: Scoring only the final answer, then tuning the prompt when the retriever is the problem.
4.13 Choosing metrics by task type
Principle. The metric must match what "good" means for the task. A metric chosen because it is easy to compute measures something else.
Task type
Primary metrics
Typical grader
Watch out for
Extraction and classification
Per-field accuracy, precision and recall per class, schema validity
Deterministic
Aggregate accuracy hiding a rare costly class (section 4.7)
Open-ended generation
Rubric scores for faithfulness, completeness, tone, safety
Calibrated LLM judge plus human sample
Verbosity and style bias (section 4.9)
Agentic, multi-step
Task success on the end state, steps and cost per success, tool-call correctness, recovery from tool errors
Deterministic check of the outcome, then trace review
Grading the path instead of the outcome, or ignoring cost
Retrieval-grounded
Retrieval precision and recall, groundedness, citation accuracy, abstention
Labels plus claim-level judge
One blended score (section 4.12)
Mechanism. For agentic tasks, grade the outcome (did the ticket get the right state, did the refund match policy) with a deterministic check where possible, because many valid paths reach one outcome. Use the trace for diagnosis, not as the score. Add guardrail metrics that must not regress: refusal rate, escalation rate, tokens per task. For extraction, report each field separately; a 95% average can mean one field at 70%.
Always pair an automatic metric with a periodic human-graded sample, because a metric can be optimised until it no longer tracks what users value.
NOTE
Exam angle. The question names a task and lists four metrics. The right one matches the failure the business cares about: recall for missed hazards, outcome success for agents, groundedness for cited answers.
Common trap: Using one LLM-judge "quality" score for every task type.
4.14 Release criteria for prompt, model and agent changes
Principle. Every change that can alter behaviour is a release: a prompt edit, a model or version change, a tool description, a retrieval setting, an agent loop limit. Each goes through the same evidence path, scaled to its risk.
Mechanism. A change type decides how much evidence you need.
Change
Minimum evidence before ship
Wording edit to a prompt
Regression set plus per-segment table
New model or model version
Full offline suite, judge recalibration if the judge is related, shadow run on live traffic, then a staged rollout
Tool or schema change in an agent
Outcome evals on multi-step tasks, tool-error handling cases, cost and step-count comparison
Retrieval or chunking change
Retrieval metrics and groundedness (section 4.12)
Wire this into CI so that the gates of section 4.5 run on every pull request that touches a prompt, a tool definition or a config. Store the result with the version identifiers of the prompt, model, tools and eval sets. A written release criterion states the numbers in advance, for example "no segment below baseline by more than 2 points, safety suite at zero failures, p95 latency within budget", so nobody has to decide after seeing the result which numbers matter.
For agents, include a behavioural check list that scores are blind to: does it stop when it should, ask for approval where required, avoid calling destructive tools without cause, and stay inside its step and cost limits?
Rollout and rollback. A passing gate allows a staged rollout, not an instant switch. Define the rollback trigger (the live metric and the threshold) before the rollout begins.
NOTE
Exam angle. A model upgrade improves the average but one segment drops. Blocking or limiting the rollout and examining the segment is correct. Shipping because the mean improved is not.
Common trap: Treating a prompt tweak as too small to need the gate. Small edits cause regressions too.
4.15 Online quality: sampling and feedback loops
Principle. Offline suites describe the past. Live traffic shows the present, and the loop that returns what you learn to the suites is what keeps them valid.
Mechanism.
Sample live traffic for grading with a rule you can defend: a fixed percentage across all traffic, plus oversampling of high-risk strata and of low-confidence or escalated sessions. Record the sampling weights so that results can be reweighted to the true traffic mix.
Grade the sample with the same graders as offline, and with humans on a smaller slice.
Collect feedback signals: thumbs, edits, escalations, retries and abandonment. Read them as indicators, not truth.
Close the loop. Failures found online become cases in the regression set; patterns become new strata; recurring failures become monitoring rules.
Bias in feedback. Explicit feedback comes from a small, self-selected group. If 2% of users leave a rating, and unhappy users are more likely to do so, the thumbs-down rate over-states dissatisfaction and tells you nothing about silent users. Implicit signals (the user re-asked the question, edited the draft heavily, asked for a human) are more numerous but ambiguous. Use both, and anchor them to a graded random sample.
Worked example (illustrative data). Of 10,000 sessions, 200 carry a rating, and 40 of those are thumbs-down: 20% of rated sessions but only 0.4% of all sessions. Neither figure is the real failure rate. A random sample of 400 sessions graded by humans gives it.
A/B and shadow together. Use shadow mode first (section 4.1), then an A/B test (section 4.6), with the graded sample and guardrail metrics reported per arm.
NOTE
Exam angle. "Thumbs-down rate fell after the release" is weak evidence by itself, because who rates may have changed. The better answer adds a graded random sample.
Common trap: Optimising for the feedback button, which measures who clicks, not what users need.
IMPORTANT
Remember this:
Shadow mode tests on real traffic without a single user seeing the candidate.
Use code to grade what code can grade, and trust a judge only after checking it against people.
An average can hide the one group that is failing, so report every segment.
Hard gates have no exceptions, and a good p-value is not proof of a good test.
When a score moves, check the instrument before you credit the change.
M4 Checkpoint
By the end of this module you should be able to:
Explain when to use an offline set, online sampling and shadow mode, and why shadow mode protects users while still using real traffic.
Choose between a deterministic validator, a rubric-based LLM judge and human review for a given quality, and treat schema validity as a hard gate that also checks stop_reason.
Compute Cohen's kappa from a 2x2 table, compare it with inter-annotator agreement, and say when a judge must be recalibrated.
Show how an under-represented segment hides failures in an aggregate score, and fix it with stratification and per-segment reporting.
Classify gates as hard, approval or advisory, and explain which can be overridden and which cannot.
Explain why statistical significance does not prove that an A/B test was representative, and handle flaky results with repeated runs.
Pick recall on the critical class when error costs are asymmetric, and compute per-group false positive and false negative rates for a fairness review.
Plan a labelled dataset under a fixed annotation budget.
Test an LLM judge for position, verbosity and self-preference bias by swapping order and controlling length, and use pointwise rubrics or a different judge family to reduce it.
Version and pin the judge, keep a human-labelled anchor set, and regrade frozen outputs to tell judge drift from a real quality change.
Keep a suite valid against contamination, saturation and coverage gaps with development, regression and held-out sets and incident-driven refresh.
Compute precision@k, recall@k and claim-level groundedness, and use them to diagnose a retrieval-grounded failure by stage.
Match the metric to the task type: extraction, generation, agentic (outcome-based) and retrieval-grounded.
Define release criteria in advance for prompt, model, tool and retrieval changes, wired into CI with rollout and rollback triggers.
Design live-traffic sampling and feedback loops, and explain the bias in explicit feedback.
Where to verify
These are the official pages this module relies on. Anthropic's products change, so confirm current behaviour there.
Lesson 5 of 10 · Claude Certified Developer — Professional
Offline and online evals, calibrating LLM judges with Cohen's kappa, stratified datasets, release gates, A/B tests, recall and fairness for Claude apps.
In the rest of this lesson
4.6 A/B tests and flaky results
4.7 Asymmetric costs and fairness
4.8 Building a dataset on an annotation budget
4.9 Judge biases: position, verbosity and self-preference
4.10 Judge drift and judge versioning
4.11 Keeping suites valid: contamination, saturation and coverage gaps
Enrolling is free. It unlocks every lesson in Claude Certified Developer — Professional, tracks your progress across devices and keeps your quiz scores. The newsletter is optional.
The domains, the 3 universal rules, core concepts, and exam-day shortcuts — one page. Enter your email and it's yours, plus my weekly AI-architecture notes.
No spam. Unsubscribe any time.
Scaled AI Weekly
Enjoyed this? Get more like it every Monday.
Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.
Get new articles by email
Free. We email a confirmation link first, and you can unsubscribe from any email.