Evaluating Generative Models

A judge that favours the first answer by 10 points crowns the worse model, with a tight error bar. Randomize the order and the truth comes back.

Press Run 2,000 battles with the order fixed. Then switch to random order and run again. Then we build, piece by piece, the instruments that turn taste into a number you can defend: perplexity, pass@k, Bradley-Terry, judge calibration, FID, caption metrics and kappa.

You need a little Python and what a probability is. We build the rest from zero. It helps to have met Metric Design.

Let a biased judge pick the winner

10 pts

Illustrative simulation. Model A truly wins 55% of battles. The judge adds the bias to whichever answer it reads first. The band is a 95% interval from the normal approximation.

Chapter 0

No Answer Key

See why scoring a generated poem is a measurement problem, and why the order of two answers can decide the winner

Two models write a poem about frost. You read both and pick one. Now swap which poem you read first. Would you pick the same one? Many readers would not. That habit is the problem this lesson solves.

A classifier has an answer key: the label "dog" is right or wrong. A generative model writes a poem, a caption, an image or a program. There is no single right output, so there is no key. Evaluation becomes a measurement of preference, and every rater, human or model, has habits.

Seat the poems and run the panel

Ten raters vote between two poems of equal quality. Each rater leans toward the poem read first. Pick a seating, then run one panel or a thousand.

15 pts

Illustrative. A fair rater picks A half the time; the bias adds to the first seat. A wins the panel with 6 or more of 10 votes.

With made-up numbers: the poems are equal, so a fair rater picks A with chance 0.50. Each rater adds 15 points to the first seat. Seat A first and each vote goes to A with chance 0.65. A wins a majority in 75.1% of panels. Seat A second and the chance drops to 9.5%. Same poems, opposite verdicts.

The fix is a coin per rater. Half see A first and half see it second:

0.5 × 0.65 + 0.5 × 0.35 = 0.50

The plus 15 and the minus 15 cancel. Nobody had to estimate the bias.

Bias first, then variance

Bias is an error that points the same way every time. Variance is an error that wobbles around the truth. More raters shrink variance and leave bias alone: with A always first, a thousand raters converge on 0.65 with great confidence. So fix bias by design first. Then buy variance down with samples.

Every problem in this lesson routes into one of three families, by the evidence you have:

You haveFamilyInstrumentChapter
A verifier (unit tests)Executionpass@k2
Only pairwise votesPreferenceBradley-Terry, a calibrated judge, kappa3, 4, 7
Only samplesDistribution matchFID, precision and recall5

Failure. The symptom: a 58 to 42 preference win that no one can reproduce. Split the win rate by which answer came first. Fix: randomize the order of every vote and hide every cue of who wrote what.

The road

  1. Likelihood is not quality: perplexity, and the three things it cannot see.
  2. pass@k without bias: the estimator for code with unit tests.
  3. From votes to a leaderboard: Bradley-Terry and Elo.
  4. Calibrate the judge: position, length and self-preference.
  5. FID: how far apart two clouds of images are.
  6. Captions and hallucinations: VQA, BLEU, CIDEr, SPICE, POPE.
  7. How much humans agree: Cohen's kappa and the ceiling.
  8. Rescue a rigged leaderboard: the hero's judge, with every repair.
  9. Field guide: formulas, the audit order, code and links.
Two equal models are compared by raters who favour whichever answer they read first. A is always shown first. What happens as you add raters?

Chapter 1

Likelihood Is Not Quality

Compute perplexity by hand, then find the three things it cannot see: samples, diversity and memorization

Here is a score that seems to dodge taste. Ask the model how likely it finds good human text. A model that finds good text likely must be a good model. Then why does the single most likely continuation so often read as dull?

A language model gives a probability to each next token. Feed it a held-out sentence of N tokens. Call the probability it gave the true token at position t pt. Perplexity turns those probabilities into one number: how many equally likely tokens the model behaves as if it chooses from.

Say it aloud

P-P-L equals e to the power of minus one over N, times the sum over t of the log of p-t.

