Lecture guides›
✎

Lecture guide: Evaluation#

Lecturer: course staff · Course: Stanford CS336 Language Modeling from Scratch, Spring 2026, lecture 12 · Length: 1:20:00 Video: watch on YouTube Chapters that cite this lecture: 09. Evaluating Language Models

In one sentence: Percy Liang turns the question "how good is this model?" into concrete metrics, from perplexity through exams, chat, agents, reasoning and safety, and shows that every evaluation trades difficulty against realism and validity, so the purpose must be declared first.

Before you watch#

The lecture needs only the idea of a language model as a distribution over token sequences, and it comes just before the lectures on training data. It is a tour of benchmarks with two threads underneath: turning an abstract construct into a metric, and keeping that metric valid. The video has no chapter marks. The chapter Evaluating Language Models arranges the same material by kind of evaluation.

The lecture, part by part#

0:00–4:00 What is a good model?#

The course has covered how to train, speed up, scale and serve a model; training data comes next week, and it shapes behaviour. Before data comes the question of which behaviour is wanted: evaluation asks, given a trained model, how good is it? It looks mechanical, prompts in, responses out, an accuracy computed, but it is deep and important, because evaluation sets the north stars that every developer, open or closed, measures progress against, and so shapes what models learn to do. The core difficulty is turning an abstract construct, being good at conversation or at reasoning, into a concrete metric powered by prompts or environments. And what is "good" anyway? Doing well on benchmarks, as the intelligence index of Artificial Analysis measures it; doing well at a low cost, where the index against inference price shows a correlation that is not exact; being preferred by people, the approach of the arena, Chatbot Arena in its earlier name; or being chosen and paid for, which OpenRouter's usage statistics show, an economic lens on a set of users that is not representative of all use. None of these is necessarily the correct answer; the point is to think in several ways. In this book: Evaluating Language Models › Why this matters · Evaluating Language Models › The core idea.

4:00–10:00 Perplexity: the classic measure and its paradigm#

Start from what a language model is, a distribution over sequences. Perplexity, likelihood and log loss ask how much probability the model assigns to a test set, normalized to be readable. Training minimized perplexity on the training set, so the obvious step is to measure it on a test set, which is what language-modeling papers did through the 2010s, on the Penn Treebank, WikiText-103 and the One Billion Word benchmark. That is the classic in-distribution paradigm: train on a split, test on the other split. Progress was measured as perplexity reduction, as in a famous 2016 paper that applied convolutional and recurrent networks to One Billion Word, at a time when n-gram and hybrid models were still discussed, the first definitive result that pure neural models were the way to go. GPT-2 changed the paradigm in 2019: trained on WebText, 40 GB of pages linked from Reddit, it was evaluated zero-shot on the standard data sets, out of distribution. On the small Penn Treebank it reached a perplexity of 35 against a state of the art of 46, though it did less well where plenty of in-distribution data existed, and he does not know whether overlap with its training data was carefully removed. Training on a large corpus and evaluating on standard benchmarks was a novelty then and the norm now. In this book: Evaluating Language Models › Perplexity.

10:00–18:00 Perplexity is all you need? Perplexity in disguise, and its traps#

Liang offers, half seriously, the mindset that drives much language-modeling research: perplexity is all you need. The best achievable perplexity is the entropy of the true distribution, reached when the model equals it, and a model that equals it can condition on a question and produce the answer. So pushing perplexity down ends in general intelligence. Before GPT-3 made the impact obvious, that belief sustained the people who kept scaling. Yet perplexity is more than needed. For the sentence that Stanford was founded in 1885, it charges for every token, while only the year carries knowledge, a question-answering example in the clothing of sentence completion. Conditional perplexity, measured on the response given a prompt, focuses on the tokens that matter. Some benchmarks are perplexity in disguise: LAMBADA, from 2016, asks for the last word of a passage, chosen so that long-range context is needed to resolve it, which suited the early GPT papers' interest in long context; HellaSwag is multiple-choice sentence completion. One warning: a perplexity leaderboard is hard to run. Entrants receive the test data and return log-probabilities, and the organizer must trust that they are valid, since a program that always returns probability one would win. Downstream tasks need no such trust, only responses. And some models expose only a bound on the likelihood. Perplexity remains in heavy use: it varies smoothly with scale, which scaling laws need, and it convinces believers. In this book: Evaluating Language Models › Perplexity.

