An eval produces numbers, and numbers invite over-confident conclusions. Is 84% really better than 81%? Is an agent that succeeds 80% of the time good enough if users try three times? This lesson covers the scoring methods you will use most, the two metrics every agent team must understand (pass@k and pass^k), cost and latency as first-class metrics, and just enough statistics to know when a difference is real: standard errors, confidence intervals, paired comparisons and repeated runs.
- Choose between exact, normalised, code-based, rubric and judge scoring
- Compute and interpret pass@k and pass^k
- Track cost and latency per case alongside quality
- Compute a confidence interval for a pass rate and size a dataset
- Compare two systems with paired comparisons and repeated runs
Scoring methods
| Method | Good for | Watch out for |
|---|---|---|
| Exact match | Classification, short factual answers, IDs | Formatting differences count as wrong |
| Normalised match | Answers that vary in case, spacing, punctuation | Normalising away real differences |
| Code-based assertions | Valid JSON, required fields, tool called, contains/excludes | Only checks what you thought to check |
| Overlap metrics (F1, ROUGE) | Rough similarity for extraction or summaries | Reward wording over correctness |
| Rubric / judge model | Helpfulness, faithfulness, tone, completeness | Needs calibration (next lesson) |
| Human review | Ground truth for subjective quality | Slow and costly; use to calibrate the others |
Prefer the cheapest scorer that measures what you actually care about. A typical eval combines several: code checks for format and safety rules, exact match where answers are crisp, and a judge for the qualities code cannot capture. Report each scorer separately as well as combined, so you can see which aspect moved.
pass@k and pass^k
Agents and code generators are often run several times per task. Two metrics describe very different things. pass@k is the probability that at least one of k attempts succeeds: right when a human or a test suite will pick the best attempt. pass^k (pass hat k) is the probability that all k attempts succeed: right when every user gets one attempt and you need consistency, which is most production agents.
single-attempt success p = 0.8 (independent attempts)
pass@3 = 1 - (1 - 0.8)^3 = 0.992 -> 'nearly always solvable with retries'
pass^3 = 0.8^3 = 0.512 -> 'only half of users get three good runs in a row'from math import comb
def pass_at_k(n: int, c: int, k: int) -> float:
"""Probability that at least one of k draws (without replacement) from n samples is correct."""
if n - c < k:
return 1.0
return 1 - comb(n - c, k) / comb(n, k)
print(round(pass_at_k(n=10, c=3, k=5), 3)) # 0.917Cost and latency are metrics too
A change that adds three points of quality and doubles cost or latency may be a bad trade. Record, per case, input and output tokens, number of model and tool calls, wall-clock time and the cost those imply, and report them next to quality. For agents, steps per task is a good proxy for both cost and the risk of wandering.
- Plot quality against cost per task for each configuration; prefer the frontier.
- Report latency percentiles (p50, p95), not only means.
- Watch for configurations that win by spending more: longer context, more retries, more samples.
Is the difference real?
A pass rate measured on n cases has a standard error of about sqrt(p(1-p)/n), and a 95% confidence interval of roughly plus or minus 1.96 standard errors. With small datasets, the intervals are wide.
| Cases (n) | 95% interval at an 80% pass rate |
|---|---|
| 50 | about ±11 points |
| 100 | about ±8 points |
| 400 | about ±4 points |
| 1,000 | about ±2.5 points |
So 84% versus 81% on 100 cases is not evidence of anything by itself. Two techniques help a lot. Paired comparison: run both systems on the same cases and count only the cases where they disagree (one passed, the other failed); this removes the noise of case difficulty. Repeated runs: because outputs vary, run each configuration several times and look at the spread, or report mean and interval across runs. A bootstrap (resampling cases with replacement many times) gives intervals for any metric without formulas.
import random
def bootstrap_diff(a: list[int], b: list[int], iters: int = 5000) -> tuple[float, float]:
"""a, b: 1/0 outcomes for the same cases under systems A and B."""
n, diffs = len(a), []
for _ in range(iters):
idx = [random.randrange(n) for _ in range(n)]
diffs.append(sum(a[i] - b[i] for i in idx) / n)
diffs.sort()
return diffs[int(0.025 * iters)], diffs[int(0.975 * iters)]
# if the interval excludes 0, the difference is unlikely to be noiseA worked comparison
Suppose a support assistant passes 160 of 200 cases with the old prompt and 172 of 200 with the new one. The headline says 80% to 86%. Looking at pairs, 20 cases flipped from fail to pass and 8 flipped from pass to fail; the other 172 cases did not change. The net gain of 12 cases comes from 28 disagreements, which is a much smaller and noisier signal than the headline suggests.
A bootstrap on the paired outcomes gives an interval for the difference of roughly two to ten points, which excludes zero: the change probably helps. But the 8 cases that got worse deserve a careful read before shipping. If they are all refunds, or all in Spanish, you may be trading one slice for another, which per-slice reporting from the datasets lesson would show immediately. Finally, check cost: if the new prompt is twice as long, the cost per conversation rises, and the decision becomes a business trade-off rather than a pure quality win.
Write the conclusion the same way every time: what changed, the paired difference with its interval, the slices that moved, the cost and latency change, and a recommendation. That habit keeps reviews short and stops arguments based on a few memorable examples.