Lecture 13 · Evaluation and Benchmarks

Advanced Natural Language Processing · Lecture 13。个人学习讲义与配套实验,按主题整理并持续修订。

课程源码 ZIP ↓

个人整理的学习笔记,非官方讲义;课程来源与整理说明见课程介绍。配套示例未逐一运行验证。

本篇目录

Maps to: CMU 11-711 Spring 2026, Lecture 13 (02/24), slides anlp-s2026-13-evaluation.pdf (some slides adapted from Seungone Kim, Spring 2025); course code 13_evaluation/errorbars.ipynb (covered in Lecture 14, where the slides put error bars). Reading: E. Miller, Adding Error Bars to Evals: A Statistical Approach to Language Model Evaluations (2024) — mostly for Lecture 14. Sources: the public slides and notebook, and the papers cited in each section. Every number labelled “measured” comes from code/lecture13/, run on the author’s machine (Apple M4 Pro, Python 3.13, PyTorch 2.14, one CPU thread). The judge and arena experiments are simulations with known ground truth; everything else uses models trained in this course. Code: code/lecture13/ — four demos, each under a minute. Reading time: ~90 minutes for the prose; ~15 more for the demos.


0. How to read this lecture

0.1 Learning goals

After this lecture you should be able to:

  1. Explain why a lower loss does not mean a better system, and write down what a downstream evaluation measures: a task metric, applied to outputs of an inference algorithm, averaged over datasets.
  2. List the properties of a good benchmark: breadth, depth, utility, robustness, freedom from contamination, cheap evaluation. Recognize each failing in a real benchmark.
  3. Compute and criticize the standard task metrics: exact match (with normalization), F1, ROUGE, BLEU/chrF, pass@k (and its unbiased estimator), test-based correctness.
  4. Explain LLM-as-a-judge and arena evaluation: win rates, position and verbosity biases and their fixes, Elo vs Bradley–Terry ratings.
  5. Ask “can I trust this score?”: contamination and how it is detected, robustness to rephrasing, floor and ceiling effects.

0.2 Prerequisites and scope

  • Prerequisites:
    • Lecture 3: loss, perplexity.
    • Lecture 7: Fact World, the long tail.
    • Lecture 9: decoding, majority voting / MBR.
    • Lectures 11–12: Shape World, faithfulness checks.
  • Scope: what to measure and with which metric, and whether the measurement means what it claims.
  • Not in scope:
    • How sure we can be of a number: standard errors, paired tests, power. That is Lecture 14.
    • Agent benchmarks (Lecture 18) and reward models (Lecture 17).

0.3 Section → code map

SectionIdeaDemo in code/lecture13/
§1loss vs task success; the inference algorithm is part of the system01_loss_vs_task.py
§3.1exact match, normalization, F1, a task checker02_metrics.py Part A (+ eval_kit.py)
§3.2ROUGE, BLEU, chrF; overlap vs meaning02_metrics.py Parts B–C
§3.3pass@k and its estimator; weak tests02_metrics.py Parts D–E
§4LLM judges: biases and fixes; arenas: Elo vs Bradley–Terry03_judges.py
§5contamination, detection, robustness, difficulty04_trust.py

0.4 Notation

SymbolMeaning
pθp_\thetaa model; L(θ;D)=−1n∑log⁡pθ(yi∣xi)\mathcal{L}(\theta; \mathcal{D}) = -\frac{1}{n}\sum \log p_\theta(y_i \mid x_i) its loss on a dataset
g(pθ,x)g(p_\theta, x)an inference algorithm (greedy, sampling, majority vote, …) producing y^\hat y
m(y,y^)m(y, \hat y)a task metric (1 if correct, an overlap score, …)
p(D)p(D)a distribution over task datasets (“downstream tasks”)
pass@kkprobability that at least one of kk samples is correct
sis_ia Bradley–Terry strength; Elo rating =400log⁡10si= 400 \log_{10} s_i + const

1. Loss isn’t always enough

1.1 Loss-based evaluation

The cheapest evaluation is the one we have used since Lecture 3: the loss on held-out data, L(θ;Dtest)=−1n∑ilog⁡pθ(yi∣xi)\mathcal{L}(\theta; \mathcal{D}_{\text{test}}) = -\frac{1}{n}\sum_i \log p_\theta(y_i \mid x_i). The slides show the LLaMA training curves: the 33B model’s loss sits below the 13B’s. Is the 33B model therefore better?

