You changed the system prompt, re-ran the eval, and the pass rate went from 78% to 81% on 200 cases. The pull request says "+3 points." Before you merge, ask a question most eval dashboards skip: if you had changed nothing at all, how big a swing would you have seen anyway?

An eval set is a sample. Model outputs also vary from run to run, so every score has error bars, whether you draw them or not. Below is a small toolkit for deciding whether a change really moved quality: paired comparisons, an exact test in a dozen lines, bootstrap intervals that handle correlated cases, and an A/A run that measures your noise floor. It all uses the Python standard library.

Why "78% vs 81%" tells you less than it looks like

Start with the naive view: treat each score as its own estimate. A pass rate near 0.8 on n = 200 cases has a standard error of about √(0.8 × 0.2 / 200) ≈ 0.028. A 95% interval is roughly ±1.96 standard errors, or about ±5.5 percentage points. Seen that way, 78% and 81% are well inside each other's intervals, and the honest verdict is "no idea."

That view is too pessimistic, though, because both prompts ran on the same 200 cases. Most cases are easy (both pass) or hopeless (both fail), and those say nothing about which prompt is better. Treating the runs as independent samples throws away that pairing, and with it most of your statistical power.

Pair your results: only the disagreements count

Line up the two runs by case ID and count four groups:

| | B passes | B fails | |---|---|---| | A passes | both pass | A-only wins | | A fails | B-only wins | both fail |

The only cells that carry information about the difference are the two off-diagonal ones, the discordant cases. If prompts A and B were truly equally good, each discordant case would be equally likely to go either way, like a fair coin flip. That's McNemar's test, and its exact form is a binomial test on the discordant cases:

from math import comb

def mcnemar_exact(a_pass, b_pass):
    """a_pass, b_pass: dicts of case_id -> bool, with identical keys."""
    b_only = sum(1 for k in a_pass if b_pass[k] and not a_pass[k])
    a_only = sum(1 for k in a_pass if a_pass[k] and not b_pass[k])
    n = a_only + b_only
    if n == 0:
        return a_only, b_only, 1.0
    tail = sum(comb(n, i) for i in range(min(a_only, b_only) + 1)) / 2**n
    return a_only, b_only, min(1.0, 2 * tail)   # two-sided p-value

Now apply it to the "+3 points" example. Suppose that going from A to B, 14 cases flipped from fail to pass and 8 flipped from pass to fail. The net gain is +6 cases, which is 3 points on 200. The test looks only at the 22 discordant cases: is 14 vs 8 surprising for a fair coin? The two-sided p-value is about 0.29. A split at least that uneven, in either direction, happens about 29% of the time when there is no real difference. With 20 B-only wins vs 8 A-only wins, the p-value drops to about 0.036. And 26 vs 10 gives about 0.011.

Even without the p-value, print the discordant counts next to the headline score. "+3 points" invites celebration. "14 better, 8 worse" sends people to read the 8 regressions, which is often where the real finding is.

When it doesn't apply: McNemar's test needs binary pass/fail outcomes on the same cases. If your grader gives scores (a 1–5 judge rating, a similarity score), or you changed the eval set between runs, use the bootstrap below.

Bootstrap the difference, and resample the right unit

A paired bootstrap gives you a confidence interval on the difference itself, which is easier to read than a p-value: "B is between 1.5 points worse and 7.5 points better." It works for any per-case score:

import random
from collections import defaultdict

def paired_bootstrap(a_score, b_score, cluster_of=None, iters=10_000, seed=0):
    """a_score, b_score: dict case_id -> float (1/0 or a judge score).
    cluster_of: optional dict case_id -> cluster id (e.g. source document)."""
    rng = random.Random(seed)
    groups = defaultdict(list)
    for k in a_score:
        groups[cluster_of[k] if cluster_of else k].append(b_score[k] - a_score[k])
    clusters = list(groups.values())

    def mean_diff(sample):
        diffs = [d for g in sample for d in g]
        return sum(diffs) / len(diffs)

    observed = mean_diff(clusters)
    stats = sorted(mean_diff(rng.choices(clusters, k=len(clusters)))
                   for _ in range(iters))
    return observed, stats[int(0.025 * iters)], stats[int(0.975 * iters)]