PPL
P-P-L perplexity: 1 means the model is certain; 50 means it hesitates as if among 50 tokens.
exp( )
e to the power of undoes the log, so the answer is back in units of "tokens to choose from".
1/N
one over N divide by the number of tokens, so long and short texts compare.
Σt
the sum over t add one term for each token position.
ln pt
the log of p-t the natural log of the probability given to the true token; always 0 or less.
In plain words

Take the log of each p-t. Average the logs over the N tokens. Flip the sign and raise e to that power. The result is PPL.

With numbers

With made-up numbers: five tokens get p-t of 0.5, 0.25, 0.5, 0.125 and 0.25. The logs sum to −6.238; divide by N = 5 to get −1.248. PPL = e1.248 = 3.48. The model hesitates as if among about three and a half tokens.

Three blind spots

  1. It reads other people's text. Perplexity scores human text, never the model's own samples. A model can predict human text well and still write badly under its decoding settings.
  2. One number cannot see diversity. Fidelity is the share of the model's samples that look like real data. Coverage is the share of real data that the samples reach. A model that writes one perfect poem forever has full fidelity and almost no coverage.
  3. Memorization wins. A model that stored a text gives each of its tokens pt = 0.99. Its perplexity on that text is 1/0.99 = 1.01: a near perfect score for storage, not skill.

Collapse the model, then let it spray

Blue dots are real data. Teal dots are the model's samples. Move the slider from collapse to spray and watch fidelity and coverage trade places. Then press Memorize.

matched

Illustrative 2-D toy. A sample counts toward fidelity if a real point lies within a fixed radius; a real point counts toward coverage if a sample lies within it. Chapter 5 meets the published version of this idea.

Memorization also hides inside benchmarks. If test items leaked into the training data, a high score measures storage. A common check flags a test item when a run of 13 words also appears in the training data. A 40-word item holds 40 − 13 + 1 = 28 such runs to look up.

Failure. The symptom: the new model has lower perplexity, but people prefer the old model's answers. Measure three things: sweep the decoding settings, check test and training text for overlap, and grade samples with a rubric. Fix: keep perplexity as a cheap alarm for regressions, and gate releases on samples. For how low diversity looks across real models, see Mode Collapse.

A model scores perplexity 1.01 on an evaluation set. What is the most likely reason?

Chapter 2

pass@k Without Bias

Derive the chance that one of k tries passes, see why the obvious estimate runs low, and count subsets to fix it

Code brings an answer key back: a function passes its unit tests or it does not. But each call gives a different program. If the model tries k times, what is the chance that at least one try passes? That is pass@k.

Call the chance that one try passes p, and the number of tries k.

Say it aloud

pass-at-k equals one minus, one minus p, to the power k.

pass@k
pass-at-k the chance that at least one of k tries passes the tests, from 0 to 1.
p
p the chance that one try passes; unknown, a property of the model and the problem.
k
to the power k multiply by itself once for each try, because the tries are independent.
In plain words

Take the chance that one try fails, 1 minus p. Multiply it by itself k times to get the chance that every try fails. Subtract that from 1.

With numbers

With made-up numbers: p = 0.3 and k = 5. All five fail with chance 0.75 = 0.168, so pass@5 = 0.832. A 30% coder passes 83% of the time with five tries.

The plug-in runs low

We never know p. We draw n samples and count c that pass. The obvious move puts c/n in place of p. Chen et al. (2021) show that this plug-in estimate runs low: the curve bends downward, so its average over noisy guesses sits under the truth.

The fix: any k of the n samples form a fair k-try experiment. Name the number of ways to choose b things from a things C(a, b), said "a choose b".

Say it aloud

pass-at-k hat equals one minus, n minus c choose k, over n choose k.

pass@k̂
pass-at-k hat the estimate of pass@k from the samples; the hat marks an estimate.
C(n − c, k)
n minus c choose k the number of groups of k drawn only from the n minus c failed samples.
C(n, k)
n choose k the number of groups of k drawn from all n samples.
In plain words

