Skip to content

Chapter 20 — Evaluation and Benchmarks

Part VI — Evaluation, Deployment, and the Ecosystem · 3–4 weeks

What you will learn

This chapter covers the methods used to measure the quality of a language model and to compare two models. It describes intrinsic metrics (perplexity and bits per byte), the standard benchmarks and the two ways in which they are scored (log-likelihood of answer choices and scoring of generated text), human-preference rankings, and the use of a strong model as a judge. It also covers the sources of error in reported scores — prompt format, few-shot settings, sampling noise, and benchmark contamination — and the statistics needed to state whether a difference between two models is significant. Later chapters apply these methods: Chapter 21 measures the accuracy cost of quantization, Chapter 22 measures the effect of fine-tuning and retrieval, and the Chapter 23 capstone requires an evaluation report.

Topics

  • The purposes of evaluation: model selection, regression testing, and reporting
  • Perplexity and bits per byte as intrinsic metrics
  • Standard benchmarks by capability: knowledge (MMLU), commonsense and science reasoning (HellaSwag, ARC), mathematics (GSM8K), code (HumanEval), graduate-level science (GPQA), and instruction following (IFEval)
  • Scoring methods: log-likelihood of answer choices, exact match on generated answers, and unit tests with pass@k for code
  • Evaluation settings that change scores: few-shot examples, prompt and chat templates, answer normalization, and decoding parameters
  • Statistical uncertainty: standard errors, confidence intervals, and paired comparisons
  • Benchmark contamination and saturation
  • Human evaluation and preference arenas: pairwise votes and Elo-style (Bradley–Terry) ratings
  • Use of a large language model (LLM) as a judge, and its position, verbosity, and self-preference biases
  • Agentic, multi-step benchmarks (SWE-bench)
  • Task-specific evaluation: building a test set and a custom harness task
  • Reproducible reporting of evaluation results

Resources

Suggested path. Start with the LLM Evaluation Guidebook and Unit 2 of the smol course, and run lm-evaluation-harness on a small model during the first week; Biderman et al. explains the settings that change its scores. Read chapters 3 and 4 of AI Engineering and watch CS336 lecture 12 in parallel. Then read Miller for the statistics, Zheng et al. and Chiang et al. for judges and arenas, and Oren et al. for contamination. When time is short, read the benchmark papers for the task format only, and omit HELM, Inspect, and the model reports.

University courses

  • Stanford — CS336: Language Modeling from Scratch by Percy Liang and Tatsunori Hashimoto (free; Spring 2026 lecture videos on a YouTube playlist and public assignments; start here: lecture 12, "Evaluation", covers perplexity, knowledge, instruction-following, and agent benchmarks, and validity problems such as contamination).

Online courses (MOOCs)

  • Hugging Face — smol course, Unit 2: Evaluation (free; v2, 2025; about one week; start here: running standard benchmarks with lighteval and building a custom evaluation for a specific domain).

Books

  • Book: Chip Huyen, AI Engineering (O'Reilly, 2025) — book repo (paid book, free chapter summaries; start here: chapter 3, "Evaluation Methodology", on perplexity, exact and similarity-based scoring, and AI judges; chapter 4, "Evaluate AI Systems", on evaluation criteria, model selection, and the design of an evaluation pipeline).

Lectures, papers and articles

Tools and hands-on

  • Tool: EleutherAI, lm-evaluation-harness (free, open source; start here: the harness used by most open-model reports and by this chapter's milestone; tasks are defined in YAML files, and results include standard errors).
  • Tool: UK AI Security Institute, Inspect (free, open source; optional; a framework built from datasets, solvers, and scorers, suited to model-graded and multi-step agent evaluations).

Milestone

On a free Colab or Kaggle T4 GPU, run lm-evaluation-harness on two open base models of 1–2 billion parameters (for example Qwen2.5-1.5B and SmolLM2-1.7B) on ARC-Easy, HellaSwag, and a 250-question subset of GSM8K, and compare each score and its standard error with the value published by the model's authors. Add one custom task of at least 50 questions, defined in a harness YAML task file. Write a two-page report that states the evaluation settings (few-shot count, prompt format, answer normalization) and explains one score difference, either between the two models or between a measured and a published value.

Estimated time

3–4 weeks.