Evals for LLM features and agents
- Build an eval set from real questions, and grade each kind with code, a rubric or people
- Report a pass rate with its interval, and compare two models on the same questions with a paired difference
- Split results by kind of question, and work out how many questions a decision needs
- Measure an agent with pass@k and pass^k, and say which one a product needs
- Set an LLM judge's thresholds with a band for people, and name the biases to test for
Comparing models, the way the eval round asks
A prep site reports an OpenAI ML engineer round that was billed as system design and turned into agent harness and eval design (1 report), and an Airbnb candidate was asked how they designed an LLM judge and set its thresholds (1 report). Under both sits the same arithmetic, and this lesson's practice problem builds it, in three levels:
pass_rate_ci(passed): one model's pass rate and its 95% interval.paired_difference(a, b),verdict(a, b)andquestions_needed(split, half_width): two models on the same questions, a decision only when the interval clears zero, and how many questions a decision takes.pass_at_k(n, c, k)andpass_hat_k(n, c, k): from several tries per task, the chance that any try works and the chance that every try does.
Call Returns pass_rate_cion 372 passes of 400(0.930, 0.905, 0.955) verdict(sonnet, haiku)on the same 400"a better": 3.0 points ahead, give or take 2.5 questions_needed(13 / 120, 0.02)1,041 pass_hat_k(10, 6, 3)0.167: 3 tries drawn from 6 passes in 10
The lesson follows the outdoor shop deciding whether Haiku can take its easy support questions: the eval set, one pass rate, two models on the same questions, several tries per task, and model judges. Seven steps end with a small task in the editor.
An eval is a fixed set of questions, and a way to grade each answer
The outdoor shop wants to move its easy support questions from Sonnet to Haiku, the smaller model that costs a twentieth as much. The open question is whether customers would get worse answers. An eval answers it before any customer does: a fixed set of questions, a grader for each answer, and a pass rate that you can compare between models, prompts and releases.
Anthropic hires research engineers to design, run and analyze evaluations at scale (1 source).
The shop samples 400 questions from a month of logs. They fall into three kinds, and each kind gets its own grader:
| Kind | Questions | Grader | A pass |
|---|---|---|---|
| Order status | 160 | code, against the order record | the right status and delivery date |
| Returns | 120 | a model, with a rubric | the 30-day window and the right next step |
| Product fit | 120 | a model, with a rubric | a recommendation that fits the stated use |
Where should the eval's questions come from?
Grade with code where you can, a rubric where you can't, and people to check both
Anthropic's eval docs rank the graders. Code-based grading is fastest and most reliable, extremely scalable, but it lacks nuance for judgments that aren't rule-based. A model grader handles those, given a detailed, clear rubric. People are the slowest and the ground truth the other two get checked against.
An order-status answer has facts a program can check against the order record:
record = {"status": "shipped", "arrives": "Nov 21"}
for answer in ("Your order has shipped and arrives Nov 21.",
"Good news, it's on its way to you!",
"Shipped. It should arrive Nov 12."):
print(grade_order(answer, record), "|", answer)
Which of the three answers pass?
A pass rate on 400 questions, and how sure it is
Until the shop runs its eval for real, a simulation stands in. Each question gets one hardness that both models face, with order questions easiest and fit questions hardest, plus a little luck for each model. Sonnet is set to be slightly stronger. The code then grades both models on all 400 questions.
A pass rate on 400 questions is an estimate of the rate on all the questions customers will ever ask. The standard error says how far that estimate tends to land from the truth: the square root of p × (1 − p) / n for a rate p on n questions. Anthropic's statistics guide for evals asks for it next to every eval score, and builds the 95% interval by adding and subtracting 1.96 times it. pass_rate_ci returns the rate and that interval. Gaps between rates are in percentage points, or points for short: 93% against 90% is 3 points.
import math
import random
rng = random.Random(28)
# what each question asks about
kinds = ["order"] * 160 + ["returns"] * 120 + ["fit"] * 120
# how hard each kind can get
reach = {"order": 0.8, "returns": 1.0, "fit": 1.3}
# True: the answer passed
sonnet, haiku = [], []
for kind in kinds:
# one hardness that both models face
hard = rng.random() * reach[kind]
sonnet.append(hard + 0.1 * rng.gauss(0, 1) < 1.0)
haiku.append(hard + 0.1 * rng.gauss(0, 1) < 0.93)
for name, passed in (("Sonnet", sonnet), ("Haiku", haiku)):
p, low, high = pass_rate_ci(passed)
print(f"{name}: {p:.1%}, 95% interval {low:.1%} to {high:.1%}")
Sonnet passes about 93% and Haiku about 90%. Do their 95% intervals overlap?
Compare two models question by question
Both models answered the same 400 questions, so compare them question by question.
# 1, 0 or -1 for each question
diffs = [int(s) - int(h) for s, h in zip(sonnet, haiku)]
mean, paired_half = paired_difference(sonnet, haiku)
ps, ph = sum(sonnet) / len(sonnet), sum(haiku) / len(haiku)
unpaired_se = math.sqrt(ps * (1 - ps) / len(sonnet) + ph * (1 - ph) / len(haiku))
print(f"Sonnet only {diffs.count(1)}, Haiku only {diffs.count(-1)}, both alike {diffs.count(0)}")
print(f"difference {mean:.1%}, paired ± {paired_half:.1%}, unpaired ± {1.96 * unpaired_se:.1%}")
Both models answered the same 400 questions. Most questions are easy for both or hard for both. Which interval for the difference is narrower?
Split the result by kind of question
The 400 questions hold three kinds, and the models may differ on only some of them.
for kind in ("order", "returns", "fit"):
s = [x for x, k in zip(sonnet, kinds) if k == kind]
h = [x for x, k in zip(haiku, kinds) if k == kind]
m, half = paired_difference(s, h)
print(f"{kind:8} {len(s)} questions: Sonnet minus Haiku {m:+5.1%} ± {half:.1%}")
Overall Sonnet leads by 3 points. On the 160 order-status questions, what do you expect?
Halving the interval takes four times the questions
When the difference is small next to how often the models split, the variance of a question's difference is about the share they split on. So the half-width is about 1.96 times the square root of that share over n, and n follows from the half-width you want.
returns = [x for x, k in zip(diffs, kinds) if k == "returns"]
# share of questions the models split on
split = sum(x != 0 for x in returns) / len(returns)
print(f"returns split {split:.1%} of the time: {questions_needed(split, 0.02):,} questions for ± 2 points")
The 120 returns questions give ± 5.8 points. To get down to ± 2 points, about how many returns questions do you need?
pass@k asks whether any try worked, and pass^k whether every try did
An agent that books returns for the shop succeeds on a task 75% of the time, and each try is independent.
for k in (1, 3, 8):
print(f"k = {k}: pass@k {1 - (1 - 0.75) ** k:.3f}, pass^k {0.75 ** k:.3f}")
What's the chance it succeeds on all 3 of 3 tries?
Count from real tries instead of assuming they're independent
Real tries aren't independent: a task the agent misunderstands, it tends to misunderstand every time. So run each task n times, count the c that pass, and ask what share of the ways to pick k of those n tries contain a pass, or contain only passes. HumanEval did this with n = 200 samples per task.
print(f"pass@3 {pass_at_k(10, 6, 3):.3f}, pass^3 {pass_hat_k(10, 6, 3):.3f}")
An agent passed 6 of 10 tries on a task. Drawing 3 of those tries, about how often are all 3 passes?
Pick the lowest score that still keeps the accepted answers good enough
The shop's returns grader is a model that scores each answer from 1 to 5. A person checked 200 of those answers, so for each one the shop knows the judge's score and whether the answer was really good. Airbnb asked a candidate exactly how they designed such a judge, set its thresholds and handled ambiguous cases (1 report).
The 200 checked answers are simulated too: 85% good, and the judge's score is noisy around 4.3 for good answers and 2.4 for bad ones.
rng = random.Random(5)
# (judge score 1 to 5, a person says it's good)
judged = []
for _ in range(200):
good = rng.random() < 0.85
judged.append((min(5, max(1, round(rng.gauss(4.3 if good else 2.4, 0.8)))), good))
for t in (5, 4, 3, 2):
kept = [good for score, good in judged if score >= t]
print(f"accept {t} and up: {len(kept) / len(judged):4.0%} of answers, {sum(kept) / len(kept):5.1%} of those good")
The shop needs at least 95% of the answers its judge accepts to be good. What's the lowest score it can accept?
Judges have known biases, so test for them
The MT-Bench paper found strong model judges matched human preferences over 80% of the time, the same level at which people agree with each other. It also named the biases to test for: position, verbosity and self-enhancement. A judge may prefer whichever answer it reads first, the longer answer, or answers written by its own model.
Test each one on your own labeled answers: swap the order of two answers, pad an answer with words that add nothing, and score answers from the judge's own model against people. The rag-support lesson shows how to measure a judge's agreement with people and correct the share it flags before you report it.
In the editor, write lowest_threshold(judged, min_good), the threshold search from the step before as a function. It prints the threshold for two bars: 95% and 85% good.
A worked example: can Haiku take the shop's easy questions?
The prompt: moving the shop's easy questions to Haiku would cut the bill by thousands a month. Decide which questions can move, and how you'd know nothing got worse.
1. Clarify. Which questions count as easy? What's the bar: say, Haiku no more than 2 points worse, at 95% confidence, on any kind of question that moves. Which mistake hurts most? Here, a wrong return policy, since it costs the shop money and a customer's trust.
Why fix the bar before you run the eval?
Decide kind by kind, on paired results
3. The plan. The 400 questions from real traffic, code grading for order status, rubric grading for returns and fit, both models on every question, paired differences by kind:
- Order status: Sonnet minus Haiku is −0.6 points, give or take 2.1. The interval reaches at most 1.5 points in Sonnet's favor, inside the 2-point bar. Move these to Haiku.
- Returns: Haiku 4.2 points behind, give or take 5.8. The eval can't rule out a gap bigger than the bar, and this is the costly mistake. Keep them on Sonnet, and grow the returns questions toward the thousand it would take.
- Product fit: Haiku 6.7 points behind, give or take 5.0. Keep them on Sonnet.
4. Gate every change. The eval now runs on every prompt edit and model update. OpenAI's guide puts it as a rule: set up continuous evaluation to run evals on every change, and grow the eval set over time. A change that drops order status below the bar doesn't ship.
5. Then test with customers. An eval is a lab result. Ship the order-status move behind an A/B test on the support numbers the shop already tracks, like the share of conversations that end with a human agent, as the ab-test lesson sets one up.
Grading an agent: the outcome or the path
An agent takes many steps to reach an answer, so you can grade the answer, the steps, or both.
Your returns agent reached the right refund, but called the order lookup tool three times instead of once. Does it pass?
Three more follow-ups on the numbers
Three shorter follow-ups come up too: questions that come in groups, answers that reason first, and a judge's written reasons.
Questions that come in groups need a wider interval
When several questions come from one source, like five questions about one long policy, their results move together. Anthropic recommends clustering standard errors on that unit, such as the passage of text, and the interval grows to match. Counting 5 linked questions as 5 independent ones overstates what you know.
Answers that reason before they answer get sampled more than once
For evals where the model reasons step by step, Anthropic recommends resampling each question several times and using the question's average as its score. One sample per question adds the model's own randomness to the noise.
Netflix's judge writes down why
Netflix's LLM judge grades a generated explanation pass or fail and writes a rationale (1 source). The rationale is what a person reads in the middle band, and what tells you a judge has drifted.
The practice problem, start to finish
That's every piece the practice problem needs. It asks for the three levels from the start of the lesson, from a blank file, and the interviewer follows up after each one.
1.A model passes 180 of 200 questions. What's the 95% interval for its pass rate, roughly?
2.Two prompts score 84% and 87% on the same 300 questions. How should you compare them?
3.A support agent succeeds on a task 3 times in 4. Many customers bring that task, and each gets one try with no retry. Which number tells you how reliably the agent serves them, and which one would mislead you?
4.After a prompt change, answers get longer, and your LLM judge's average score rises. Nothing else changed. What do you check first?
5.Overall, Haiku is 3 points behind Sonnet with a paired interval that clears zero. Most of your users ask order-status questions. What do you do?
Where this shows up
The reports behind this lesson, each with its source.
Research Engineer, Post-Training Model Evaluations asks for experience designing, running and analyzing evaluations of ML models at scale.
“Have designed, run, and analyzed evaluations for ML models at scale”
OpenAI evaluates its data agent by comparing both the generated SQL and the resulting data, graded with OpenAI's Evals.
“we compare both the SQL and the resulting data, and feed these signals into OpenAI’s Evals grader.”
LLM-as-a-judge (2026): Netflix's judge grades a generated explanation pass or fail and writes a rationale.
“evaluates an explanation and returns a pass/fail label together with a written rationale”
Practice
Sources (17)
- Demystifying evals for AI agents · Anthropic Engineering · Jan 9, 2026
“In reality, 20-50 simple tasks drawn from real failures is a great start.”
- Define success criteria and build evaluations · Claude Platform Docs (Anthropic) · Nov 19, 2026
“Code-based grading: Fastest and most reliable, extremely scalable, but also lacks nuance for more complex judgments that require less rule-based rigidity.”
- Define success criteria and build evaluations · Claude Platform Docs (Anthropic) · Nov 19, 2026
“Have detailed, clear rubrics: “The answer should always mention ‘Acme Inc.’ in the first sentence.”
- A statistical approach to model evaluations · Anthropic Research · Nov 19, 2024
“we encourage researchers to report the SEM, derived from the Central Limit Theorem, alongside each calculated eval score”
- A statistical approach to model evaluations · Anthropic Research · Nov 19, 2024
“A 95% confidence interval can be calculated from the SEM by adding and subtracting 1.96 × SEM from the mean score.”
- A statistical approach to model evaluations · Anthropic Research · Nov 19, 2024
“Since the question list is shared across models, conducting a paired-differences test lets us eliminate the variance in question difficulty and focus on the variance in responses.”
- A statistical approach to model evaluations · Anthropic Research · Nov 19, 2024
“In practice, we find the correlation of question scores on popular evals between frontier models to be substantial ... between 0.3 and 0.7”
- A statistical approach to model evaluations · Anthropic Research · Nov 19, 2024
“When the inclusion of questions is non-independent, we recommend clustering standard errors on the unit of randomization (for example, passage of text)”
- A statistical approach to model evaluations · Anthropic Research · Nov 19, 2024
“If an eval uses chain-of-thought reasoning, we recommend resampling answers from the same model several times, and using the question-level averages as the question scores”
- Evaluating Large Language Models Trained on Code · OpenAI (Chen et al.), arXiv 2107.03374 · Jul 7, 2021
“To evaluate pass@k, we generate n ≥ k samples per task (in this paper, we use n = 200 and k ≤ 100), count the number of correct samples c ≤ n which pass unit tests, and calculate the unbiased estimator”
- τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains · Sierra (Yao et al.), arXiv 2406.12045 · Jun 17, 2024
“We also propose a new metric (pass^k) to evaluate the reliability of agent behavior over multiple trials.”
- τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains · Sierra (Yao et al.), arXiv 2406.12045 · Jun 17, 2024
“Our experiments show that even state-of-the-art function calling agents (like gpt-4o) succeed on <50% of the tasks, and are quite inconsistent (pass^8 <25% in retail).”
- Demystifying evals for AI agents · Anthropic Engineering · Jan 9, 2026
“If your agent has a 75% per-trial success rate and you run 3 trials, the probability of passing all three is (0.75)³ ≈ 42%.”
- Demystifying evals for AI agents · Anthropic Engineering · Jan 9, 2026
“So as not to unnecessarily punish creativity, it’s often better to grade what the agent produced, not the path it took.”
- Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena · Zheng et al., NeurIPS 2023 Datasets and Benchmarks, arXiv 2306.05685 · Jun 9, 2023
“We examine the usage and limitations of LLM-as-a-judge, including position, verbosity, and self-enhancement biases, as well as limited reasoning ability, and propose solutions to mitigate some of them.”
- Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena · Zheng et al., NeurIPS 2023 Datasets and Benchmarks, arXiv 2306.05685 · Jun 9, 2023
“Our results reveal that strong LLM judges like GPT-4 can match both controlled and crowdsourced human preferences well, achieving over 80% agreement, the same level of agreement between humans.”
- Evaluation best practices · OpenAI API docs · Nov 19, 2026
“Set up continuous evaluation (CE) to run evals on every change, monitor your app to identify new cases of nondeterminism, and grow the eval set over time.”