18:00–26:00 Exam benchmarks: from MMLU to GPQA#

Exams give control over subject and difficulty and have unambiguous answers, so they are easy to grade, and much benchmarking culture is built on them. MMLU, published in 2020, was ahead of its time: 57 subjects, assembled by a team who scoured the internet, and, for all its name says about language understanding, a test of knowledge and reasoning. It was run on GPT-3 with few-shot prompting, a prompt of in-context question and answer pairs followed by the question, a radical thing to expect of a model then. Small models were barely above chance and the largest well above it. The benchmark has saturated: from roughly 35% in 2020, by his account, to the nineties now. Around 2024 it was made harder: noisy and trivial questions removed, ten options instead of four, chain of thought expected. Accuracy fell to 33% and has climbed back near 90. GPQA, graduate-level and Google-proof, rests on the idea that a question answerable by search is answerable by a model trained on the web. Sixty-one PhD contractors wrote questions, experts reviewed them, the authors revised them, a second expert looked again, and non-experts with Google tried them: the diamond set keeps questions on which two experts agree and at most one non-expert succeeds. PhDs scored 65%, non-experts with half an hour and Google a little above chance, GPT-4 at the time 39%, and the current leaders 94%. Benchmarks have a short shelf life, though they stay useful for small models and scaling laws. Asked about contamination, he answers that nobody knows what is in the training sets, that the numbers deserve a grain of salt, and that contamination is often indirect, questions being derived from sources that were trained on. In this book: Evaluating Language Models › Exams.

26:00–30:00 Humanity's Last Exam, and the limits of exams#

Humanity's Last Exam, from the previous year, threw everything at difficulty: multimodal, many subjects, multiple choice and short answer, crowdsourced with money and with authorship, reviewed in stages and filtered by frontier models, with a private set held back from release. One can only hope that prompts sent through the APIs stay out of future training. Every benchmark paper shows the same picture, earlier benchmarks solved and the new one unsolved; this one started in the single digits, and the best score in 2026 is 64.7%, so there is room left. The trend is toward harder questions, and multiple choice survives it, since its difficulty has no ceiling; what it limits is the kinds of questions that can be asked. The main problem with exams is that they do not capture real use: nobody asks a model such questions outside the evaluation. To a question on grading: multiple choice is a letter match, and for generated answers a chain of thought is produced and the answer extracted, a step to which results can be sensitive. In this book: Evaluating Language Models › Exams.

30:00–38:00 Chat benchmarks: the arena#

Most people ask open-ended questions, sometimes without a correct answer or even a well-formed one, and no exact match can grade the replies. The arena's method asks humans. Anyone can chat on the site, receives answers from two anonymized models, and votes: "A is better", "both are good", "both are bad", "B is better". The votes are pairwise comparisons, and Elo ratings turn them into a ranking: the probability that one model beats another is a smooth function of their two ratings, and the ratings are fitted to maximize the probability of the observed votes. What is good about it: real prompts, since people come for free access to a model and presumably use it for something. What to keep in mind: who these people are; possible biases, spammers, or those who submitted a model and want it to shine; and that a binary preference conflates style with correctness, whereas in chess only winning matters. The asker is the judge, who knows their intent but presumably not the answer, and sycophancy rewards pleasing over honest answers. The beauty of Elo is that the same prompts need not go to every model: sparse comparisons suffice as long as the graph is connected, humans need only compare two answers, and new prompts and models update the rankings naturally. In this book: Evaluating Language Models › Open-ended chat.

38:00–44:00 LM-as-judge: AlpacaEval and WildBench#

