Education › Evals & Harness › Stage 1: Evaluation foundations

Metrics and statistics for evals

Exact match to rubric scores, pass@k and pass^k, confidence intervals and how many samples you need.

Intermediate ~35 min read Module 3 of 20

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.

After this module you can
  • 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

MethodGood forWatch out for
Exact matchClassification, short factual answers, IDsFormatting differences count as wrong
Normalised matchAnswers that vary in case, spacing, punctuationNormalising away real differences
Code-based assertionsValid JSON, required fields, tool called, contains/excludesOnly checks what you thought to check
Overlap metrics (F1, ROUGE)Rough similarity for extraction or summariesReward wording over correctness
Rubric / judge modelHelpfulness, faithfulness, tone, completenessNeeds calibration (next lesson)
Human reviewGround truth for subjective qualitySlow 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.

Same 80% single-attempt success, very different stories
text
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'
Unbiased pass@k from n samples with c successes
python
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.917

Cost 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
50about ±11 points
100about ±8 points
400about ±4 points
1,000about ±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.

Bootstrap interval for the difference between two systems on the same cases
python
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 noise

A 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.

Hands-on practice

Measure honestly

  1. Take the eval from the previous lessons and add per-case token counts, model calls and latency to the results.
  2. Run the same configuration five times and record the spread of pass rates.
  3. Compute the 95% interval for your pass rate with the standard-error formula.
  4. Make one change, run both versions on the same cases, and compute the bootstrap interval for the paired difference.
  5. For an agent task, run each case three times and report both pass@3 and pass^3.
  6. Write one paragraph stating whether the change helped, with the interval and the cost difference.
Cheat sheet

Metrics and statistics for evals — at a glance

Main things to focus on

  • Cheapest scorer that measures what you care about; combine several.
  • pass@k: at least one of k succeeds. pass^k: all k succeed.
  • Production agents usually need pass^k, not pass@k.
  • Cost, tokens, steps and latency belong next to quality.
  • 100 cases at 80% is about ±8 points: small differences are noise.
  • Paired comparisons and repeated runs separate signal from noise.

Formulas

SE = sqrt(p(1-p)/n)Standard error of a pass rate
95% CI = p ± 1.96 x SERough confidence interval
pass@k = 1 - C(n-c,k)/C(n,k)Unbiased estimate from n samples, c correct
pass^k ~ p^kAll k independent attempts succeed
n ~ (1.96^2 x p(1-p)) / margin^2Cases needed for a target margin

Scorers

exact / normalised matchCrisp answers
code assertionsFormat, fields, tool calls, safety rules
judge with rubricSubjective qualities
human reviewGround truth and calibration
overlap metrics (F1, ROUGE)Rough similarity; reward wording

Comparing systems

same cases, count disagreementsPaired comparison
bootstrap the paired differenceInterval for the improvement
3-5 repeated runsMeasure non-determinism
quality vs cost frontierChoose the trade-off
report each scorer separatelySee which aspect moved

Common pitfalls

  • Declaring a winner from a two-point difference on 100 cases.
  • Reporting pass@k for a product where users get one attempt.
  • Ignoring cost and latency when a change wins on quality.
  • Comparing systems on different case sets.
  • Single runs of a non-deterministic system.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →