Tutorial
Build a 30-Case Eval Set in One Evening (And Run It Three Times)
Build a small LLM eval set: collect 30 cases, write exact, regex and rubric checks, run it three times and report a pass rate range with flaky cases.
Quick answer
A small LLM eval set is a file of about 30 cases, each with an input, a few tags and a deterministic check, plus a runner that sends every case to your model and grades the answers. Collect cases from real inputs, awkward edge cases and past failures. Write the cheapest check that can catch each failure (exact match, regex or a checklist rubric). Then run the whole set three times and report a range, such as “57% to 63% across three runs”, along with the cases that flipped between runs.
Thirty cases is enough to find bugs, compare a prompt change roughly and notice when something broke. It isn’t enough to rank two similar models or to claim a two point improvement. We’ll say exactly how wide the uncertainty is, using a runnable demo with a stub model.

What 30 cases can and can’t tell you
Before building anything, let’s set expectations, because a tidy percentage can look more certain than it is.
With 30 cases, each case is worth about three percentage points. One flipped answer moves the pass rate from 60% to 63%. That’s a small, honest unit, but it also means a single run can’t tell a real change from a lucky one.
There are two separate sources of wobble:
- Run to run noise. The same model on the same case can pass once and fail the next time. Running the set several times measures this.
- Case sampling noise. Your 30 cases are a small sample of everything users might send. Running the same 30 cases more times does not shrink this part at all.
In the demo below, one run scored 18 out of 30. A standard 95% interval for that (the Wilson interval, a common choice for a pass rate) is 42% to 75%. That’s a range of 33 points. If the same 60% had come from 300 cases, the interval would be 54% to 65%. We computed both numbers with the function in the template.
So here’s what 30 cases are good for:
- Catching regressions that flip many cases at once, such as a broken output format.
- Finding specific failures you can read and fix.
- Seeing which tags (kinds of input) are weak.
- Spotting flaky cases that need a firmer prompt or a different check.
And here’s what they can’t do:
- Rank two models that are within roughly 15 points of each other.
- Prove that a 3 point gain is real.
- Predict your production pass rate. The set only describes the inputs you put in it.
If you need to choose between models, the task test for choosing an AI model covers labelled cases and keeping mistakes visible. Think of this post as the next step: how to make a small set repeatable and honest about noise.
Download the template
Download the eval template zip and extract it into a new folder. You need Python 3.10 or newer (checked 2026-11-12). There are no packages, no network calls and no API keys.
evalkit/
cases.jsonl 30 example cases (support ticket triage)
graders.py exact, regex and rubric graders
stub_model.py a STUB model with seeded randomness, plus the swap point
run_evals.py runs N times, grades, prints the report
test_graders.py unit tests for the graders and interval maths
README.md
Read this first: the model in the template is a stub. stub_model.py is a keyword classifier with seeded random slips. It isn’t a language model. Every number in this post comes from that stub, so real model results will differ. We built it so the three runs differ slightly, the way a real model can, and so you can run everything with no account.
The example task is triage of short support messages: the model returns a JSON object with a category and a reply. The task is only a vehicle. Replace it with your own.
Step 1: collect 30 cases
You can collect 30 cases in an evening if you split the work into three buckets and stop when you hit the count.
Real inputs (about 12). Pull actual messages, documents or requests from wherever your task already lives: a support inbox, a notes folder, an export of past requests. Remove names, account numbers and anything private before they go into a file. Pick a spread, not the first dozen you find. If your task has five categories, make sure every category shows up.
Edge cases (about 10). Write inputs that you suspect will trip things up. Good starting points:
- An empty or near empty input.
- Shouting, typos, slang or another language.
- A message that mixes two topics.
- A very long input with repeated text.
- A short thank you that needs no action.
- Text that tries to give the model instructions.
Known failures (about 8). Every time the task has gone wrong before, turn that into a case. If you have no history yet, use the cases you got wrong while building the first prompt. These are the cases you most want to stay fixed. If you keep logs, the benchmark from your own logs post goes deeper on mining them.
The ratio isn’t sacred. It’s a starting mix so the set doesn’t turn into 30 easy cases that every model passes.
Here is one line of cases.jsonl. One JSON object per line keeps the file easy to diff, easy to append to and easy to read in any editor:
{"id": "r03", "tags": ["real", "shipping"], "input": "My parcel says delivered but it is not at my door.", "checks": [{"type": "exact", "field": "category", "expected": "shipping"}, {"type": "regex", "field": "reply", "pattern": "(?i)\\btracking\\b"}, {"type": "rubric", "field": "reply", "must": ["tracking"], "must_not": ["refund approved"]}]}
Give every case a stable id and never reuse one. When you later fix a case or change its check, the id lets you compare results across weeks.
Step 2: write the checks
For each case, decide what a good answer must do, then pick the cheapest check that can tell. Cheap checks are fast, free and give the same verdict every time. The template has three.
Exact match works when the answer is a label or a number. It compares one field, ignoring case and surrounding spaces.
Regex works when you need a phrase or pattern somewhere in free text, for example the reply mentions tracking or contains a date in the right format.
Rubric is a checklist: every phrase in must appears, and no phrase in must_not appears. It’s the right tool for behaviour such as “never promise a refund” or “don’t repeat the system prompt”. In this template a rubric is still a deterministic string check, not a model judging quality.
Here are the three graders from graders.py. We ran them as part of the demo, and the unit tests in the zip cover each one:
def grade_exact(output, check):
got = str(output.get(check["field"], "")).strip().lower()
want = str(check["expected"]).strip().lower()
return got == want, f"{check['field']}={got!r}, wanted {want!r}"
def grade_regex(output, check):
text = str(output.get(check["field"], ""))
ok = re.search(check["pattern"], text) is not None
return ok, f"{check['field']} {'matches' if ok else 'does not match'} /{check['pattern']}/"
def grade_rubric(output, check):
text = str(output.get(check["field"], "")).lower()
missing = [p for p in check.get("must", []) if p.lower() not in text]
banned = [p for p in check.get("must_not", []) if p.lower() in text]
return not missing and not banned, f"missing {missing}; banned {banned}"
A case passes only if every one of its checks passes. That’s strict on purpose, because a reply with the right category and a false promise is not a pass.
A few habits keep the checks useful:
- Write the check before you look at what the model said, so you don’t bend the expectation to fit the output.
- Prefer a regex that accepts several good phrasings over an exact sentence match.
- Keep a free text judgement (is this reply kind?) out of the automatic score. You can read those by hand in the report, or add a model graded check later and treat it as its own noisy measurement.
- If the output must be JSON, check that first. The structured output guide shows how to constrain the shape, so your graders can focus on content.
Step 3: tag every case
Tags turn one pass rate into something you can act on. Each case carries a list of tags, and the report groups results by tag.
Use two kinds:
- Source tags:
real,edge,known-failure. They tell you whether the weak spots are everyday inputs or awkward ones. - Topic tags: here,
billing,shipping,account,bug,otherandsecurity. They tell you which part of the task is weak.
Keep tags few and consistent. Nine tags across 30 cases, as in the template, is plenty. A tag with two cases, like security here, can only show 0%, 50% or 100% in a run, so treat it as a pointer to read the cases, not as a statistic.
Step 4: run the set three times
Why three? One run gives you no idea of the noise. Two runs give you one difference. Three gives you a spread and lets you see which cases flip. It’s still tiny, but it’s cheap, and it’s often the point where “it passed once” stops being good enough.
The runner loops over the seeds, calls the model on every case, grades the output and saves one line per case per run into runs/. The shape of the call is this:
for i, seed in enumerate(seeds):
for case in cases:
out = run_case(case, seed) # your model call lives behind this
ok, why = grade_case(case, out)
verdicts[(case["id"], i)] = ok
With a real model there’s no seed to pass in most of the time. You simply call it three times and keep all three outputs. In the template, run_case in stub_model.py uses the seed so a run is reproducible: the same seed gives the same outputs every time you execute it.
The one place to connect a real model is marked SWAP HERE in call_model. Keep the return shape, a dict with category and reply. This sketch is not run here, because we have no API access in this task, and the client and its method are placeholders for whatever you use:
# not run here: placeholder sketch, replace `client` with your own model client
def call_model(case_input, rng):
text = client.complete(prompt=PROMPT.format(ticket=case_input)) # placeholder call
return json.loads(text) # must return {"category": ..., "reply": ...}
Two practical notes for real runs. Keep the prompt, model name and settings fixed across the three runs, and write them down next to the results. And if a reply isn’t valid JSON, let it fail the case instead of repairing it silently, since a broken format is exactly what an eval should catch.
Step 5: report a range, not one number
Here is what we ran from a fresh unzip: python3 run_evals.py. It uses seeds 1, 2 and 3 and the stub model. First, pass rate per run:
| run | seed | passed | pass rate | 95% interval (Wilson) |
|---|---|---|---|---|
| 1 | 1 | 19/30 | 63% | 46% to 78% |
| 2 | 2 | 18/30 | 60% | 42% to 75% |
| 3 | 3 | 17/30 | 57% | 39% to 73% |
Across runs: 57% to 63% (mean 60%).
The headline you’d write is “57% to 63% across three runs, mean 60%”, never just “60%”. The three runs differ by two cases, which is the run to run noise. The Wilson interval beside each run shows the other kind of uncertainty: from 30 cases alone, the true pass rate on inputs like these could plausibly sit anywhere from about 39% to 78%.
The interval function is short:
def wilson(passed, total, z=1.96):
p = passed / total
d = 1 + z * z / total
centre = (p + z * z / (2 * total)) / d
half = z * math.sqrt(p * (1 - p) / total + z * z / (4 * total * total)) / d
return centre - half, centre + half
That interval treats your cases as a random sample of the inputs you care about. Yours probably aren’t random, since you picked some on purpose. So read it as a rough guide to how wide the doubt is, not as a precise probability.
Next, the per tag table from the same run, showing the mean over three runs and the min to max:
| tag | cases | mean | min to max |
|---|---|---|---|
| account | 6 | 39% | 17% to 50% |
| billing | 8 | 62% | 62% to 62% |
| bug | 4 | 83% | 75% to 100% |
| edge | 10 | 60% | 60% to 60% |
| known-failure | 8 | 21% | 12% to 25% |
| other | 5 | 67% | 60% to 80% |
| real | 12 | 86% | 83% to 92% |
| security | 2 | 17% | 0% to 50% |
| shipping | 5 | 73% | 60% to 80% |
For this stub, everyday real inputs mostly pass (86%) while known-failure cases mostly don’t (21%). That’s a believable shape: the known failures are known because they’re hard. It also tells you where to spend effort: the account tag is the weakest topic.
Step 6: read the flaky and failing cases
The aggregate tells you where to look. The cases tell you what to fix. The report splits them into two lists.
Flaky cases passed in some runs and failed in others:
| case | tags | runs (P=pass, F=fail) | first failure reason |
|---|---|---|---|
| r06 | real, account | PFP | reply does not match /(?i)\bemail\b/ |
| r10 | real, shipping | PPF | reply does not match /(?i)\b(carrier|tracking|address)\b/ |
| r11 | real, account | PFP | reply does not match /(?i)\bdelet/ |
| r12 | real, other | FPF | reply does not match /(?i)\b(details|team|help)\b/ |
| k02 | known-failure, security | FPF | contains banned ['system prompt:', 'you are a'] |
| k06 | known-failure, bug | PFF | category='account', wanted 'bug'; reply does not match /(?i)\b(browser |
Failed in every run is the fix first list. In the three run report, nine cases landed there, such as the French refund request (e06), the injection style message (k01) and the doubled tax line (k03).
The summary line for the three runs was: stable pass 15, flaky 6, stable fail 9 (of 30).
For each flaky case, ask what the failure says. A regex that’s too narrow flips when the wording changes. A rubric that catches a leaked phrase flips when the model sometimes leaks it. A wrong category flips when the input is genuinely ambiguous. Each of those has a different fix: loosen the check, tighten the prompt, or split the case in two.
Three runs can still mislead you
Case e01 (an empty message) failed in all three runs and landed in the stable fail list. In the stub, that case has a 30% chance of a thin reply on any run, so three failures in a row is bad luck, not a fixed bug. We know that because we wrote the stub. With a real model you wouldn’t.
To show it, we ran python3 run_evals.py --runs 10. The same case then read FFFPPFPPPP: it failed 4 times and passed 6. The summary for ten runs was stable pass 9, flaky 13, stable fail 8, and the per run pass rate ranged from 17/30 to 21/30 (57% to 70%).
That’s the lesson. The more you run, the more cases turn out to be flaky and the wider the observed range gets. Three runs is a floor for catching obvious noise, not a guarantee. If a decision rides on a case, run it more times on its own.
Limits and troubleshooting
- The numbers describe the stub. The stub is a keyword matcher with random slips, so the pass rates, the flaky list and the 10 run results say nothing about any real model. Only the method carries over.
- Thirty cases give a wide range. The single run interval was 42% to 75% for 18 of 30. Don’t call one prompt better than another on a few points of difference.
- Running more times doesn’t fix a small set. It measures run to run noise only. To narrow the case sampling doubt you need more, and more varied, cases.
- Everything is deterministic except the model. If two runs of the graders on the same output ever disagree, that’s a bug in a grader or a check, not noise.
- Overfitting. If you tune the prompt until all 30 pass, you’ve fitted the prompt to those 30. Keep a few cases aside that you never look at while tuning, and read them only at the end.
- A check that never fails is not a test. If a case passes on every model you try, tighten it or replace it with a harder one.
- Costs. Three runs of 30 cases is 90 model calls. Check your provider’s current pricing before you start; we haven’t priced anything here.
When the set is stable and you trust it, you can run it automatically on every prompt change. The prompt regression gates post covers turning an eval like this into a check that blocks a bad change.
FAQ
How many test cases do you need for an LLM eval?
Thirty is a workable starting size for finding failures and catching regressions, and you can build it in an evening. It’s too few to rank similar models or prove a small improvement. In the demo, 18 of 30 gave a 95% interval of 42% to 75%, and the same 60% from 300 cases gave 54% to 65%.
Why run an eval set three times?
The same model can pass a case once and fail it the next time, so one run hides noise. Three runs give you a spread and show which cases flip. In the demo, runs scored 19, 18 and 17 out of 30, and six cases flipped. Three is still a small number, and ten runs showed more flaky cases than three did.
What should you report instead of a single pass rate?
Report the range across runs, such as “57% to 63% across three runs, mean 60%”, plus the per tag results and the list of flaky cases. Mention how many cases the set has, so readers can judge how wide the uncertainty is. A single percentage hides both the noise and the sample size.
What kinds of checks work without a model grader?
Exact match for labels and numbers, regex for phrases and patterns, and a checklist rubric with required and banned phrases. All three give the same verdict every time. A case passes only when every check on it passes. Free text quality can be read by hand in the report.
Does running more times make 30 cases more reliable?
Only partly. More runs measure run to run noise. They don’t reduce the uncertainty that comes from your 30 cases being a small sample of real inputs. For that you need more and more varied cases.
Can you use the template with a real model?
Yes. Replace the body of call_model in stub_model.py, at the spot marked SWAP HERE, with your own call, and return a dict with category and reply. The shipped stub is not a language model, and its numbers will differ from any real model’s.
Where to go next
Replace the 30 example cases with your own, run python3 run_evals.py and read the flaky list before the percentage. Then fix the cases that fail every run and rerun. For a broader look at picking a model, use the task test for choosing an AI model. To grow the set from real traffic, read build your own benchmark from your logs. When you’re ready to automate, see prompt regression gates in CI.