Count the groups of k that hold only failures. Divide by all groups of k. That is the chance a random group has no pass. Subtract it from 1.

With numbers

With made-up numbers: n = 10 samples, c = 3 pass, k = 5. C(7, 5) = 21 and C(10, 5) = 252. pass@5 = 1 − 21/252 = 0.917.

Average both estimators over many draws

The top row is one draw of 10 samples. The chart shows pass@k for k from 1 to 10: the truth (blue, dashed), the plug-in average (purple), the subset estimator average (green). Move p and k.

0.30
5

The averages are exact expectations over c drawn from a binomial with n = 10. The estimator and its bias come from Chen et al. (2021), Appendix A.

At p = 0.3, n = 10, k = 5 the plug-in averages 0.760 against a truth of 0.832: 7.2 points low. The subset estimator averages 0.832. Edge cases: c = 0 gives 0; fewer than k failures gives 1; k = 1 gives c/n.

pythonimport numpy as np
def pass_at_k(n, c, k):                  # Chen et al. (2021), Figure 3
    if n - c < k: return 1.0              # every group of k holds a pass
    return 1.0 - np.prod(1.0 - k / np.arange(n - c + 1, n + 1))
print(pass_at_k(10, 3, 5))                  # 0.9167, no giant factorials

Failure. The symptom: pass@10 from n = 10 samples, so each problem gives one 0 or 1. Measure n against the largest k. Fix: draw n well above k; the Codex paper used n = 200 for k up to 100. Report pass@1 too, and fix the temperature.

n = 10 samples, c = 3 pass. What does the subset estimator give for pass@8?

Chapter 3

From Votes to a Leaderboard

Fit one strength per model from pairwise votes, read it on the Elo scale, and put an error bar on it

You hold thousands of A-versus-B votes across ten models. A raw win rate is unfair: a model that met only weak rivals looks great.

Give model i a positive strength si. The Bradley-Terry model (1952) gives i a win chance equal to its share of the two strengths.

Say it aloud

The probability that i beats j equals s-i over s-i plus s-j.

P(i beats j)
the probability that i beats j how often model i wins a battle against model j.
si
s-i the strength of model i, a positive number; only ratios matter.
si + sj
s-i plus s-j the total strength in this battle.
sj
s-j the strength of the opponent, model j.
In plain words

Add the two strengths. Model i wins its share, s-i out of the total s-i plus s-j.

With numbers

With the fitted toy below: s-A = 0.597 and s-B = 0.245. P(A beats B) = 0.597 / 0.842 = 0.709. The votes said 7 of 10.

Fit it by hand

Toy votes: A beat B 7 of 10, A beat C 8 of 10, B beat C 6 of 10. The fitting loop:

  1. Start with equal strengths: one third each.
  2. For each model, divide its total wins by the sum, over its opponents, of battles divided by (si + sj).
  3. Rescale the strengths so they sum to 1. Repeat until they stop moving.

One pass gives 0.50, 0.30, 0.20. The loop settles at 0.597, 0.245, 0.158. Leaderboards print 400 × log10(si/sC), the chess Elo scale. On it, 400 points means 10 to 1 odds: A +231, B +77, C 0.

Fit the arena, then shake it

Each row is a pair of models. Change who won how often, then press Fit. Bootstrap resamples the battles 200 times and draws each model's band. Fewer battles, wider bands.

7 of 10
8 of 10
6 of 10
10

Battles per pair scales the counts from 10 to 200 at the same win shares. Bands span the middle 95% of 200 refits. A perfect record gets half a virtual win each way.

Elo is the same model, one battle at a time

Chess updates ratings after each game. Call them RA and RB. A's expected score is EA = 1/(1 + 10(RB − RA)/400). Call the real result S (1 for a win, 0 for a loss) and the step size K.

Say it aloud

R-A prime equals R-A plus K times, S minus E-A.

RA′
R-A prime A's rating after the battle.
RA
R-A A's rating before the battle, in Elo points.
K
K the step size: how far one result moves a rating; 32 here.
S
S the result: 1 if A won, 0 if A lost, 0.5 for a tie.
EA
E-A the score the ratings predicted for A, between 0 and 1.
In plain words