Loss measures how well the model fits the data distribution, token by token. It does not directly measure how well the model performs tasks. AlphaCode (Li et al., 2022) is the classic counterexample. Late in training, its validation loss increased while the solve rate on programming problems kept improving.

1.2 Measured: the AlphaCode picture in miniature

Why can that happen? A programming problem has many correct programs, and the validation set holds one reference program per problem. Demo 01 builds the smallest task with the same structure: “name a multiple of 4 between 36 and 58”. Six answers are correct, but each training example shows one, chosen at random. A small Transformer trains for 60 epochs on 5,000 such prompts and is evaluated on 1,000 new ones:

epoch618304260
training loss (nats)1.8181.1620.7010.5310.438
validation loss (nats)2.0572.3733.0673.4993.805
sampled success rate83.6%92.5%94.5%94.8%94.2%
entropy of the answer distribution (nats)2.111.531.110.920.84

The validation loss is lowest at epoch 6 and nearly doubles by epoch 60, while the probability of producing a correct answer rises by 11 points. The mechanism is visible in the last row. Training on one arbitrary answer per prompt makes the model confident in some correct answers. So it becomes less likely to say the reference answer, which is all the loss looks at. A model that spread its probability evenly over the correct answers would have a validation loss of 1.667 nats. The training loss, 0.438, falls far below that: the model memorized the references.

Consequences:

  • Checkpoint selection disagrees. Early stopping on validation loss would keep epoch 6 (83.6% success); the success rate prefers epoch 48 (94.9%).
  • A saturated metric says nothing. pass@10 is 99.7–100% at every checkpoint, so it cannot tell them apart (§2.2).

1.3 The inference algorithm is part of the system

The slides define what we actually want: high expected task performance,

ED∼p(D)  E(x,y)∼D  Ey^∼g(pθ,x)[m(y,y^)].\mathbb{E}_{D \sim p(D)}\; \mathbb{E}_{(x, y) \sim D}\; \mathbb{E}_{\hat y \sim g(p_\theta, x)}\big[m(y, \hat y)\big].

  • DD is a downstream task: a dataset representing a use of the model.
  • mm is a task metric.
  • gg is the inference algorithm.

The same model can score very differently under different gg. Demo 01 Part B takes Lecture 9’s Answer World exactly. The model is the true distribution, so its loss is the entropy and no model can do better. For half the people, the correct city is spread over four phrasings (0.15 each) while a wrong city takes 0.30 in one phrasing:

inference algorithm ggspread peopleconcentrated peopleall
greedy (the most likely string)0.0%100.0%50.0%
one sample60.0%60.0%60.0%
majority city of 5 samples (MBR)76.2%77.5%76.8%
majority city of 20 samples (MBR)92.6%93.0%92.8%

Same model, same (optimal) loss: from 50% to 93% depending on gg. A benchmark number belongs to a system: model + prompt + inference algorithm + metric. Reports should say which.


2. Benchmarks

2.1 What a benchmark is

In practice p(D)p(D) is replaced by a finite set of benchmarks. Each is:

  • a dataset DD (sometimes inputs only);
  • a task metric m(y,y^)m(y, \hat y).

A benchmark suite should cover the breadth and depth of what the system must do:

  • for a translation system, many language pairs and domains;
  • for a general LM API, the capabilities customers use.

The slides show two suites:

  • the “key benchmarks” table of the Llama 3 paper: general knowledge, math, code, reasoning, tool use, long context, multilinguality;
  • Gemini 3.1’s model card (February 2026), with agentic and multimodal suites alongside the classics.

Three classics, with their metrics:

  • MMLU (Hendrycks et al., 2021): multiple-choice questions in 57 subjects. The model outputs A, B, C or D; the metric is exact match, m(y,y^)=1[y^=y]m(y, \hat y) = \mathbb{1}[\hat y = y].
  • HumanEval (Chen et al., 2021): 164 hand-written Python problems. The model writes a function; the metric executes it on the problem’s tests, m=∏j1[y^ passes test j]m = \prod_{j} \mathbb{1}[\hat y \text{ passes test } j], reported as pass@k (§3.3).
  • GSM8K (Cobbe et al., 2021): grade-school math word problems. The model writes a chain of thought, then an answer; the metric compares the final number with the reference.

