Evaluation — study guide

The concept's fragments, read in order.

For your capstone An agent that does a task you currently do by hand

Evaluation is how you know the pipeline does your job as well as you did, and that next month's prompt edit did not quietly make it worse. Its drafts read fluently whether or not they are right, so a few hand-picked tries prove nothing. The pipeline needs a fixed set of cases, a grader for each, and a script that runs them all.

evals/sort_v3.jsonl holds 60 requests: real ones from your inbox, a blank email, one in Portuguese, and every request the pipeline ever got wrong, each with its right label. Code grades the labels. The drafts get your written rubric, applied by a model grader you first compared with your own grading of 40 drafts. After an edit the total rises from 51 to 53, but two cases that used to pass now fail, and you read those first.

Is the output actually good?

A system with a language model inside produces output nobody wrote in advance: a summary, a routed ticket, a drafted reply, a plan an agent is about to act on. The obvious way to check it is to try a few inputs and read what comes back. That feels like checking and is not, because a model's output reads fluently whether or not it is right, and a handful of hand-picked tries tells you about those tries and nothing else.

An evaluation is the repeatable replacement. It has three parts: a fixed set of cases, each an input plus a statement of what a good output looks like; a grader that turns each output into a verdict or a score; and a script that runs every case through the system, grades every result the same way, and reports the totals. Run it today and again next week and the two numbers can be compared, because nothing changed except the thing you changed.

That repeatability is the whole point, and it is harder to get than it sounds. The same input can produce a different output on the next run, graders make mistakes of their own, and a score from a few dozen cases is far less certain than it looks. The rest of this concept is how to build each part so that the number at the end means what it says.

Why a passing test is not enough

an ordinary test output from a model one input run once one output assert it equals the expected value pass or fail same input, same output, one right answer one input run it 5 times out 1 out 2 out 3 out 4 out 5 pass fail pass pass fail 3 of 5 runs pass on this one case repeat for every case a pass rate over cases and runs, not a single yes or no
An ordinary test runs one input once and asserts one expected output, giving a yes or no; a model given the same input five times produces five different outputs, three graded pass and two fail, so across every case the result is a pass rate rather than a single pass or fail.

An ordinary test rests on two assumptions. The code is deterministic, so the same input produces the same output every time, and there is one right answer, so an assertion can compare the output with an expected value exactly. Arrange, act, assert: if the test passes once, it keeps passing until someone changes the code.

A language model breaks both assumptions. Its output is sampled, so the same input can come back different on the next run. Even the settings meant to make it repeatable only reduce the variation: a serving system groups requests differently depending on load, the rounding in its arithmetic depends on that grouping, and one token that comes out differently sends the rest of the answer down a different path. And many different outputs can be right: two summaries can both be faithful while sharing hardly a sentence. An exact assertion then fails on harmless variation, and an assertion loose enough to tolerate the variation stops catching real mistakes.

So one passing run proves little; the output that passed may have been the lucky one, like judging a basketball player's free throws: one shot going in tells you very little, and the honest measure is the percentage over many attempts. The useful question moves from whether it passed to how often it passes, which is a rate over many cases and, because of the variation, over more than one run of each case.

Ordinary tests do not go away. The code around the model is still code: the part that assembles the prompt, the parser that reads the reply, the check that a structured reply matches its schema. Those parts are deterministic and get ordinary tests. The evaluation covers what is left, the model's own judgment, which no single assertion can pin down.

Building the set of cases

where the cases come from, and where they go sampled from real use looks like what will arrive deliberate edge cases empty, huge, odd, hostile every real failure so it cannot return unseen add the evaluation set each case: an input and what counts as good versioned like code most a slice kept back development set iterate against it often held-out set check it rarely a production failure becomes a new case, and the set grows
An evaluation set is fed from three sources, inputs sampled from real use, deliberate edge cases, and every real failure, and is versioned like code; it splits into a development portion you iterate against often and a held-out portion you check rarely.

Each case in an evaluation is an input plus a statement of what counts as a good output: an exact expected answer where one exists, a reference answer to compare against, or a short list of criteria the output has to meet. The set of cases is everything the evaluation can see. A failure that resembles none of the cases is invisible to it, however good the score.