Subtract the predicted score E-A from the result S. That is the surprise. Move R-A by K times the surprise.

With numbers

With made-up numbers: R-A = 1200, R-B = 1000, so E-A = 1/(1 + 10−0.5) = 0.760. A loses, S = 0. R-A′ = 1200 + 32 × (0 − 0.760) = 1175.7, and B rises to 1024.3. An upset costs A 24 points.

Elo depends on the order of the battles. A frozen model does not drift, so order noise is pure error. The Chatbot Arena paper (Chiang et al., 2024) moved from Elo to Bradley-Terry, fitted on all battles at once.

Failure. The symptom: a team announces a lead of 7 Elo points. That gap is a 51.0% chance to win. A 7 of 10 record has a standard error of √(0.7 × 0.3 / 10) = 0.145. Fix: report intervals and call overlaps a tie.

Model X won 90% of its battles, all against the weakest model. Model Y won 60%, against the strongest. What does Bradley-Terry do that a raw win rate cannot?

Chapter 4

Calibrate the Judge

Measure a judge model's position, length and self-preference habits with one designed experiment each, then cancel them

Human votes cost dollars and days. A judge, a language model that picks the better of two answers, costs cents and seconds. Zheng et al. (2023) found that strong judges such as GPT-4 agree with human preferences over 80% of the time. Humans agree with each other at the same level. The paper also named three habits.

HabitThe experiment that isolates itThe fix
Position: the first seat winsJudge each pair twice, with the seats swappedAverage both orders, or randomize the order
Verbosity: the longer answer winsThe same content at two lengthsLength control: fit the effect of length, report at equal length
Self-preference: its own family winsHide authors; compare with judges from other familiesNever let a judge grade its own family; use a jury

Length-Controlled AlpacaEval (Dubois et al., 2024) fits the judge's preference with the length gap as one input. Then it predicts the preference at a gap of zero. That raised its rank agreement with Chatbot Arena from 0.94 to 0.98.

The swap test

Judge 100 pairs twice. Call A's win rate when A sits first w1, and when A sits second w2. A position tilt adds to one and subtracts from the other.

Say it aloud

w equals w-one plus w-two, over two.

w
w A's order-free win rate: the estimate with the position tilt removed.
w1
w-one A's win rate when A sits in the first seat; it carries plus the tilt.
w2
w-two A's win rate when A sits second; it carries minus the tilt.
/ 2
over two average the two seatings, so the plus and minus cancel.
In plain words

Add w-one and w-two and halve the sum. The tilt rides up in one and down in the other, so it drops out. Half the gap between them is the tilt itself.

With numbers

With made-up numbers: w-one = 0.60 and w-two = 0.44. w = 1.04 / 2 = 0.52. The tilt is (0.60 − 0.44)/2 = 0.08: the first seat buys 8 points.

Run the swap test on a judge

Plant a hidden tilt and a true preference. Press the button to judge 100 pairs in both orders. The four boxes sort the pairs; the read-out recovers the tilt you planted.

8 pts
52%

Illustrative judge. Each pair gets its own true chance that A is better, spread around the true rate; the tilt adds to the first seat. The worked numbers use one fixed outcome: 40, 20, 4 and 36 pairs.

Read the four boxes with the right test. The 20 + 4 pairs that flipped test the seat: 20 against 4 is an exact binomial p of 0.0015, so the tilt is real. The pairs that did not flip test the models: A won 40, B won 36, p = 0.73. There is no evidence that A is better. The flip rate, 24 of 100, says a quarter of the verdicts came from the seat.

Failure. The symptom: "A wins 60%" from a judge that always saw A first. Measure the win rate split by seat. Fix: judge both orders or randomize, and accept a judge only if its agreement with humans reaches the human-human level. Why a judge can agree and still miss real disagreement: Mode Collapse.

A judge gives A 60% when A sits first and 44% when A sits second. What is the best estimate of A's order-free win rate?

Chapter 5