2.2 Properties of a good benchmark

The slides’ discussion produces a checklist. Each item names a way a benchmark can mislead:

propertythe question it asksfailure when missing
breadth / diversitydoes it cover all desired input–output behavior?a model tuned to the benchmark fails on what users actually ask (the slides show prompt types from real users)
depth / difficultyare items hard enough to separate good from bad models?saturation: everyone scores ~100% (or ~0%), so differences are noise. Demo 01’s pass@10 was flat at ~100%; demo 04’s tail items were at chance for both models
utilityis the task a proxy for something we care about?three kinds of utility: a foundation for harder tasks (e.g. financial analysis); usefulness to real users (e.g. tutoring); a medium for research questions (“can a model reason?”)
robustnessdoes the score survive harmless input changes, and does the metric reject wrong outputs?GSM-Plus (Li et al., 2024): perturbed GSM8K questions drop accuracy. HumanEval+ (Liu et al., 2023): more tests per problem expose wrong programs (§3.3, §5.3)
no contaminationwas the test set (or a rephrasing of it) in the training data?inflated scores. The Llemma paper checked for overlap; miniCTX uses a temporal split, with test items created after the models’ data cutoff (§5)
efficient evaluationcan it be scored cheaply and reliably?an expert reading a long chat is expensive, slow and error-prone. Matching an integer is cheap and exact, but simplifies the task

The last row is the central tension of evaluation, and the reason §3–4 exist. Exact automatic metrics need constrained outputs; open-ended outputs need judgment.


3. Task metrics and how they fail

3.1 Short answers: exact match, normalization, F1

Exact match is cheap and unambiguous, but it scores strings, not meanings. SQuAD (Rajpurkar et al., 2016) introduced two softenings:

  • Normalization: lowercase, drop punctuation and articles.
  • Token F1: the harmonic mean of token precision and recall against the gold answer.

Measured (demo 02 Part A). Eleven answers to “where does kemi dorasu live ?”, gold “lima”, with known correctness:

answercorrect?strict EMnormalized EMtoken F1task checker
“lima”yes111.001
“Lima.”yes011.001
“she lives in lima”yes000.401
“In Lima, I believe.”yes000.401
“not lima”no000.670
“lima or paris”no000.500

The AUC is the probability that a correct answer scores above a wrong one. Over all eleven answers it is: strict EM 0.58, normalized EM 0.75, token F1 0.73, and 1.00 for a small task-specific checker. The checker requires exactly the gold city, no other city, and no negation. Normalization fixes formatting but not phrasing. F1 rewards answers that merely mention the gold string, including its negation. This is why benchmarks constrain the output format (“answer with the letter”, “put the final number in \boxed{}”), and why checkers are written per task.

3.2 Long answers: ROUGE, BLEU, chrF, and meaning

For free-form text, the classic option is word overlap with a reference. The slides’ example:

  • Question: “What are the benefits of regular exercise?”
  • Prediction: “Exercise improves mood and health.”
  • Reference: “Regular exercise benefits health and mood.”

Measured (demo 02 Part B; eval_kit.py reproduces the slides exactly):

metricprecisionrecallF1
ROUGE-1 (unigrams: exercise, health, and, mood)4/5 = 0.8004/6 = 0.6670.727
ROUGE-2 (bigrams)000.000
ROUGE-L (longest common subsequence, length 2)2/5 = 0.4002/6 = 0.3330.364

The answer is good, yet depending on nn it scores anywhere from 0 to 0.73 (BLEU-4 0.278, chrF 0.374). Is that desirable? The slides ask for pros and cons.

  • Pros: cheap, deterministic, reproducible, and the only option before strong judges existed. ROUGE remains standard for summarization, BLEU and chrF for translation.
  • Cons: overlap is not meaning.

Measured: overlap ranks meaning backwards (demo 02 Part C). Shape World captions have exactly checkable meanings (Lecture 11). For 500 two-object scenes, demo 02 scores five candidates against the reference “a red cross above a blue square”:

candidatetrue?ROUGE-1ROUGE-2BLEU-4chrFfact checker
paraphrase: “a blue square below a red cross”yes0.870.690.480.731.00
less detail: “a red cross and a blue square”yes0.830.640.460.731.00
objects swapped: “a blue square above a red cross”no1.000.850.540.860.00
colors swapped: “a blue cross above a red square”no1.000.690.520.760.00
one color changedno0.870.690.730.800.00

(Mean scores over the 500 scenes; the example captions are from the first scene.)

AUCs for telling true from false captions:

metricROUGE-1ROUGE-2ROUGE-LBLEU-4chrFfact checker
AUC0.100.210.370.080.101.00

Every overlap metric is far below 0.5: it systematically prefers the false captions. A false caption with the same words overlaps more than a true caption in other words. The checker, which verifies each stated fact, is perfect. This is the idea behind checklist-based evaluation (Lee et al., 2025): define criteria c1,…,cNc_1, \dots, c_N and check whether each is met. Our checker is a checklist with one item per fact. An LLM judge can apply such checklists when the facts cannot be checked by code.

3.3 Code: pass@k, and tests that are too weak

pass@k. Sample kk programs; the problem counts as solved if any passes all tests:

pass@k(y,{y^1,…,y^k})=max⁡jm(y,y^j).\text{pass@}k(y, \{\hat y_1, \dots, \hat y_k\}) = \max_j m(y, \hat y_j).

Estimating it with exactly kk samples is noisy. Chen et al. (2021) draw n≥kn \ge k samples, count the correct ones cc, and use the unbiased estimator

pass@k^=1−(n−ck)/(nk),\widehat{\text{pass@}k} = 1 - \binom{n - c}{k} \Big/ \binom{n}{k},

the probability that kk of the nn samples, drawn without replacement, include a correct one. The tempting plug-in 1−(1−c/n)k1 - (1 - c/n)^k is biased low. The function 1−(1−p)k1 - (1 - p)^k is concave, so by Jensen’s inequality plugging in a noisy p^\hat p underestimates it on average.

Measured (demo 02 Part D): 164 simulated problems with known pass rates, n=20n = 20 samples each, 2,000 simulated evaluations.

kktrue pass@kunbiased estimate (mean)plug-in estimate (mean)
140.41%40.44%40.44%
564.96%64.95%63.58%
1072.24%72.24%69.97%

Weak tests. “Passes the tests” is only as good as the tests. HumanEval has a handful of tests per problem. EvalPlus (Liu et al., 2023) generated many more for HumanEval+, and reported pass rates fell across models: programs that passed the original tests were wrong on edge cases. Demo 02 Part E is a hand-made illustration: 8 small tasks, 4 sampled programs each, half of them with bugs that typical inputs do not trigger. For example, sorted(xs)[-2] for “second largest” fails on duplicates, and sum(xs)/len(xs) crashes on an empty list. All 32 programs pass the base tests (100%); with edge-case tests added, 53.1% do. A metric must reject wrong outputs, not just accept right ones.


4. Judging open-ended outputs: LLMs and humans

4.1 LLM-as-a-judge

When outputs are long and open-ended (chat answers, essays, plans), the slides’ second option is to use an LLM as the judge:

z∼LLM(x,yA,yB;"Which output is better, A or B? Think carefully."),z \sim \text{LLM}(x, y_A, y_B; \text{"Which output is better, A or B? Think carefully."}),

then compute model A’s win rate against model B over a prompt set. Zheng et al. (2023, MT-Bench and Chatbot Arena) found high agreement with humans: GPT-4’s agreement with expert preferences matched the agreement between humans (the slides’ “high agreement with humans”). They also documented biases:

  • position bias: preferring the first answer shown (GPT-4 gave the same verdict under swapped order only about 65% of the time);
  • verbosity bias: preferring longer answers;
  • self-enhancement: preferring outputs of the judge’s own model family.

Measured, by simulation (demo 03). There is no real judge in these notes. Instead, “human” labels follow the true quality difference, and a simulated judge sees the same difference plus noise, plus a bonus for the first position and for length. The parameters were set so that its order-consistency lands near Zheng et al.’s 65%. The point is the method of detecting and correcting bias.

measure (2,000 pairs)value
judge agrees with a human label61.0%
two independent human labels agree64.0%
judge gives the same winner in both orders65.8%
judge picks the answer shown first67.8%