On the 14-vs-8 example, this returns a difference of +0.03 with a 95% interval of roughly −0.015 to +0.075. The interval includes zero, which matches the McNemar result.

The cluster_of argument handles a mistake that quietly shrinks error bars in many eval sets: correlated cases. If you generated five questions from each of 40 documents, you don't have 200 independent observations. A retrieval bug that breaks one document breaks all five of its questions together. Resampling individual cases treats those five as separate pieces of evidence and makes the interval too narrow. Resampling whole clusters (documents, conversations, users, templates) respects how the data was produced. In a constructed version of the example above, where the changed cases sit together in clusters of four, the interval widens from about ±4.5 points to about ±9. Same data, same headline number, very different confidence.

Trade-offs: the percentile bootstrap gets unreliable with very few clusters (a dozen or fewer) and when almost every difference is zero. In those situations, read the discordant cases by hand instead of trusting any interval.

Measure your noise floor with an A/A run

Everything so far treats each case's outcome as fixed. With sampling temperature above zero, or with an LLM judge, it isn't. Run the same prompt twice and some cases will flip. Before you interpret any A/B difference, run A against A: the same prompt, the same model and the same grader, executed twice.

The A/A run tells you three things:

  1. The flip rate per run. If 15 of 200 cases change outcome between two identical runs, then a 14-vs-8 split in an A/B comparison is comparable to the churn identical runs produce, and the headline gain is mostly noise.
  2. Which cases are unstable. Cases that flip in A/A are good candidates for running several samples. Score them as the mean over k runs, so each case contributes a pass rate instead of a coin flip. The paired bootstrap above accepts those fractional scores unchanged.
  3. Whether the grader is the noise source. Re-grade the same outputs twice. If verdicts change, the judge's rubric needs work before any comparison means anything.

Plan the comparison before you look at the result

Testing many variants and shipping the best one. Try 15 prompt rewrites and there is a good chance at least one looks significantly better at p < 0.05 by luck alone. If you search over variants, treat the search set as a dev set. Confirm the winner once on a held-out split it never touched, and report that number.

Stopping when the number looks good. Re-running the eval until the difference is significant, or adding cases until it is, inflates false positives. Decide the eval set and the number of runs up front.

Ignoring slices. A flat overall score can hide a large regression in one category offset by gains elsewhere. Compare per slice, and expect wider intervals there.

Planning sample size from the wrong number. Power depends on how many cases flip, not on the total. A useful rough check: run a pilot on a subset to see how many cases typically disagree between versions. Then simulate pairs at that discordance rate with the effect size you care about, run mcnemar_exact a few thousand times, and count how often it detects the effect. If detection is rare at 200 cases, grow the set or write down that this eval only catches larger changes.

Treating "not significant" as "no difference." A wide interval that includes zero means the eval can't tell, not that the change is harmless. If the interval reaches deep into negative territory, you have no evidence that B doesn't regress.

Checklist for your next prompt or model comparison

  • Same case IDs for both versions, per-case outcomes stored.
  • Discordant counts next to every headline score; read the A-only cases.
  • Exact McNemar for pass/fail; paired bootstrap for graded scores.
  • cluster_of set whenever cases share a source document, conversation or user.
  • An A/A run per eval setup, plus a re-grade of identical outputs.
  • Unstable cases scored as a mean over several samples.
  • Eval set and run count fixed before comparing; "best of many" confirmed on a held-out split.
  • A confidence interval for the difference, with "includes zero" read as "undetermined", per slice where it matters.

That's about forty lines of code plus one habit: asking how much a score would move if nothing had changed. Then review discussions move from "is +3 good?" to "which 8 cases got worse, and why?"

Further reading