deep · 7 min
Evals
Tests for AI features: a fixed set of inputs, a way to score each output, and a number you track across changes.
updated 27 Sept 2026
Say we've built a small feature: it reads a support ticket and labels it
billing, bug or account. We tried it on a few tickets and it looked
right. Then someone tweaks one line of the prompt to fix a ticket it got
wrong. Did the tweak help? Did it break the tickets that used to work?
Without a test, we'd find out when users complain. An eval lets us find out first.
Making it a test
Let's turn the ticket sorter into a test. We collect 30 real tickets and write down the label each one should get. We run the prompt on all 30. For each output we check whether it matches the expected label, after trimming spaces and lowercasing. Say 27 match. Our score is 90%.
That's an eval, and every one has the same three parts. There's a fixed set of test cases (often called tasks), each with what a good answer looks like. There's a grader, the logic that scores one output; here it's an exact match, but it could be a regex, a JSON check, another model or a person. And there's the number over the whole set.
After the tweak, we run the same 30 again and compare. If the score drops, we caught it before it shipped. That's what treating prompts as code means in practice: a prompt change goes through its evals the way a code change goes through its tests.
So it's a unit test?
Close, but three things differ, all because the same input can give different outputs from run to run (that's sampling, and it's one of the known weak spots of LLMs).
First, one run of a case tells us little, so we run each case a few times and look at the rate. Two ways of counting help here. pass@k is the chance that at least one of k tries works, which suits tools where one good answer is enough. pass^k is the chance that all k tries work. A task that works 75% of the time passes three in a row only about 42% of the time. For something customers use, where they expect it to work every time, that second number is the honest one.
Second, the score doesn't need to be 100%. How many failures we accept is a product decision.
Third, the grader can be wrong, especially one that's a model. It's a guess that needs checking itself.
One more thing people mix up. "Evals" also gets used for benchmarks, like MMLU or GPQA Diamond, which compare general models on shared tasks. Those help pick a model to start with. They can't tell us whether our feature works, because they know nothing about our data, prompt or tools. Think of an agent that cancels orders. What matters is whether it picked the right order and waited for the cancel to succeed before saying it was done. No benchmark checks that. Here we mean evals for our own product.
Picking a grader
There are three kinds of grader. Code is fast, cheap and gives the same result every time, but it fails a right answer worded differently. A model handles open-ended text, but its verdicts vary too, it costs more, and it has to be checked against people. People judge best, and are slow and expensive.
So the advice from every direction is the same: use code wherever a clear rule can decide, a model grader where you need judgment, and people to check the other two. A label from a fixed list? Exact match. An internal ID that must never reach the user? A regex that fails if one shows up. Valid JSON in a set shape? Parse it and check the fields. Tone, or "did it answer the question"? A model with a clear rubric, ideally yes or no per point.
For agents, grade what came out, not the path taken. For a flight-booking agent, what matters is whether the booking exists in the database, not which tools it called or whether its last message said "booked".
Building the first set
How many cases do we need? Fewer than you'd think. Early on, each change makes a big difference, so 20 to 50 tasks is enough to see it. The usual mistake is waiting.
Start by writing down what "good" means in terms you can measure: picks the right label, answers in under two seconds. That's success criteria.
Then read outputs before writing any tests. Log what the feature does (each logged session is a trace) and read about 100 varied ones, the first 30 at least yourself, before letting any tool suggest problems. Jot a note on anything wrong, then group the notes and count them. That's error analysis, and the list you end up with, the ways your app actually fails, tells you which evals to write. Stop when new traces stop showing new kinds of failure. No users yet? Have an LLM write realistic inputs and read those (synthetic test data).
Now collect the tasks. The checks you already do by hand before a release are a good start, plus the failures you just found. Once there are users, the bug tracker and the support queue are the best source. Put in the messy stuff people send: typos, a one-word "returns", two questions at once.
A good task is one where two experts would reach the same pass or fail on their own. If they wouldn't, fix the task, because ambiguity in the task turns into noise in the score. And test both directions. If every case checks that the feature does something, you'll push it to do that thing all the time. An assistant with web search needs cases where it should search (today's weather) and cases where it shouldn't (who founded Apple).
Then run it on every change and keep the score next to the prompt and model version. The first run is your baseline. Every new failure becomes a new task, so the set grows with the product.
Once the set is going, split it. A regression set holds what the feature already handles and should sit near 100%; a drop means something broke. A capability set holds what it can't do yet, and starts low. That's the one that shows progress, and it's what you run first when a new model comes out. A set everything passes still catches breakage, but it can't show you getting better.
Where it gets murky
How many cases, and how carefully graded? Some advice says many cases with noisier automatic grading beat a few graded by hand. Other advice puts the value in reading traces closely. Both hold: reading tells you what to test, and volume shows small differences once you know.
Pass or fail, or a score out of 5? People who label a lot of data find yes or no much easier to manage, though some guides average a 1-to-5 score. It isn't settled.
And an eval set only knows what you put in it. A set that doesn't look like real traffic can pass while users hit failures it never tried. That gap is what online evals and production monitoring cover, and agents add their own wrinkles (agent evals). For a retrieval feature, test the search step on its own too, which is retrieval evaluation.
When the score surprises you
When Anthropic first ran Claude Opus 4.5 on one coding benchmark, it scored 42%. Part of that was the grader: it expected "96.124991…" and rejected "96.12". After fixing grading bugs and loosening the agent's setup, it scored 95%. A low score can mean a broken task or a grader turning down right answers.
So back to our ticket sorter at 90%. Before we decide what that number means, we open the three tickets it got wrong and read them. Maybe the model's wrong. Maybe our expected label was.
Further reading
- Your AI Product Needs Evals, Hamel Husain, 2024. The classic case for evals, told through a real product that got stuck until it had them. Start here.
- Demystifying evals for AI agents, Grace, Hadfield, Olivares and De Jonghe (Anthropic), 2026. The clearest step-by-step path from nothing to a first set, plus pass@k, pass^k and the 42%-to-95% story.
- Define success criteria and build evaluations, Anthropic docs. Worked grader examples with code, if you want to see one for each kind.
- Evaluation best practices, OpenAI docs. A second vendor's process and a good list of edge cases to include. (OpenAI's hosted Evals platform goes read-only on 2026-10-31, so keep your set in your own repo.)
- Q: What are AI Evals?, Hamel Husain and Shreya Shankar, 2025. Short, and the clearest on benchmarks versus product evals.
- Q: How many examples do I need for an eval?, Hamel Husain and Shreya Shankar, 2026. The numbers for each stage, from traces to read to the size of the set you rerun.