Agreement with humans looks nearly human-level, while a third of the verdicts flip when the order is swapped. Agreement rates hide biases. Always check consistency under swapping.

A verbosity attack. System B gives system A’s answers, padded to twice the length:

who judgeswin rate of B over A
humans53.2%
judge, A always shown first63.2%
judge, both orders averaged80.9%
length-controlled fit, read at equal length52.0%

Two biases interact. With A always first, the position bonus for A partly hides the length bonus for B (63.2%). Averaging both orders cancels the position bias, and the length bias stands alone (80.9%). The fix for length is a length-controlled win rate (AlpacaEval LC, Dubois et al., 2024): regress the judge’s verdicts on the length difference (and position), and read the fit at equal length. That gives 52.0%, the human picture. Dubois et al. report that length control raised AlpacaEval’s correlation with Chatbot Arena rankings.

4.2 Humans: arenas and ratings

The slides’ third option: ask humans. LMSYS Chatbot Arena (Chiang et al., 2024) shows a user two anonymous models’ answers to the user’s own prompt and asks which is better. That gives real prompts (breadth) and human judgment, at the price of noisy, unpaired, crowd-sourced votes. Votes become ratings:

  • Online Elo (from chess): after each vote, move both ratings by K(1−E)K(1 - E), where EE is the expected score.
  • Bradley–Terry: fit P(i beats j)=si/(si+sj)P(i \text{ beats } j) = s_i / (s_i + s_j) to all votes at once by maximum likelihood. Report the strengths on the Elo scale, with bootstrap confidence intervals (resample the votes, refit).

Measured, by simulation (demo 03 Part C): 10 models 35 rating points apart, 32,000 votes; the three newest models get one third of the votes.

trueonline Elo (K = 32)Elo range over 10 vote ordersBradley–TerryBT 95% CI
model 0100010811851000[994, 1009]
model 4114011672001141[1133, 1150]
model 9 (few votes)131511991291322[1306, 1334]

(Three of ten rows; the demo prints all.)

  • Online Elo depends on the order of the votes. The same votes in another order move a rating by up to 218 points, against 35 points between neighbors. Bradley–Terry uses all votes at once and is order-free, which is why the Arena moved to it.
  • Rankings need votes and need intervals. The Kendall correlation with the true ranking was 0.83 / 0.95 / 1.00 / 1.00 at 500 / 2,000 / 8,000 / 32,000 votes. Even at 32,000 votes, one neighboring pair’s 95% intervals overlap, and the rarely voted models have the widest intervals. A leaderboard should report ranks with uncertainty — Lecture 14’s subject.

5. Can I trust the benchmark score?

5.1 Contamination

If test items (or close rephrasings) were in the training data, the score measures memory of the test, not the skill. Web-scale pretraining makes this hard to rule out: benchmarks are published on the web, discussed, copied into forums and solution sites. Two kinds of check:

  • Data side: search the training corpus for n-gram overlap with the test set. Model reports do this with 8- to 50-gram matches; the Llemma paper checked its math corpus against MATH test problems. This requires access to the training data.
  • Model side: test whether the model behaves as if it saw an item. Min-K% Prob (Shi et al., 2024) averages the log-probabilities of an item’s least likely tokens. Text seen in training has fewer very surprising tokens.

The structural fix is a temporal split: test items created after the model’s data cutoff. miniCTX takes theorem-proving problems from projects created after the cutoff.

Measured (demo 04, real models). Three Fact World LMs answer a 900-question closed-book benchmark. Every model saw every fact as a statement during training. In the contaminated model’s corpus, 300 benchmark items appear verbatim and 300 rephrased (“q : in which city does X reside ? a : lima .”), 3 copies each among ~30,000 documents.

modelleaked verbatimleaked rephrasedclean itemsbenchmark score
larger, clean41.7%40.3%42.0%41.3%
larger, contaminated63.0%55.7%44.7%54.4%

The headline score rises 13 points with no change in the model’s ability on clean items (44.7% vs 42.0%). Relative to what the model knew, the inflation is largest on the tail: rare facts went from 7.7% to 20.7%, while the head went from 88.0% to 97.0%. Contamination does most damage exactly where a benchmark is supposed to be hard.