Three sources fill the set. The first is real use: inputs sampled from what the system actually receives, or will receive, so the mix of easy and hard, short and long, common and rare looks like the traffic it faces. A set assembled from whatever was convenient to write down inherits the bias of any convenience sample, and more cases of the same kind will not fix it. The second is deliberate edge cases: empty input, enormous input, input in an unexpected language or format, input written to trick the system. The third is every real failure. When the system gets something wrong in use, that input and the right answer become a permanent case, like a checklist that gains a new line after every incident, so the mistake that caused it is checked for every time from then on. There is no universal size. Practitioner guides suggest a few dozen carefully reviewed cases is enough to start, with the set growing as real traffic and real failures reveal gaps, and labeling each case by task or risk lets a weak category show up instead of hiding inside the overall score.

Treat the set like code. Keep it in version control, record which version of the set produced which score, and review changes to it, because a score on a different set is a different measurement. Keep part of it apart as well, for the same reason a model's test set is held back from training: do the day-to-day tuning against a development set, and check a held-out portion only rarely. Once the tuning is done, the held-out score is the one that estimates how the system does on cases nobody tuned it for.

Four ways to grade an answer

four graders, and what each can be trusted for programmatic check comparison with a reference a model with a rubric a person with a rubric trust it for: format, exact facts, rules cannot judge: whether the content is good trust it for: closeness to a known answer fails on: right answers worded differently trust it for: judgment at scale, once checked fails on: its own biases and blind spots trust it for: the reference judgment fails on: cost, speed, people disagreeing checks cheaper, faster, judges less costlier, slower, judges more use the cheapest grader that can actually judge what the case is about
Four graders from cheapest and narrowest to costliest and broadest: a programmatic check is trusted for format and exact facts but cannot judge quality; a reference comparison measures closeness to a known answer but penalizes right answers worded differently; a model with a rubric judges at scale but has its own biases; a person with a rubric is the reference judgment but is slow, costly and inconsistent, and is what the model grader is checked against.

A grader turns one output into a verdict or a score. There are four kinds, and they trade cost against how much they can judge.

A programmatic check is code asking a question with a definite answer: does the output parse, does it match its schema, is the label one of the allowed labels, does the generated code pass its tests, is the number within tolerance of the right one, does the reply avoid a forbidden phrase? These checks are fast, free to rerun and deterministic, so they can be trusted completely for what they check. What they check is form and exact facts, not whether a summary is faithful or an explanation is clear.

A comparison with a reference measures how close the output is to a known good answer, by overlapping words or by the distance between embeddings. It works where right answers are close to unique and misleads where they are not: a correct answer phrased differently can score low on word overlap, and a wrong one that borrows the reference's wording scores high. Overlap measures shared wording, not correctness, and embedding distance measures closeness of meaning, not truth: an answer can sit very close to the reference and still get the one fact that mattered wrong.

A rubric applied by a person is the closest thing to ground truth: someone qualified reads the output against written criteria. It is slow and costly, and people grading the same output do not always agree, so the rubric has to be specific enough that two graders reach the same verdict, and their agreement is worth measuring. A rubric applied by another model scales that judgment to thousands of outputs cheaply, which is why it is common, but it brings errors of its own, and its verdicts mean little until they have been checked against people. The working rule is to use the cheapest grader that can actually judge what a case is about, and to break a vague quality into specific yes-or-no criteria wherever possible.

Who grades the grader

an imperfect grader on 1000 outputs 1000 outputs really good: 70% really bad: 30% 700 good 300 bad passed: 95% failed: 5% passed: 20% failed: 80% 665 graded pass 35 wrongly failed 60 wrongly passed 240 graded fail reported passes: 665 + 60 = 725, so 72.5 percent true rate: 70 percent, and more cases will not close the gap
An imperfect grader shifts the score: of 1000 outputs, 700 are really good and 300 really bad; the grader passes 665 of the good ones and wrongly passes 60 of the bad ones, so it reports 725 passes, 72.5 percent, when the true rate is 70 percent.