FID: How Far Apart Are Two Clouds

Embed real and generated images, fit a mean and a spread to each cloud, and compute the distance by hand

For images there are two piles of pictures: real and generated. A good model's pile matches the real pile in content and in variety. How far apart are the piles?

Pixels are a bad ruler, so embed each image with a fixed network. The Fréchet Inception Distance (FID, Heusel et al., 2017) uses the 2,048 features of Inception-v3's last pooling layer. Each pile becomes a cloud of points. Fit each cloud with its mean (the centre) and its covariance (the spread and tilt). Call them μr, Σr for real and μg, Σg for generated.

Say it aloud

F-I-D equals the squared distance between mu-r and mu-g, plus the trace of: sigma-r plus sigma-g, minus two times the square root of sigma-r times sigma-g.

FID
F-I-D the distance between the two clouds; 0 means they match, lower is better.
‖μr − μg‖2
the squared distance between mu-r and mu-g the mean term: how far apart the two centres sit.
Tr
the trace the sum of the diagonal of a matrix: one number per feature, added up.
Σr + Σg
sigma-r plus sigma-g the two covariance matrices: the spread of each cloud.
(ΣrΣg)1/2
the square root of sigma-r times sigma-g a matrix square root; it handles features that move together.
In plain words

Square the distance between mu-r and mu-g. Then compare the spreads: when the features are independent, each feature adds (real standard deviation minus generated standard deviation) squared. Add the two terms.

With numbers

With made-up 2-D numbers: mu-r = (0, 0), mu-g = (1, 1), so the mean term is 1 + 1 = 2. Real standard deviations are 1 and 1; generated ones are 2 and 1. The trace term is (1 − 2)2 + (1 − 1)2 = 1. FID = 3.

Move the cloud and watch both terms

Blue is the real cloud, teal the generated one, each drawn with its one and two spread rings. The bar stacks the mean term and the trace term. Try the presets.

1.0
2.0
1.0

A 2-D toy with independent features, so the matrix square root is the square root of each spread squared. Real image FID uses 2,048 features and a full matrix square root.

If the model collapses to one image, its spread goes to zero. The trace term then climbs to the real cloud's total spread, 2 here: the missing variety is the penalty. If features move together, use the full matrix square root. With Σg = [[2, 0.6], [0.6, 1]], scipy's sqrtm gives FID = 2.284.

Neighbours: the Inception Score (Salimans et al., 2016) never looks at real data, so FID replaced it. Precision and recall for generative models (Kynkäänniemi et al., 2019) split FID's one number into Chapter 1's fidelity and coverage. CLIPScore (Hessel et al., 2021) checks whether an image matches its prompt, which FID never asks.

Failure. The symptom: team A reports FID 8.2 on 10,000 samples, team B 9.1 on 50,000. Small sample counts push FID up, so the comparison is void. Fix: recompute both at one count (50,000 is common) with one resize code; Parmar et al. (2022) show resizing alone moves FID. Chong and Forsyth (2020) show the bias also differs by model.

A diffusion model collapses: every sample is the same sharp, realistic image. What happens to FID?

Chapter 6

Grading Captions and Hallucinations

Give partial credit against many right answers, see how overlap metrics get fooled, and probe for objects that are not there

Ask ten people to describe a photo. You get ten different sentences, most of them right. "A man riding a horse on a beach" and "a rider on horseback by the sea" share almost no words. Exact match fails at once, so every metric for a vision-language model (VLM) is a scheme for partial credit.

VQA accuracy (Antol et al., 2015) collects 10 human answers per question. A model's answer scores the number of humans who gave it, divided by 3, capped at 1. Three matches earn full credit. The official score averages this over the 10 ways to leave one human out. With made-up numbers: 2 of 10 humans said "yellow". The simple rule gives 2/3 = 0.67; the official average gives 0.60.

BLEU, step by step