Detection:

leakflagged by 8-gram overlapMin-K% AUC vs clean itemscontrol: same test on the clean model
verbatim100%0.600.49
rephrased30.7%0.570.47
(clean items, false alarms)36.3%——
  • The n-gram check catches every verbatim leak, but also fires on 36% of clean items. Templated questions share 8-grams across people (“q : what is the job of ”). It flags rephrased leaks no more often than clean items. Yang et al. (2023) showed that rephrased test sets evade such checks while inflating scores.
  • Min-K% needs no training data and gives a real but weak signal. The clean model’s control is near 0.5, as it should be.

5.2 Robustness

A score should measure the skill, not the benchmark’s wording. Demo 04 rephrases the clean items with words the models never saw in training (“in which city does X reside ?”):

modelbenchmark wordingrephrased
small, clean17.7%1.0%
larger, clean42.0%6.7%

The models know the facts, since they answer in the familiar wording, but cannot access them through unfamiliar words. Real LLMs are far more robust than these 2-layer models, but the direction is the same. GSM-Plus found accuracy drops under perturbations of GSM8K problems: numbers changed, distractors added, questions reworded. Robustness checks belong in every evaluation report.

5.3 Difficulty: floors and ceilings

Do the items separate the models we want to compare? Demo 04 compares a small and a larger clean model by popularity stratum:

stratum (300 items each)smalllargerdifference
head (ranks 1–100)30.3%88.0%+57.7 points
torso (101–1,000)10.7%28.3%+17.7
tail (1,001–2,500)5.7%7.7%+2.0

The tail is at the floor: both models are near the 5% guessing rate, so it says “tie” about very different models. Saturated benchmarks show the mirror image, a ceiling where every strong model scores ~100%. Jason Wei’s point in the slides is that evaluations must be hard enough to separate frontier models. They must also not be so hard that everyone is at chance. Items carry information about a comparison only when the models disagree on them, and Lecture 14 makes this precise: paired comparisons and their variance.


6. Summary

  1. Loss ≠ task performance.
    • With many correct answers, validation loss rose 1.85× while the success rate rose 11 points (AlphaCode’s pattern), so checkpoint selection by loss picks the wrong model.
    • The inference algorithm is part of the system: the exact Answer World model scores 50% (greedy) to 93% (majority of 20).
  2. Benchmarks = dataset + metric. Good ones have breadth, depth, utility and robustness, are free of contamination, and are cheap to evaluate. Examples: MMLU (exact match), HumanEval (tests, pass@k), GSM8K (final answer).
  3. Metrics fail predictably.
    • Strict EM rejects correct paraphrases, and F1 rewards “not lima”.
    • Overlap metrics prefer false captions with the right words (AUC 0.08–0.37); checking each stated fact gives AUC 1.00.
    • pass@k needs the unbiased estimator; weak tests inflate pass rates (100% → 53% with edge cases).
  4. Judges.
    • An LLM judge can agree with humans at human-like rates and still flip a third of its verdicts when the order is swapped.
    • Judge both orders and control for length (padded copies: 80.9% → 52.0%).
    • Arenas need Bradley–Terry (order-free), many votes, and intervals.
  5. Trust.
    • Contamination inflated a benchmark by 13 points, most on the tail. n-gram checks miss rephrased leaks and raise false alarms on templated benchmarks; Min-K% gives a weak model-side signal.
    • Rephrasing exposed the wording dependence (42.0% → 6.7%).
    • Floors and ceilings hide real differences.

Common pitfalls

  • Selecting checkpoints or models by validation loss when the task has many correct outputs.
  • Reporting a score without the inference algorithm, prompt and metric that produced it.
  • Strict exact match on free-form answers, or F1 on answers where negation matters.
  • ROUGE/BLEU as a proxy for correctness. They measure overlap and can rank false outputs above true ones.
  • The plug-in pass@k estimator, or pass@k with only kk samples.
  • Trusting “passes the tests” without asking how strong the tests are.
  • LLM-judge win rates without swapping positions and without controlling for length.
  • Online Elo on a fixed set of votes; leaderboards without intervals.
  • Assuming a published benchmark is uncontaminated. Prefer temporal splits or private held-out sets, and report decontamination checks.
  • Comparing models on saturated or floor-level items.