A model used as a grader is still a model: it makes mistakes, and some of them lean consistently one way. Studies of model graders have documented a preference for whichever of two answers is shown first (position bias), for longer answers whether or not they are better (verbosity bias), and, more tentatively, for answers produced by the grader's own model (self-preference). In a widely cited 2023 study, the strongest model grader then available agreed with expert judges on 85 percent of pairwise comparisons (ties excluded), while the experts agreed with each other 81 percent of the time. Yet when the same two answers were swapped, that grader gave a consistent verdict only about two times in three. A good agreement rate and a real bias can sit in the same grader.

So check the grader before trusting it, like putting a known one-kilogram weight on a kitchen scale before trusting it with anything else: if it reads wrong on the weight you know, it reads wrong on everything. Take a sample of outputs, have qualified people grade them with the same rubric without seeing the model's verdicts, run the model grader on the same sample, and compare. Have two people grade some of the same outputs, too: how often they agree with each other is the bar the model grader is measured against. Count the grader's two kinds of error separately, how often it passes an output the people failed and how often it fails one they passed, because the two push the score in opposite directions. Read the disagreements, which can expose a vague rubric as easily as a bad grader, test for the known biases by swapping answer order and padding answers, and repeat the check whenever the rubric, the grader's instructions or the grader's model changes.

The arithmetic shows why the check matters. Suppose 70 percent of outputs are truly good, and the grader passes 95 percent of the good ones but also 20 percent of the bad ones. On 1000 outputs it passes 700 x 0.95 = 665 good ones and 300 x 0.20 = 60 bad ones, and reports 725 / 1000, which is 72.5 percent. The error is systematic, so more cases make the wrong number more precise, not more right. Once the grader's two error rates have been measured, the true rate can be recovered: (0.725 - 0.20) / (1 - 0.05 - 0.20) = 0.525 / 0.75 = 0.70. The correction is only as good as those measured rates, which come from a human-graded sample with uncertainty of its own.

A pass rate comes with error bars

80 percent passed: how sure is that number? measured: 80% 100 cases plus or minus 7.8 400 cases plus or minus 3.9 1600 cases plus or minus 2.0 70% 75% 80% 85% 90% four times the cases, half the width: 1.96 x the square root of 0.8 x 0.2 / n
The same 80 percent pass rate measured on 100, 400 and 1600 cases gives approximate 95 percent intervals of about 72 to 88, 76 to 84 and 78 to 82 percent: each time the number of cases quadruples, the interval's width halves.

A pass rate measured on a set of cases is a sample proportion. The cases are a sample of everything the system will face, and a different sample would have given a somewhat different number. The typical size of that sample-to-sample movement is called the standard error, and for a pass rate it has a simple formula: the square root of p x (1 - p) / n, where p is the pass rate and n is the number of cases. The formula comes from the binomial distribution, the statistics of counting successes in n independent tries, and it says two things worth keeping. The movement is largest when the rate is near one half and shrinks as the rate nears 0 or 100 percent, and it shrinks as cases are added, but only with the square root of their number.

Take 80 passes out of 100 cases. The standard error is the square root of 0.8 x 0.2 / 100, which is the square root of 0.0016, so 0.04, or 4 percentage points. An approximate 95 percent interval reaches 1.96 standard errors either side of the estimate, 1.96 being the normal-curve cutoff (1.95996, rounded) behind the rounder two-standard-deviations rule: 1.96 x 0.04 = 0.0784, so the interval runs from about 72 to 88 percent. The honest report is 80 percent, plus or minus about 8 points. Because n sits under a square root, quadrupling the cases halves the width: 400 cases give plus or minus about 3.9 points, and 1600 cases plus or minus about 2.0.

That interval is the normal approximation, a rule of thumb that degrades with few cases or with a rate near 0 or 100 percent. The Wilson interval behaves better there, and for 80 of 100 it gives about 71 to 87 percent. The breakdown is easiest to see at the extreme. If all 20 of 20 cases pass, the simple formula gives a standard error of zero and an interval of exactly 100 percent, which is nonsense. Ask instead which failure rates would make 20 straight passes plausible: if the true failure rate were 13.9 percent, each case would pass with chance 0.861, and because the chances of independent events multiply, 20 passes in a row would have chance 0.861 to the 20th power, about 0.05. A perfect 20 out of 20 is therefore consistent with failing about one time in seven: 13.9 percent is the one-sided 95 percent upper bound on the failure rate. The rule of three gets there faster: with zero failures in n cases, the one-sided 95 percent upper bound on the failure rate is roughly 3 / n, here 3 / 20 = 0.15.