BLEU counts shared word runs (n-grams). Candidate "the cat sat on the mat", reference "the cat is on the mat":

  1. Unigram precision with clipping: a word earns credit at most as often as the reference has it. Matches: the ×2, cat, on, mat = 5 of 6 words. p1 = 0.833.
  2. Bigram precision: "the cat", "on the", "the mat" match, 3 of 5. p2 = 0.6.
  3. Brevity penalty: both have 6 words, so the penalty is 1.
  4. BLEU-2 is the geometric mean: √(0.833 × 0.6) = √0.5 = 0.707.

Grade a caption against three references

The scene is a rider on a beach. Pick a candidate. Matched words glow; clipped repeats turn red. BLEU-2 updates. Find the candidate that is right but scores low.

BLEU-2 computed live: clipped counts take the most any one reference allows; the brevity penalty uses the closest reference length. We made up the captions.

MetricWhat it fixesWhat it breaks
BLEUExact match: gives partial creditSynonyms score zero; generic captions farm credit
CIDEr (Vedantam et al., 2015)Weighs rare shared phrases above common ones (TF-IDF)Scores depend on the reference corpus
SPICE (Anderson et al., 2016)Compares objects, attributes and relations, so synonyms can matchInherits every error of its parser

Probe for objects that are not there

No overlap metric checks that the caption is true of this image. POPE (Li et al., 2023) asks "Is there a <object> in the image?" for present and absent objects at a 1 to 1 ratio. The absent objects come at random, by popularity, or by how often they appear with the objects present. With made-up numbers: 50 present and 50 absent probes; the model says yes to 45 and 15. Precision 45/60 = 0.75, recall 45/50 = 0.90, F1 = 0.82. Its yes ratio is 0.60 on a set where the truth is 0.50: it says yes 10 points too often.

Failure. The symptom: a caption score rises after fine-tuning while users report more invented details. Measure with grounding probes: POPE, or CHAIR (Rohrbach et al., 2018), the share of mentioned objects that are absent. Fix: pair every overlap metric with a grounding metric.

On a balanced POPE set (half present, half absent), a VLM says yes 85% of the time with recall 0.98. What is the diagnosis?

Chapter 7

How Much Do Humans Agree

Subtract the agreement that luck gives for free, find the ceiling for any judge, and design a human study that earns trust

We check every judge and metric against humans. So who checks the humans? Two raters agree on 70% of items. That sounds decent until you count how much agreement luck hands out.

Two raters who each say "acceptable" 90% of the time agree 0.9 × 0.9 + 0.1 × 0.1 = 82% of the time without reading a word. Call the share of items where the raters match the observed agreement po. Call the match rate expected from their base rates alone the chance agreement pe. Cohen's kappa keeps only what they earned above luck.

Say it aloud

Kappa equals p-o minus p-e, over one minus p-e.

κ
kappa agreement beyond chance: 1 is perfect, 0 is luck, below 0 is worse than luck.
po
p-o the observed agreement: the share of items where the two raters match.
pe
p-e the chance agreement: for each label, multiply the two raters' rates; add over labels.
1 − pe
one minus p-e the room above luck: the most agreement there was left to earn.
In plain words

Subtract the free agreement p-e from the observed p-o. Divide by the room there was above luck, 1 minus p-e. Kappa is the share of that room the raters filled.

With numbers

With made-up numbers: of 100 answers, both say acceptable 40, both say not 30, they split 20 and 10. p-o = 0.70. Rater 1 says acceptable 60%, rater 2 says 50%, so p-e = 0.6 × 0.5 + 0.4 × 0.5 = 0.50. Kappa = 0.20 / 0.50 = 0.40.

Fill the agreement table

The grid counts 100 answers by what each rater said. The ghost number in each cell is what chance alone would put there. Try the presets: both have 86% raw agreement.

40
20
10

Illustrative counts. "Both not acceptable" is what remains of the 100. A slider stops when the four cells reach 100.

The two presets show the kappa paradox. Both have po = 0.86. With balanced base rates pe = 0.50 and kappa is 0.72. When both raters say acceptable 90% of the time, pe = 0.82 and kappa drops to 0.22. Same raw agreement, a third of the kappa.