Exercises

  1. Many right answers. A task has 6 correct answers per prompt; references are drawn uniformly. Model A spreads 0.9 evenly over the 6 correct answers (and 0.1 over wrong ones). Model B puts 0.95 on a single correct answer. Compute each model’s expected reference loss and success rate. Which would you deploy?

    AnswerA: each correct answer has 0.15; expected loss $= -\log 0.15 = 1.90$ nats; success 90%. B: the reference is B's favorite with probability 1/6 (loss $-\log 0.95 = 0.05$); otherwise its probability is tiny (say 0.01: loss 4.6). Expected loss $\approx \frac{1}{6}(0.05) + \frac{5}{6}(4.6) = 3.84$ nats; success 95%. B has twice the loss and the higher success rate. Deploy by the task metric: B (unless diversity matters).
  2. Inference algorithms. For a spread person in Answer World, compute the probability that a majority vote over 3 samples picks the correct city (correct 0.6, wrong 0.3, others 0.1 spread over 8 cities).

    AnswerCorrect wins if it appears at least twice: $P(\ge 2 \text{ of } 3) = 3(0.6)^2(0.4) + 0.6^3 = 0.432 + 0.216 = 0.648$. It also wins some three-way ties (one each of correct, wrong, other), broken at random: $P = 6 \cdot 0.6 \cdot 0.3 \cdot 0.1 = 0.108$, times 1/3 = 0.036. Total ≈ 0.68, up from 0.6 for one sample (and 0 for greedy).
  3. ROUGE by hand. Prediction “the cat sat on the mat”, reference “the cat is on the mat”. Compute ROUGE-1, ROUGE-2 and ROUGE-L F1.

    AnswerUnigrams: the(2), cat, on, mat match (sat/is do not): 5 of 6 each way, so P = R = F1 = 0.833. Bigrams: "the cat", "on the", "the mat" match, 3 of 5 each: F1 = 0.6. LCS: the cat on the mat = 5, so P = R = F1 = 0.833.
  4. The unbiased pass@k estimator. With n=10n = 10 samples of which c=2c = 2 pass, compute pass@1, pass@5 and the plug-in estimate of pass@5. Why is the plug-in lower?

    Answerpass@1 = 1 − C(8,1)/C(10,1) = 0.2. pass@5 = 1 − C(8,5)/C(10,5) = 1 − 56/252 = 0.778. Plug-in: 1 − 0.8⁵ = 0.672. The plug-in treats the 5 draws as independent with replacement at rate $\hat p$. Averaged over the randomness of $\hat p$, the concave $1 - (1 - \hat p)^5$ is lower than at the true $p$ (Jensen). The unbiased estimator counts subsets of the actual samples.
  5. Detecting position bias. You have a judge’s verdicts on 500 pairs in the order (A, B). How would you test for position bias, and how should you report the win rate?

    AnswerRerun the judge on the same 500 pairs in order (B, A). Report the consistency rate (same winner both times) and the first-position rate. A win rate should use both orders: count a win only when both agree, or average the two orders' outcomes and treat disagreements as ties. If consistency is low, the judge's verdicts on close pairs are mostly noise plus bias.
  6. Elo vs Bradley–Terry. Why does online Elo depend on the order of votes while a Bradley–Terry fit does not? When would you still use online Elo?

    AnswerOnline Elo is a stochastic-gradient update with step size K on one vote at a time. Recent votes count more, and the final ratings depend on the path. Bradley–Terry maximizes the likelihood of all votes jointly, a function of the vote *counts* only. Online Elo suits settings where strengths change over time (players improve; a model is updated) and recency should matter. For fixed models, fit Bradley–Terry and bootstrap.
  7. Contamination arithmetic. A benchmark of 1,000 items has 20% leaked. A model scores 90% on leaked items and 60% on clean ones. What is its reported score, and what would an uncontaminated measurement give? What if leaked items were the hardest ones?

    AnswerReported: 0.2·0.9 + 0.8·0.6 = 0.66; clean estimate: 0.60 (the score on clean items, assuming they are like the leaked ones). If the leaked items were the hardest, the model's true ability on them might have been ~20%. Its true benchmark score would be 0.2·0.2 + 0.8·0.6 = 0.52, so contamination inflated it by 14 points. As in demo 04, the inflation concentrates where the model knew least.
  • Assignment 2 (end-to-end NLP system building, due soon) asks you to evaluate a system you built. Use this lecture as a checklist:

    • Say which metric, which inference algorithm, which test data.
    • Check that the metric agrees with correctness on a sample you label by hand.
    • Keep a held-out set that never influenced a design decision.
  • Assignments 3–4 compare against baselines: Lecture 14 adds the statistics.

    These notes do not provide assignment code.