AlpacaEval, from 2023, takes instructions from several sources and reports the win rate of a model against a baseline model, GPT-4 preview at the time, judged by that same model, which raises the question of bias. It is an instance of the model-as-judge, now very popular, whose bias can be mitigated with several judges. Its first problem was that judges favour long responses, and fine-tuned models with verbose answers gamed the leaderboard until a later version removed the bias with a simple regression. That raises the general question of how to evaluate a metric, which has no answer; a sanity check is correlation with other metrics, and AlpacaEval's with the arena is 0.98, for the models of that time. WildBench collected prompts from a free chat service like the arena and judges with a model like AlpacaEval; its innovation is a checklist generated for each prompt, a rubric that turns the ill-defined question "is this response good?" into a scoped task. Its correlation with the arena is admittedly circular, but everyone is in the same boat. Liang's conclusions for open-ended responses: pairwise comparison against a reference carries directional signal, absolute scores much less; humans and model judges each have biases; evaluating over several judges, human and model, is the most one can do; and rubrics make evaluation better defined for humans as much as for models, as anyone who has run crowdsourcing knows. In this book: Evaluating Language Models › Open-ended chat.

44:00–50:00 Agents: SWE-bench, Terminal-Bench and capture the flag#

From what models say to what they do. An agent is a language model plus a scaffold, the logic that decides how the model is called and which tools it has. SWE-bench gives a codebase and the description of a GitHub issue and expects a pull request, graded by unit tests designed to fail before the fix and pass after, with nothing else broken. The evaluation is straightforward: about 16% in 2024, about 93% now on SWE-bench Verified, a cleaned version to which he returns. It pioneered realistic assessment of coding agents. Terminal-Bench makes the environment a computer terminal, simple and universal; its tasks were crowdsourced from 93 people around the world, 89 of the tasks making up version 2.0, and take a human from an hour to more than a week. Frontier models lead, and the same model under two agents scores differently. A third kind is cybersecurity: the agent runs commands, reaches a web server and must extract a flag, a unique string, as in the capture-the-flag exercises humans play. A very simple scaffold keeps one continuous memory: an action, the environment's feedback, both appended to the history, which grows until context management is needed. The best models scored around 10% when that leaderboard appeared; it is solved now. In this book: Evaluating Language Models › Agents.

50:00–54:00 Scaffolds, and ML engineering benchmarks#

MLE-bench is a set of Kaggle competitions: the agent reads the data and the description, writes code, trains models and submits, and receives a grade. The leading models are the familiar ones, while the scaffolds vary widely, and scaffolds matter a great deal for complicated tasks. What people have learned: explicit planning helps, a to-do list that gets checked off, rather than a stream of consciousness in which the agent loses its place; hierarchical delegation, in which subagents do work on a cleaned context and return only the result; memory in explicitly read and written files once the context grows; and context engineering that manages the process itself, when to delegate, which strategy to try, what to persist, all tuned to the particular model. Evaluating agents therefore means evaluating the model and the scaffold together. In this book: Evaluating Language Models › Agents.

54:00–60:00 Pure reasoning: ARC-AGI#

All the tasks so far need linguistic and world knowledge. Can reasoning alone, fluid intelligence, be isolated from facts? ARC-AGI, started in 2019, aimed at tasks solvable by every human and hard for AIs, each one a special case, so that memorized facts and earlier problems would not help; in the GPT-2 era that was prescient. Its grids ask what comes next, a ten-second puzzle for a person. Pretrained models of the GPT-3 generation scored zero on it, exactly as intended: what they learned from the internet did not help directly. In 2024, with OpenAI's o1 and o3, scores took off abruptly, and the first version is basically solved; the second, released in 2025, is on its way. Reasoning unlocked it, which leaves open how necessary pretraining knowledge was; without it there would be no reasoning models, but it was not directly visible on these tasks. ARC-AGI-3, released the month before, is an interactive game environment without language, with extremely low scores. His reflections: disentangling reasoning from knowledge is very hard, and the tasks still come from some prior; the goal of being human-solvable excludes superhuman reasoning such as open mathematics; and the gaps it exposes are real work to be done. To a question: the input is a 64 by 64 image, or ASCII art, a spatial element that is not natural language. In this book: Evaluating Language Models › Reasoning, safety and real work.

60:00–64:00 Safety#