Human-human kappa is a ceiling. A judge cannot agree with humans more than humans agree with each other. So report the ratio: with made-up numbers, judge-human kappa 0.42 over human-human 0.45 is 93% of the ceiling. For 3 or more raters use Fleiss' kappa; for ordered scales a weighted kappa; for missing labels Krippendorff's alpha.

A protocol that earns that trust:

  1. Blind the raters: strip model names and style tells. Randomize the seat of each pair.
  2. Anchor each scale point with an example. Pilot on about 20 items, measure kappa, and revise the rubric before you scale.
  3. Seed items with known answers and drop raters who miss them.

With made-up prices: 1,000 pairs × 3 raters × $0.50 = $1,500 and days of waiting, against 2,000 judge calls at $0.002 = $4. Spend the human budget on the ceiling and on audits of the judge.

Failure. The symptom: a pilot kappa of 0.2. Measure which items split the raters. Fix: treat it as a rubric bug, not a rater bug, and rewrite the anchors.

A judge reaches kappa 0.42 against human labels. Trained humans reach 0.45 against each other on the same items. What follows?

Chapter 8

Rescue a Rigged Leaderboard

Corrupt a judge three ways, watch a confident wrong verdict, repair it by design, and only then size the sample

This lab knows the truth: model A beats model B on 55% of prompts. The judge has three habits from Chapter 4. It adds b to the first seat. It adds γ to the longer answer, and B writes longer. It adds s to its own family, and B shares the judge's family.

Corrupt the judge, then repair the pipeline

Purple dials corrupt the judge. Green switches repair the pipeline. The bar shows A's measured win rate with its 95% band, against the truth (blue) and a tie (grey). It starts as the worked case: position bias only. Then raise length and self.

10 pts
0 pts
0 pts
5,000

Illustrative. The bias terms add to the chance that the judge picks A. Length control and the other-family judge remove their term entirely, which real fixes do only roughly. The band uses the normal approximation.

Start with every repair off and only b = 10 points. A always sits second, the accident of sorting runs by name. The judge measures 0.55 − 0.10 = 0.45, and B tops the board. The ranking flips for any b above 0.05, the true margin. At 5,000 battles the band is 1.96 × √(0.45 × 0.55 / 5000) = ±0.014, so [0.436, 0.464] excludes 0.5. More data made the wrong answer look firmer.

Now repair by design, in order. A coin per battle gives 0.5(0.55 + b) + 0.5(0.55 − b) = 0.55 for any b. Length control removes γ. A judge from another family removes s. The swap audit catches the first habit before any of this: it costs two judgments on a few hundred pairs.

Only then, the sample size

With bias handled, how many battles separate 0.55 from 0.50? Call the margin you must resolve m, the win rate p, and the 95% multiplier z.

Say it aloud

n equals z squared times p times one minus p, over m squared.

n
n the number of battles needed.
z2
z squared the confidence multiplier squared; z = 1.96 for 95%.
p(1 − p)
p times one minus p the noise of one battle; largest at p = 0.5, where it is 0.25.
m2
m squared the margin to resolve, squared: halve it and n grows four times.
In plain words

Multiply z squared by the noise of one battle, p times 1 minus p. Divide by the margin m squared. Round up.

With numbers

With m = 0.05, p = 0.5 and z = 1.96: n = 3.8416 × 0.25 / 0.0025 = 384.2, so 385 battles. A 10-point Elo gap is a 51.4% win chance, m = 0.0144, and n is about 4,640.

That is why public arenas need hundreds of thousands of votes. Chatbot Arena reported over 240,000 by early 2024 (Chiang et al., 2024). In August 2024 it added a style control: answer length and markdown counts enter the Bradley-Terry fit as extra inputs. Strength is then read apart from style.

True P(A wins) = 0.55. The judge has a position bias b, and A always sits second. For which b does the leaderboard invert?

Chapter 9

Field Guide

Keep every instrument, its trap and the audit order on one page

Every number in generative evaluation needs three things: an estimator, the bias that estimator carries, and an error bar. Check the verifier first, then preferences, then distributions. Fix bias by design before you buy samples.