Further reading

  • Y. Li et al., “Competition-Level Code Generation with AlphaCode”, Science 2022.
  • D. Hendrycks et al., “Measuring Massive Multitask Language Understanding” (MMLU), ICLR 2021; M. Chen et al., “Evaluating Large Language Models Trained on Code” (HumanEval, pass@k), 2021; K. Cobbe et al., “Training Verifiers to Solve Math Word Problems” (GSM8K), 2021.
  • J. Liu et al., “Is Your Code Generated by ChatGPT Really Correct?” (EvalPlus / HumanEval+), NeurIPS 2023; Q. Li et al., “GSM-Plus”, ACL 2024.
  • C.-Y. Lin, “ROUGE”, 2004; K. Papineni et al., “BLEU”, ACL 2002; M. Popović, “chrF”, WMT 2015; P. Rajpurkar et al., “SQuAD”, EMNLP 2016.
  • L. Zheng et al., “Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena”, NeurIPS 2023; W.-L. Chiang et al., “Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preference”, ICML 2024; Y. Dubois et al., “Length-Controlled AlpacaEval”, 2024.
  • W. Shi et al., “Detecting Pretraining Data from Large Language Models” (Min-K% Prob), ICLR 2024; S. Yang et al., “Rethinking Benchmark and Contamination for Language Models with Rephrased Samples”, 2023.
  • E. Miller, “Adding Error Bars to Evals”, 2024 (course reading; Lecture 14).

Preview of Lecture 14 — Research skills and experimental design

Every number in this lecture came without an error bar. Is 63.0% vs 41.7% on 300 items a real difference? Is CLIP’s 8-of-11 better than chance (no, p = 0.23)? Lecture 14:

  • standard errors and confidence intervals from the central limit theorem;
  • clustered questions;
  • paired comparisons;
  • power analysis: how many test items a comparison needs;
  • inter-annotator agreement;
  • how to turn a research question into a falsifiable hypothesis and an experiment that can test it.

术语表 (Glossary, English → 中文)

English中文
loss-based evaluation / validation loss基于损失的评估 / 验证损失
downstream task / task metric下游任务 / 任务指标
inference algorithm推理算法
checkpoint selection / early stopping检查点选择 / 早停
benchmark / benchmark suite基准 / 基准套件
breadth / depth / utility / robustness广度 / 深度 / 实用性 / 鲁棒性
saturation / floor effect / ceiling effect饱和 / 地板效应 / 天花板效应
exact match / normalization / token F1精确匹配 / 归一化 / 词元 F1
ROUGE / BLEU / chrFROUGE / BLEU / chrF
n-gram overlap / longest common subsequencen 元重叠 / 最长公共子序列
checklist-based evaluation / checker基于检查清单的评估 / 检查器
pass@k / unbiased estimator / Jensen’s inequality前 k 次通过率 / 无偏估计 / 詹森不等式
unit test / edge case单元测试 / 边界情况
LLM-as-a-judge / win rate大模型作评审 / 胜率
position bias / verbosity bias / self-enhancement bias位置偏差 / 冗长偏差 / 自我偏好偏差
length-controlled win rate长度控制胜率
Chatbot Arena / pairwise vote聊天机器人竞技场 / 成对投票
Elo rating / Bradley–Terry modelElo 等级分 / Bradley–Terry 模型
bootstrap / confidence interval自助法 / 置信区间
Kendall’s tau肯德尔等级相关系数
data contamination / test-set leakage数据污染 / 测试集泄漏
decontamination / temporal split去污染 / 时间切分
membership inference / Min-K% Prob成员推断 / 最小 K% 概率
perturbation / rephrasing扰动 / 改写
AUC (area under the ROC curve)曲线下面积
← 返回课程目录