For cars, safety has a clear meaning, built over decades of crash tests and lobbying. For AI, he has no great answer, only examples. HarmBench prompts a model with harmful requests and expects refusal, the dominant idea: stopping bad actors. AIR-Bench takes a holistic view, building a taxonomy of what can go wrong from the regulatory frameworks of the EU, China and the US and from company policies, then constructing a set of prompts from it. Jailbreaking is a problem of its own: models are trained to refuse, and clever prompts get around it. Early work optimized prompts automatically with GCG, a coordinate-wise method, and attacks found on open models transferred to closed ones; a gibberish suffix once made a commercial model comply with a request for a plan to destroy humanity, whatever the plan's merit, when refusal was expected. Safety is also contextual, in politics, law and social norms that differ by country, and the risks differ: hallucination in medical, legal or financial settings, which fades as capability grows; sycophancy and abetting crimes, which may run against capability; inequality and lost critical thinking, which correlate with it; and dual use, since a cybersecurity agent can break into a system or test its defences. In this book: Evaluating Language Models › Reasoning, safety and real work.

64:00–68:00 Ecological validity: evaluations drawn from real work#

How well does an evaluation capture real use? Exams are far from it, and the arena has real people, though perhaps not the right distribution of people or of use cases. Some benchmarks aim at the level of use cases. GDPval, created by OpenAI, takes the nine sectors with the largest share of US GDP and 44 occupations, and has professionals with about 14 years of experience, nurses, concierges, real-estate agents, film editors, write tasks. In medicine, earlier benchmarks used standardized exams, and a model should no more go straight from passing exams to patients than a graduate does: 121 tasks were collected from 29 clinicians, the kinds of things clinicians would actually ask. Real data sits with the developers; privacy keeps others from reading it, but language models can read it and summarize the patterns, such as what people use a model for. Realism and privacy pull against each other, since a sample of the true query stream would be valuable material for understanding a model's errors. In this book: Evaluating Language Models › Reasoning, safety and real work · Evaluating Language Models › How it works: keeping evaluations valid.

68:00–72:00 Contamination, and four ways to deal with it#

Before foundation models the rule was simple: ImageNet and SQuAD had train and test splits and everyone played the same game. Now models train on the internet and beyond, and nobody knows what is in the data. Four routes follow. Infer whether a model has seen the test set: Hashimoto's group exploits the fact that the order of a benchmark's questions should carry no information, so a model that prefers that order has trained on it. Establish norms: as statistics reports confidence intervals, a position paper argues that a provider claiming a GPQA score should justify that it did not train on the test set. Assume the worst and define fresh evaluations: LiveCodeBench and similar efforts scrape new pages, papers and repositories later than a model's cutoff, though timestamps are not entirely safe, since a new repository may derive from an old one. Or keep evaluations private: companies evaluate on internal code, and he can use the papers rejected during his graduate years that never went online. This last route favours perplexity, which needs only a good data set. In this book: Evaluating Language Models › How it works: keeping evaluations valid.

72:00–76:00 Data set quality, and auditing#

SWE-bench Verified exists because the original had tasks whose unit tests were not rigorous enough. GSM8K and MMLU have been audited too, and questions were found to be broken, one referring to a curve that no text supplies, another asking whether a baby wears socks. Agentic benchmarks are harder to audit, since the object is a whole environment, and test cases can be incomplete: an agent may pass them all without a working solution. On τ-bench an agent that returns only empty responses scores 38%. The tool Docent has language models inspect agent traces for problems, a qualitative answer to a quantitative habit. His advice, whether building a benchmark or running a model on one: look at the outputs and audit them, to make sure that what is measured is what was meant. In this book: Evaluating Language Models › How it works: keeping evaluations valid · Evaluating Language Models › Pitfalls.

76:00–1:20:00 What is the point? Choosing what to measure#

There is no single evaluation, and the purpose is rarely stated. A buyer choosing between two models for a use case, a researcher with an intuitive notion of intelligence, someone weighing benefits and harms for business or policy, and a developer who wants feedback will each need different benchmarks or combinations of them. What is evaluated has also changed: before foundation models, researchers evaluated methods on fixed train and test splits, with the algorithm as the only variable; today they evaluate models and systems in which anything goes, with the nanoGPT speedrun an exception that measures an algorithm, how fast a model can be trained. Evaluating the end model is useful, since it is what ships. The punchline: declare the goal. The kinds of evaluation, perplexity, exams, chat, agents, reasoning and safety, differ in difficulty, realism, validity and contamination, and no benchmark is at once real, hard, ecologically valid and free of contamination, so each goal decides which factor to compromise. Next week: training data. In this book: Evaluating Language Models › Key takeaways · Evaluating Language Models › What the practitioners say.

What to take away#

Sources#