Practical guide · AI evaluation

LLM evaluation sample size: how many test cases do you need?

Choose the smallest evaluation that can answer your release question with acceptable uncertainty. For a binary pass rate near 50%, about 100 independent cases give a rough 95% margin of error of ±10 percentage points, 385 cases give about ±5 points, and 1,068 cases give about ±3 points. Those counts are starting points. Add enough cases inside every critical slice, pair candidate and baseline on the same inputs, and repeat variable agent runs.

Published December 1, 2026 · 14 minute read

The short answer

Start with the decision, metric, minimum effect worth detecting, and largest uncertainty you can tolerate. Use a confidence interval for the observed pass rate instead of treating the point estimate as exact. For candidate-versus-baseline tests, run both systems on the same cases and size the comparison around disagreements. Then check each high-risk slice separately. A large overall set can still contain only a handful of safety, language, tool-failure, or long-context cases.

Start with the decision, not a universal number

OpenAI's evaluation best-practices guide recommends task-specific tests that reflect real use and warns against relying on generic metrics or an unrepresentative dataset. A sample-size calculation cannot repair a test set that measures the wrong work.

Write one release rule in plain language. For example: "Ship the retrieval prompt if it does not lower citation correctness by more than two points, improves useful-answer preference by at least five points, and produces no critical unsupported claim in the safety slice." This identifies the metrics, comparison, tolerances, and slices that need evidence.

  • Unit: decide whether one observation is a prompt, conversation, completed task, user, document, or agent trajectory.
  • Primary metric: name the pass rate, win rate, error rate, latency threshold, or accepted-task rate that controls the release.
  • Minimum detectable effect: state the smallest change that would alter the decision. Detecting a two-point gain needs more evidence than detecting a ten-point gain.
  • Critical slices: list failures that an average can hide, such as unsupported claims, unsafe tool calls, one language, or one high-value workflow.

Sample-size planning table

The table below uses the familiar normal approximation at 95% confidence and assumes the most uncertain pass rate, 50%. The calculation is 1.96 × sqrt(0.25 / n). It is a planning aid, not the interval you should report after the run. For small samples or rates near zero or one, use a Wilson or exact binomial interval. SciPy's binomial proportion interval reference exposes exact, Wilson, and Wilson-with-continuity methods.

Independent casesWorst-case 95% marginApproximate use
25±19.6 pointsHarness smoke test and obvious failures
50±13.9 pointsEarly directional check
100±9.8 pointsLarge effects and iteration
200±6.9 pointsModerate release changes
385±5.0 pointsFive-point precision target
500±4.4 pointsTighter release estimate
1,000±3.1 pointsSmaller effects or tighter reporting

NIST's binomial proportion guidance shows why interval choice matters, especially when the observed proportion is close to a boundary. Always publish the case count and interval beside the rate.

Why 20 to 50 cases are useful but not precise

A small pilot can expose broken fixtures, weak graders, obvious regressions, and missing failure categories. It cannot support a tight pass-rate claim. At the worst-case 50% pass rate, 25 independent cases have a rough 95% margin near ±20 points and 50 cases remain near ±14 points. Use a pilot to improve the evaluation design and estimate disagreement, then size the release run from the decision you need to make.

Matched model comparisons need a different calculation

A model migration or prompt test should usually be paired: candidate and baseline answer the same input under the same tool state, timeout, and grader. The comparison then depends on cases where the systems disagree. Inputs where both pass or both fail add context but little information about which system is better.

Run a pilot first and count candidate-only wins and baseline-only wins. Size the next run around the difference you care about and the observed disagreement rate. If only 10% of cases produce a disagreement, a nominal set of 200 may contain roughly 20 informative comparisons. A balanced pairwise test should also randomize presentation order and allow ties.

Use the pointwise vs pairwise evaluation guide to choose the judging method. Use pointwise gates for absolute requirements and paired preference for a direct candidate-versus-baseline decision.

Plan every critical slice separately

Suppose an evaluation has 400 cases but only eight involve irreversible tool actions. The overall pass rate may look precise while the high-risk slice remains almost unknown. Set a minimum case count or a zero-tolerance rule for each slice before sampling. Oversample rare, costly cases and report their results separately rather than reweighting them into a flattering average.

Repeated runs answer a different question. Ten runs of one prompt estimate that prompt's run-to-run behavior; they do not replace ten different prompts. Keep the case count and trials per case separate. For agents, report task success, consistency, and the number of cases that failed at least once.

OpenAI's datasets guide recommends growing an evaluation dataset as new edge cases and blind spots appear. The AI agent test-set guide covers how to create those cases from real workflows and controlled transformations.

A six-step sample-size workflow

  1. Define the unit and release rule. Name the observation, primary metric, baseline, acceptable regression, and critical failure rule.
  2. Build a representative pilot. Run 30 to 50 cases across normal work and critical slices. Use the pilot to debug the harness and estimate rates, disagreements, invalid outputs, and run variance.
  3. Choose the precision or effect. For a single pass rate, choose the largest confidence-interval width you can accept. For a comparison, choose the smallest candidate improvement or regression that would change the release decision.
  4. Calculate by metric, then by slice. Compute the main count and check whether each critical slice has enough observations. Increase or stratify the set where it does not.
  5. Reserve a held-out confirmation set. Do not tune prompts, graders, or policies against every case. Confirm the final candidate on cases that did not guide the changes.
  6. Report uncertainty and exclusions. Publish counts, intervals, invalid outputs, abstentions, repeated trials, slice results, and any stopping rule used during the run.

Worked example: a support-answer release

A team compares a new retrieval prompt with production. The release rule requires no regression in citation support, at least a five-point gain in paired usefulness preference, and zero critical fabricated-policy answers in a reviewed safety slice.

They begin with 50 paired cases. Twelve produce a preference disagreement, which shows that the comparison will need far more than 50 inputs. They plan 400 paired cases for the usefulness decision, while separately assembling 60 fabricated-policy traps and 80 missing-evidence cases. Each configuration runs once on ordinary answer cases and five times on the highest-risk agentic cases.

The final report shows candidate-only wins, baseline-only wins, ties, citation pass rates with Wilson intervals, results for each safety slice, and the number of repeated cases that failed at least once. If the interval still crosses the release threshold, the result is inconclusive. The team collects more cases or declines to ship rather than turning a noisy point estimate into certainty.

Mistakes that make a large evaluation weak

  • Counting outputs as independent: several completions for one prompt share the same task and do not provide the breadth of several distinct prompts.
  • Stopping when the result looks good: repeated peeking raises the chance of a false positive unless the stopping rule accounts for it.
  • Ignoring grader error: a model judge with uncertain human agreement adds measurement error that a larger case count does not remove.
  • Using one overall margin: the uncertainty for a small critical slice is much wider than the uncertainty for the full set.
  • Changing the dataset during the comparison: candidate and baseline need matched cases, policies, tools, and grader versions.
  • Reporting only the rate: "90% passed" means something different for 9 of 10 cases and 900 of 1,000 cases.

NIST's sample-size planning example illustrates the wider principle: sample size follows the statistical quantity, desired precision, confidence, and expected variability. The same discipline applies to LLM evaluations, even when the grader and cases are product-specific.

A release-planning worksheet

Decision: What exact result changes the release?

Unit: What counts as one independent case?

Metric: Which rate, difference, or threshold controls the decision?

Precision: What interval width or effect is small enough?

Slices: Which rare failures need their own minimum count?

Repeats: Which cases need repeated trials, and why?

Holdout: Which cases remain unseen until confirmation?

Reporting: Which intervals, exclusions, and stopping rules will be published?

Continue learning