Evaluation Harnesses and Reproducibility › Comparing Two Models on the Same Tasks
Language AI HandbookAll chapters Comparing model A and model B is usually framed as "is B's score higher than A's?" That framing invites computing two independent intervals and eyeballing overlap, which is both under-powered and misleading. The models were evaluated on the same tasks. That pairing is information: if a task is hard, both models tend to miss it; if it is easy, both tend to hit it. A paired analysis exploits this by looking at per-task differences, which cancels the shared task difficulty.
The discordant outcomes determine the observed difference, but the estimate still divides by the total number of matched tasks. Pairs where both systems succeed or both fail contribute a zero difference.
The statistic of interest is the mean per-task difference
where:
- : model 's score on task (1 if correct, 0 otherwise)
- : the number of graded tasks shared by both models
- : the estimated mean per-task accuracy difference between models B and A
With pairing, is the average of the per-task differences , which have mean and sample variance ; the standard error of is therefore the standard deviation of those differences divided by :
not . Positive covariance lowers the variance of the paired difference relative to ignoring covariance. Negative covariance raises it. The classic McNemar view makes the same point: only the discordant items (where one model is right and the other wrong) carry information about which model is better. Let (b) be the count of items where B is right and A is wrong, and (c) the count of items where A is right and B is wrong.
where:
- : the number of discordant tasks on which model B is correct and model A is incorrect
- : the number of discordant tasks on which model A is correct and model B is incorrect
- : the number of graded tasks shared by both models
- : the mean per-task difference, since the tasks contribute , the tasks contribute , and the remaining concordant tasks contribute
The paired difference is therefore (\hat d = (b - c)/n).
For uncertainty, a bootstrap over tasks is the most flexible and the least assumption-laden: resample task indices with replacement, compute on each resample, and take percentiles. We will also compute the analytic paired z-test as a cross-check.
Let's run the paired analysis on our fixture. Recall the true gap is 0.80 - 0.72 = 0.08.
PythonIn [32]Expand
diffs = scores_b - scores_a
n = len(diffs)
d_hat = float(diffs.mean())
# Discordant counts (symmetric difference)
b = int(((scores_b == 1) & (scores_a == 0)).sum()) # B right, A wrong
c = int(((scores_b == 0) & (scores_a == 1)).sum()) # A right, B wrong
# Paired standard error
var_d = float(np.var(diffs, ddof=1))
se_paired = math.sqrt(var_d / n)
z = 1.959963984540054
paired_ci = (d_hat - z * se_paired, d_hat + z * se_paired)
# Unpaired SE for comparison (wrong for this design)
p_a, p_b = scores_a.mean(), scores_b.mean()
se_unpaired = math.sqrt(p_a * (1 - p_a) / n + p_b * (1 - p_b) / n)
unpaired_ci = (d_hat - z * se_unpaired, d_hat + z * se_unpaired)
# Bootstrap over tasks
rng = np.random.default_rng(7)
B = 5000
boot_d = np.empty(B)
for bidx in range(B):
idx = rng.integers(0, n, size=n)
boot_d[bidx] = diffs[idx].mean()
boot_ci = (float(np.quantile(boot_d, 0.025)), float(np.quantile(boot_d, 0.975)))ConsoleOut [33]Expand
n=7, observed mean difference=+0.143 Discordant: B-only-right b=1, A-only-right c=0 Paired SE=0.1429 95% CI=(-0.137, +0.423) Bootstrap 95% CI=(+0.000, +0.429) Unpaired SE=0.2160 95% CI=(-0.280, +0.566)
Compare the paired estimate, discordant counts and interval bounds directly. This fixture has only seven graded tasks, so a handful of discordances can dominate the estimate. An interval including zero leaves both signs compatible with the uncertainty in that procedure.
Pairing changes variance through the covariance between scores. Positive covariance can narrow the interval compared with an independence calculation; negative covariance can widen it. The small fixture is a demonstration of the computation, so avoid treating either normal or percentile-bootstrap bounds as a release decision.
Coverage of the Paired Interval
In a separate synthetic experiment, draw 100 independent tasks per run. Use the same uniform draw for both binary outcomes on a task, creating positive dependence. Compare the observed coverage of the true 0.08 difference when the estimated covariance is used and when it is ignored.
PythonIn [34]Expand
def simulate_paired(n_runs=3000, n_tasks=100, base_seed=3000):
draws = np.random.default_rng(base_seed).random((n_runs, n_tasks))
a, b = (draws < 0.72).astype(float), (draws < 0.80).astype(float)
d = b - a
dhat = d.mean(axis=1)
z = NormalDist().inv_cdf(0.975)
paired_se = np.sqrt(d.var(axis=1, ddof=1) / n_tasks)
naive_se = np.sqrt(
(a.var(axis=1, ddof=1) + b.var(axis=1, ddof=1)) / n_tasks
)
gap = 0.80 - 0.72
return float(np.mean(np.abs(dhat - gap) <= z * paired_se)), float(
np.mean(np.abs(dhat - gap) <= z * naive_se)
)
cov_paired, cov_unpaired = simulate_paired()ConsoleOut [35]Expand
Observed coverage of the 0.08 gap, paired: 0.907 Observed coverage if covariance is ignored: 1.000
The output reports observed coverage for this construction. It does not establish nominal coverage for the same interval in a seven-item benchmark. Use a paired estimate on a matched design and report the assumptions behind the uncertainty calculation.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!