Running each case more than once

Because the same input can produce a different output, one run per case mixes two kinds of luck: which cases happen to be in the set, and which output each case happened to produce this time. Running every case several times pulls them apart. A case that passes 5 runs out of 5 is solid, one that passes none is a consistent failure, and one that passes 3 of 5 is flaky, which is often among the most useful things an evaluation finds, because users will meet both behaviors.

Repeated runs steady each case's score, but they do not multiply the evidence. Five runs of 100 cases are not 500 independent cases: the runs of one case share that case's difficulty, so they agree with each other more than different cases do. Average each case's runs into a per-case score first, then compute the uncertainty over the 100 cases. Treating the 500 runs as independent produces an interval narrower than the evidence supports. More runs per case shrink the run-to-run noise; only more cases shrink the uncertainty about which cases happened to be chosen.

The per-run pass rate is also not the only number worth reporting, because what matters depends on how the output is used. Suppose a case passes 90 percent of runs, independently. The chances of independent events multiply, so all 5 runs fail with chance 0.1 multiplied by itself 5 times, 0.1^5 = 0.00001. If a person can retry and keep the first good answer, at least one of 5 runs passes in every other outcome, a chance of 1 - 0.1^5 = 0.99999. If the system has to be right every time, the chance that all 5 runs pass is 0.9^5 = 0.59049, about 59 percent. Code-generation benchmarks commonly report the first kind of number, written pass@k; agent benchmarks have added the second, written pass^k, to measure consistency. The gap is not hypothetical: the benchmark that introduced pass^k reported an agent built on a 2024 model that averaged about 61 percent success on a single run of a simulated retail customer-service task but succeeded on all 8 of 8 tries less than 25 percent of the time. One system, one per-run rate, very different headlines, so report the one that matches how the output will actually be used.

Did the change make it worse?

the same 100 cases, before and after a change after the change pass fail before the change pass fail 76 pass both times 4 broken by the change 9 fixed by the change 11 fail both times 80 before = 76 + 4 85 after = 76 + 9 the totals say plus 5; the evidence is the 13 cases that flipped 9 fixed against 4 broken: read each of the 13
The same 100 cases graded before and after a change: 76 pass both times, 11 fail both times, 9 failed before and pass after, and 4 passed before and fail after; the totals move from 80 to 85 passes, and only the 13 flipped cases carry information about the change.

An evaluation earns its keep when something changes: a reworded prompt, a newer model version, a different setting, an added tool. Rerun the whole set against the candidate and compare it with the stored results of the current version, the baseline. For the comparison to mean anything, everything not under test stays pinned: the same version of the set, the same grader and rubric, the same model version and settings. Change two things at once and the difference belongs to neither. Running the evaluation automatically on every change to a prompt or a model, the way a test suite runs on every change to code, turns this from an event into a habit; a common split is a fast subset on every change and the full set before a release.

Compare case by case, not only in total. Suppose the baseline passes 80 of 100 cases and the candidate passes 85. The totals hide what happened: 76 cases passed both times, 11 failed both times, 9 were fixed by the change and 4 were broken by it. Those 4 are regressions, and reading them matters more than the net gain, because a change that fixes one kind of request while breaking another is a trade someone should decide to make on purpose.

Nor is plus 5 strong evidence. Only the 13 cases that flipped say anything about the change, and if the change did nothing, each flip would be as likely to go one way as the other, like a fair coin. Thirteen flips can fall in 8192 equally likely ways, which is 2 multiplied by itself 13 times, and 2 x 1093 of those ways split at least as unevenly as 9 to 4 in one direction or the other. So the chance of a split this lopsided from a coin that favors neither side is 2 x 1093 / 8192, about 0.27: more than a quarter of the time, a change that does nothing produces a gap like this one. Scoring the versions on separate cases is no kinder. Each pass rate carries its own sampling uncertainty, its standard error, and when the two are measured on separate cases the uncertainties combine by adding under one square root. The standard error of the difference between 80 and 85 percent on 100 cases each is the square root of 0.8 x 0.2 / 100 + 0.85 x 0.15 / 100, about 0.054, so a gap would need to exceed 1.96 x 0.054, about 10.5 points, to stand out at the 95 percent level.