InstrumentFormula, in wordsUse whenMain trap
Perplexitye to the minus average log probability of the true tokensA cheap alarm for regressionsNever reads samples; memorizers win
pass@k1 minus (n minus c choose k) over (n choose k)A verifier existsThe plug-in runs low; n too close to k
Bradley-TerryP(i beats j) = s-i over (s-i plus s-j)Pairwise votes become a rankingGaps inside the error bars
Elo scale400 times log base 10 of a strength ratioReadable leaderboard unitsOnline updates depend on order
Order-free win rate(w-one plus w-two) over 2Any pairwise judgeOne seating only
FIDsquared mean gap plus the trace of the spread mismatchOnly samples; fidelity and variety at onceSample count, resize code, feature network
VQA accuracymatching humans over 3, capped at 110 human answers per questionAnswer priors such as "yes"
BLEU-2brevity penalty times the geometric mean of p1 and p2A baseline for overlapBlind to synonyms and to truth
Cohen's kappa(p-o minus p-e) over (1 minus p-e)Two raters, labels with no orderSkewed base rates
Sample sizez squared times p(1 minus p) over m squaredAfter bias is handledTiny margins need huge n

The audit order for any headline number

  1. Layout: was the order random per comparison? Ask for the win rate split by seat.
  2. Judge identity: does the judge share a family with a contestant? Rerun a slice with other judges.
  3. Length: do the answer lengths differ? Rescore with length control.
  4. Prompts and data: who chose the prompts, and did test items leak into training?
  5. Agreement: what is the human-human kappa, and how close does the judge come?
  6. Only now, the error bar and the sample size.
pythonimport numpy as np
def bt_fit(wins, iters=2000):        # wins[i][j] = times i beat j, a square array
    n = wins + wins.T; s = np.ones(len(wins)) / len(wins)
    for _ in range(iters):
        den = (n / (s[:, None] + s[None, :])).sum(1)
        s = wins.sum(1) / den; s /= s.sum()
    return s                                # [0.597 0.245 0.158] for the toy

def order_free(v_first, v_second):     # 1 if the judge picked A, per pair
    return (v_first.mean() + v_second.mean()) / 2, (v_first != v_second).mean()

def kappa(a, b, c, d):                 # both yes, only 1 yes, only 2 yes, both no
    n = a + b + c + d; po = (a + d) / n
    r1, r2 = (a + b) / n, (a + c) / n
    pe = r1 * r2 + (1 - r1) * (1 - r2)
    return (po - pe) / (1 - pe)            # 0.40 for 40, 20, 10, 30

print(bt_fit(np.array([[0,7,8],[3,0,6],[2,4,0]], float)).round(3), kappa(40, 20, 10, 30))

Keep going

LessonWhat it adds
Metric DesignWhat to measure before you estimate it
The Statistics of EvaluationIntervals, the bootstrap and power in depth
Plots That Tell the TruthHow to draw pass@k curves and rating bands honestly
Experiment DesignPreference data from live A/B tests
Regression Testing for MLThese metrics as release gates
The Metrics LadderFrom model metrics up to product metrics
AI EvaluationThe harness: datasets, suites, judge deployment
Agent EvaluationBenchmarks and grading for agents
CS336 L12: EvaluationPerplexity details and contamination
Mode CollapseLow diversity across models, and judges that miss human disagreement
CalibrationWhen to trust a model's stated confidence
CLIPThe embeddings behind CLIPScore
Diffusion and VLMsWhat the scored models do inside

Sources

The takeaway. Refuse to trust a generative score until you know its estimator, its bias and its error bar. Fix the bias by design; then buy down the variance.
You must evaluate a model that writes SQL. Which instrument family comes first?

Now press Present or Teach and explain from memory: why order bias needs a design fix, the subset count behind pass@k, how a strength becomes an Elo number, and what kappa subtracts. Then go back to the hero and run the biased judge again. This time say which repair moved the verdict and why.

Evaluating Generative Models: LLM, VLM, Diffusion
Back to Gleams