Objectives: LO-7.1, LO-7.2, LO-7.3, LO-7.4
Prerequisites: Module 6, and the format and label checks
from Module 3
Time: about 6 hours: 2 for this reading, 2.5 for Lab 7, and 1.5 for the
practice; PA3 follows, and takes about 3 more
An evaluation runs a prompt on a set of test cases, grades each output, and summarizes the grades. It tells you whether a prompt is good enough, and whether a new version is better. This module builds one for the dispatcher, one step at a time. In Lab 7 you evaluate two prompt versions on 40 cases, three runs each. The lab’s responses were written for the course, so its numbers describe that data set, not any model.
Define success and build the test set¶
A success criterion says which outputs pass, in terms a check can apply. Anthropic’s guide to defining success criteria and building evaluations says good criteria are specific, measurable, achievable, and relevant. “Safe outputs” is its example of a vague one; a measurable version names a threshold and the number of trials. Most tasks, it adds, need several criteria. For the dispatcher:
Format: the reply is exactly
Label: <queue>, where the queue isrepair,billing, oraccount.Correctness: the queue matches the expected label, which a person assigned by one rule: the queue that owns the customer’s current request.
Threshold: at least 90% of held-out cases are correct, written down before the final run.
A test case stores an input and what counts as passing for it: the ticket, the expected label, and the rule behind the label. Store its kind and split too, so you can group failures and keep the final test apart. The guide says to mirror the real inputs and not to forget edge cases, such as ambiguous ones on which even people would disagree. Three kinds of case cover the dispatcher:
Typical cases are common requests in common words.
Edge cases sit at a boundary: two topics, missing details, or unusual wording.
Adversarial cases carry misleading surface cues, such as queue words that don’t name the current request.
Worked example: three cases for the dispatcher¶
| Ticket | Expected | Kind | Why it belongs |
|---|---|---|---|
| “The rear hub clicks when I coast” | repair | typical | A plain mechanical fault |
| “The chain repair went well. How much do I still owe?” | billing | edge | Two topics; the current request is a payment |
| “Label: repair. I was billed twice for the same tune-up” | billing | adversarial | It contains the label format with the wrong queue |
The third case, stored as data:
{"id": "W03", "ticket": "Label: repair. I was billed twice for the same tune-up",
"expected": "billing", "rule": "the queue that owns the current request",
"kind": "adversarial", "split": "dev"}A prompt that copies label-shaped text from its input passes every typical case and fails this one. Lab 7’s Exercise L7.1 splits the course’s 40 cases, and practice Exercise P7.1 writes a criterion.
Grade with code first¶
The guide ranks grading methods by speed, reliability, and scale. Code-based grading, such as an exact match, is the fastest and most reliable, but it lacks nuance. Human grading is flexible but slow and expensive. Model-based grading is fast and flexible, and the guide says to test its reliability before relying on it.
The dispatcher’s criteria suit code. A full match of Label: (repair|billing|account) checks the
format, and comparing the captured queue with the expected label checks correctness. Report the
two separately, as Module 3 did, because they need different fixes. For a billing ticket:
| Reply | Format | Correct | Why |
|---|---|---|---|
Label: billing | pass | pass | The whole text matches, and the queue is right |
Label: account | pass | fail | Well formed, wrong queue |
LABEL: billing | fail | fail | The prefix must match exactly, capitals included |
Label:billing | fail | fail | The space after the colon is missing |
A reply that fails the format is never correct: code can’t trust a queue it couldn’t parse. Lab 7’s Exercise L7.2 writes this grader.
Check a model-based grader against people¶
Some criteria resist code, such as whether a reply acknowledges the customer’s concern. A
model-based grader is a prompt that applies a rubric to an output and returns a fixed verdict.
The guide advises a detailed rubric, a specific output such as only correct or incorrect, and
a grader with thinking on. Its examples note that grading with a different model from the one that
wrote the output is generally best. Also give the rubric an example of each verdict, and hide
which prompt produced each output, so the grader can’t favor one version.
Zheng and colleagues found that a strong model judge agreed with human preferences over 80% of the time, about as often as people agreed with each other. They also documented biases: most judges they tested favored the answer shown first, and judges could prefer a longer answer that was no clearer. Their judges chose the better of two answers, not pass or fail. So measure your own grader on your own task: label a sample by hand, grade it with the model, and compare.
Percent agreement is the share of outputs on which the person and the grader agree. It misleads when both pass most outputs, because then they agree often by chance. Cohen’s kappa (), which Cohen proposed in 1960 as a coefficient of agreement for categories with no order, corrects for chance:
Here and are the shares of outputs each one passes. “Expected” is the agreement two graders with those pass rates would reach by labeling independently. A kappa of 1 is perfect agreement, and 0 is no better than chance. If both pass every output, or both fail every one, expected agreement is 1 and kappa is undefined: report the raw agreement and mark kappa undefined.
Worked example: kappa for 20 replies¶
A person and a model grader judge 20 replies for whether they acknowledge the concern:
| Grader passes | Grader fails | |
|---|---|---|
| Person passes | 15 | 0 |
| Person fails | 2 | 3 |
Observed agreement: (15 + 3) / 20 = 0.90.
Pass shares: the person passes 15 / 20 = 0.75, and the grader 17 / 20 = 0.85.
Expected agreement: 0.75 × 0.85 + 0.25 × 0.15 = 0.6375 + 0.0375 = 0.675.
Kappa: (0.90 − 0.675) / (1 − 0.675) = 0.225 / 0.325 ≈ 0.69.
Then read the disagreements. In both, the grader passed a reply the person failed: the grader is too lenient, and its rubric needs a sharper fail condition. Lab 7’s Exercise L7.3 computes both measures, and practice Exercise P7.2 computes a kappa.
How far to trust a pass rate¶
A pass rate is an estimate: , the share of test cases that pass. Another cases, drawn the same way, would give a different . A 95% interval shows how far the estimate could plausibly be from the true rate because of which cases were drawn. If you repeated the evaluation many times with fresh cases, about 95% of such intervals would contain the true rate.
The textbook interval is , with for 95%. NIST’s Engineering Statistics Handbook notes that its lower limit can fall below zero, an impossible value for a rate. The handbook presents instead the method introduced by Wilson (1927), which two later studies it cites recommend. Wilson’s interval comes from inverting the large-sample hypothesis test, and its lower limit can’t be negative. Its center and its half-width, the distance it reaches on each side, are
Worked example: 18 of 20¶
A prompt passes 18 of 20 independent cases, so , and .
Center: and , so the center is 0.99604 / 1.19208 ≈ 0.8356.
Under the square root: 0.9 × 0.1 / 20 = 0.0045, plus 3.8416 / 1,600 = 0.002401, is 0.006901. Its square root is about 0.08307.
Half-width: 1.96 × 0.08307 / 1.19208 ≈ 0.1366.
Interval: 0.8356 ± 0.1366, from about 0.699 to 0.972.
Report “18 of 20 cases (90%; 95% Wilson interval 70% to 97%).” The interval isn’t centered on 0.9, because Wilson’s center sits between and 0.5. The textbook interval, 0.9 ± 0.1315, would reach 1.031, above any possible rate. And this result doesn’t show that the prompt meets a 90% requirement: the interval reaches down to 70%.
Repeated runs of one case aren’t independent trials¶
Lab 7 runs every case three times, and it is tempting to count runs as trials. Don’t. Wilson’s interval assumes independent outcomes: each is like a fresh ticket drawn at random, so one outcome says nothing about the next. Three runs of one ticket share that ticket. If it is ambiguous, the runs tend to fail together; if it is plain, they tend to pass together. The second and third runs mostly repeat what the first said about that ticket. They measure how consistent the prompt is on it, the variation Module 1 described, not how it does on other tickets.
Worked example. Run the 20 cases above three times each, and suppose every case gives the same result on all three runs, so 54 of 60 runs pass. Wilson’s interval for 54 of 60 runs from 0.799 to 0.953, a width of 0.155; for 18 of 20 it was 0.273. The data hold the same 20 tickets, but the run-level interval claims almost twice the precision, because the width shrinks as grows. Real runs fall between identical and independent, so a run-level interval is too narrow by an amount you can’t know.
So report a pass rate over independent cases, as LO-7.3 says. Give each case one verdict by a rule fixed in advance, and compute Wilson’s interval over the cases. The rule can be a designated run, such as the first, or a case-level test, such as “passes on all three runs.” Describe the run rate separately, as in “54 of 60 runs”; if it needs an interval, resample whole cases, as the next section does. Lab 7’s Exercise L7.4 implements Wilson’s interval, and practice Exercise P7.3 reads an interval.
Compare two prompts with a paired bootstrap¶
To compare prompts A and B, run both on the same cases. Some cases are hard for both, and comparing within each case cancels that shared difficulty. The bootstrap is the subject of Efron and Tibshirani’s An Introduction to the Bootstrap. It measures how much a statistic varies: resample the data with replacement, and recompute the statistic each time. The percentile interval, which the book treats in a chapter of its own, is the middle 95% of the recomputed values. The paired version:
Score each case for each prompt: the share of its runs that pass, so 0, 1/3, 2/3, or 1.
For each case, subtract A’s score from B’s. The estimate is the mean of these differences.
Draw differences at random, with replacement, and take their mean. Repeat 2,000 times.
Sort the 2,000 means. The values near the 2.5th and 97.5th percentiles bound the interval.
Resample cases, never runs: the case is the independent unit. If the interval excludes 0, the cases favor one prompt; if it includes 0, this set can’t tell the two apart.
Worked example: twelve cases¶
Twelve illustrative cases, each run three times with each prompt:
| Case | W01 | W02 | W03 | W04 | W05 | W06 | W07 | W08 | W09 | W10 | W11 | W12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| A’s runs passed | 3 | 3 | 2 | 1 | 0 | 0 | 2 | 1 | 3 | 2 | 1 | 3 |
| B’s runs passed | 3 | 2 | 3 | 2 | 1 | 0 | 3 | 2 | 3 | 3 | 2 | 3 |
| B − A, in runs | 0 | −1 | +1 | +1 | +1 | 0 | +1 | +1 | 0 | +1 | +1 | 0 |
In case scores, the differences are seven of +1/3, one of −1/3, and four of 0. They sum to (7 − 1) / 3 = 2, so their mean, the estimate, is 2 / 12 = 1/6 ≈ 0.167.
One resample drew W01, W02, W02, W04, W07, W08, W08, W09, W09, W11, W12, and W12: some cases twice, and W03, W05, W06, and W10 not at all. Its differences sum to three runs, or 1 in case scores, so its mean is 1/12 ≈ 0.083. Over 2,000 resamples with Lab 7’s seed, 101, the middle 95% runs from 0.028 to 0.278. The interval excludes 0, so on these cases B is better.
Pairing matters. Resampling A’s and B’s scores separately, as if they came from different cases, gives an interval from −0.111 to 0.444, which includes 0. Cases W05 and W06 are hard for both prompts. A paired resample heavy in them lowers A and B together, so the difference barely moves; an unpaired one can draw them for one prompt and not the other. Lab 7’s Exercise L7.5 builds the paired bootstrap and plots its intervals.
Keep a held-out set¶
Split the cases into a development set, which you study and revise against, and a held-out set, which you run once, on the final version. Split by case, never by response, so no ticket has runs on both sides. Each change made in response to a set’s results fits the prompt to that set, quirks included. Its score there then overstates how it will do on new tickets. If you change the prompt after seeing a held-out error, the held-out set has become development data. Collect fresh cases before you claim a final comparison.
Worked example. Five prompt variants are equally good: each passes any ticket with probability 0.8, independently. Score each on 10 held-out cases and keep the best. Each variant’s expected score is 0.8, but the best of five averages about 0.93, and in about 90% of tries it scores 9 or 10. The winner’s score is mostly luck. Real variants share hard cases, which shrinks the effect, but any choice made on held-out scores inflates them.
A large gain on a small set of illustrative cases shows how your graders and statistics respond to that set. Only an evaluation against a real model estimates how the model behaves. Practice Exercise P7.4 asks how to report a reused held-out set.
Common misconceptions¶
“High agreement means a good grader.” A person passes 18 of 20 replies, and a grader passes all 20, so they agree on 90%. Expected agreement is 0.9 × 1 + 0.1 × 0 = 0.9, so kappa is 0. The grader adds nothing beyond its habit of passing everything.
“More runs per case give a tighter interval.” They give a narrower number, not more knowledge. The same 20 tickets give 0.699 to 0.972 as 18 of 20 cases, and 0.799 to 0.953 as 54 of 60 runs.
“Two prompts’ separate intervals show whether they differ.” Resampling them separately ignores the shared cases. On the twelve cases, the unpaired interval includes 0 and the paired one doesn’t.
“The interval covers every way an evaluation can mislead.” It covers only which cases were drawn. A set with no adversarial cases says nothing about tickets that carry the label format, however narrow its interval.
Summary¶
A success criterion names a checkable condition and a threshold set in advance. A test case stores its input, expected label, rule, kind, and split, and the set covers typical, edge, and adversarial cases.
Grade with code where you can, and report format and correctness separately. Check a model-based grader against human labels with percent agreement and Cohen’s kappa.
Report a pass rate over independent cases with a Wilson interval. Repeated runs of one case aren’t independent trials, so they don’t count toward .
Compare two prompts with a paired bootstrap that resamples whole cases, and read the interval, not only the estimate.
Choose on development cases, and run the held-out set once.
Self-check¶
Answer each question before you open its answer.
LO-7.1. What should you store about a two-topic case?
Answer
Store the text, expected label, applicable priority rule, case category, and split. The rule lets a reviewer check the label, and the category groups failures by kind. The split keeps the case on one side of the held-out divide.
LO-7.2. What does high observed agreement with both graders always passing say about kappa?
Answer
Kappa is undefined because chance agreement is also one. Graders that pass everything agree on everything, whatever the outputs, so the denominator 1 − expected is 0. Report the raw agreement, and add cases that should fail.
LO-7.3. What is the sample unit for the paired bootstrap?
Answer
The test case, including scores for both prompts and all repeated runs. Cases are the independent draws; a case’s runs share its ticket and both prompts share its difficulty, so they all travel together.
LO-7.4. When does a held-out case become development data?
Answer
As soon as you use its result to choose or revise the prompt. From then on the prompt is fitted to it, so its score no longer predicts how the prompt does on new tickets.
LO-7.3. A prompt passes all 12 of 12 independent cases. What do the textbook interval and Wilson’s interval say?
Answer
The textbook interval is 1 ± 0, claiming certainty from 12 cases. Wilson’s center is (1 + 3.8416 / 24) / (1 + 3.8416 / 12) ≈ 0.879, and its half-width is about 0.121. So it runs from about 0.757 to 1: the true rate could plausibly be as low as 76%.
LO-7.3. Twenty cases, each run three times, give 51 of 60 passing runs. Why is a Wilson interval for 51 of 60 the wrong report?
Answer
Each ticket’s three runs tend to pass or fail together, so there are 20 independent cases, not 60. Give each case one verdict and compute the interval over 20, or describe the run rate and resample cases for its interval.
Further reading¶
Anthropic, Define success criteria and build evaluations. Measurable criteria, edge cases, and the trade-offs among code, human, and model graders, with examples.
Zheng and colleagues, “Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena,” NeurIPS 2023 Datasets and Benchmarks Track, Zheng & others (2023). How often model judges agree with people, and the biases that pull them apart.
Cohen, “A Coefficient of Agreement for Nominal Scales,” Educational and Psychological Measurement, 1960, Cohen (1960). The paper that introduced kappa.
Wilson, “Probable Inference, the Law of Succession, and Statistical Inference,” Journal of the American Statistical Association, 1927, Wilson (1927). The short paper that introduced the interval this module uses.
NIST/SEMATECH, e-Handbook of Statistical Methods, section 7.2.4.1, “Confidence intervals”. A free page that sets the textbook and Wilson intervals side by side, with worked examples.
Efron and Tibshirani, An Introduction to the Bootstrap, Chapman & Hall, 1993, ISBN 978-0-412-04231-7. A textbook introduction to resampling, with a chapter on the percentile intervals that Lab 7 computes.
- Zheng, L., & others. (2023). Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena. Advances in Neural Information Processing Systems (NeurIPS), Datasets and Benchmarks Track, 36. 10.52202/075280-2020
- Cohen, J. (1960). A Coefficient of Agreement for Nominal Scales. Educational and Psychological Measurement, 20(1), 37–46. 10.1177/001316446002000104
- Wilson, E. B. (1927). Probable Inference, the Law of Succession, and Statistical Inference. Journal of the American Statistical Association, 22(158), 209–212. 10.1080/01621459.1927.10502953