How many cases would it take? To detect a real 5-point gap between 80 and 85 percent four times out of five, the standard sample-size formula for two separate groups asks for (1.96 + 0.84)^2 x (0.8 x 0.2 + 0.85 x 0.15) / 0.05^2 cases per version, which is 7.84 x 0.2875 / 0.0025 = 901.6, so 902 each, where 0.84 is the normal-curve cutoff that buys the four-in-five chance. A slightly more careful version of the formula gives about 905; either way, roughly 900 cases per version. Scoring both versions on the same cases and counting the flips needs fewer, because cases that pass or fail both times cancel out of the difference. That makes the same set work harder; it does not make 100 cases able to tell 80 percent from 85.

How an evaluation lies to you

tuning a prompt against the same cases, revision after revision score prompt revisions, each tuned on the development set development set (tuned against) held-out set (never tuned on) the gap is overfitting to the set shape only: the lines are illustrative, not measured
Across successive prompt revisions, the score on the development set the prompt was tuned against keeps climbing, while the score on the held-out set rises a little and then flattens; the widening gap between them is the prompt overfitting to the evaluation set.

An evaluation produces a number with the authority of a measurement, and it can be wrong in ways the number does not show. The first is too few cases. On 30 cases, a single case is worth more than 3 percentage points, and a rough 95 percent interval around an 80 percent pass rate is about 14 points either side, 1.96 times the square root of 0.8 x 0.2 / 30, which is 0.143. A 5-point improvement on a set that size cannot be told apart from noise. A small set is still worth having, since it catches large failures and shows what to fix, but it cannot rank two close versions.

The second is overfitting the prompt to the set. Each time a prompt is adjusted to fix the cases that failed, a little of the set leaks into the prompt. After enough rounds the prompt is tuned to these particular cases, and the score on them keeps climbing while performance on anything else does not, like a class drilled on last year's exam questions: the scores on that exam rise every week while understanding of the subject stays where it was. This is overfitting in the same sense it has for a trained model, and the defense is the same: a held-out portion that tuning never touches, and fresh cases added over time. Public benchmarks suffer a larger version of the problem, since their questions can end up in a model's training data, which is one reason a set built from your own system's inputs says more about your own system than a public leaderboard does.

The third is a grader that is wrong: a reference answer with a mistake in it, a programmatic check that tests format and passes nonsense, a model grader with a bias nobody measured. A wrong grader is a biased instrument, and its error does not average away. The fourth is drift: the set matched last quarter's inputs, users moved on, and the score stays high while real quality falls. The last is optimizing the number for its own sake. Once a score becomes the target, it is easy to raise it without raising what it stood for, the effect known as Goodhart's law. None of the five shows up in the score itself. They show up when someone regularly reads actual outputs, passing and failing, and keeps adding fresh cases from current use, instead of only watching the number.

Change it without guessing

Any system with a model inside, whether an agent working through a pipeline of steps or a feature in an app running in production, will be changed. Prompts get reworded, models get replaced by newer versions, tools get added. Without an evaluation, each change is judged by trying a few inputs and deciding it looks fine, which is exactly the method fluent output is best at fooling. With one, a change becomes a measured claim: run the set, compare with the baseline, read the cases that flipped.

It is the same bargain testing offers for code. Tests let you edit without fear because they catch the edit that breaks something; an evaluation does that for the part of the system no assertion can pin down, and it has to account for what tests never had to: output that varies from run to run, graders that can be wrong, and scores built on samples small enough to fool you.

The loop closes in production. Failures that users hit become new cases, and inputs sampled from current traffic keep the set looking like real use. Before a model-driven component is trusted with more, the same discipline extends naturally: replay past cases with only the information that was available at the time, and run it in shadow, its output recorded and compared with what people actually decided rather than acted on. A system you can measure is one you can improve on purpose; one you cannot is one you change and hope.

Next on your path to An agent that does a task you currently do by hand: