# LLM Evaluation Methodology: Benchmarks, Contamination and a Workflow

> Evaluating an LLM means estimating its performance on a whole class of tasks from a finite set of questions. This page covers what MMLU, HumanEval, GSM8K and MT-Bench measure, how to detect contamination, why a mature evaluation has four layers, and a workflow you can adopt.

- URL: https://dmxsf.com/en/wiki/evaluation/llm-evaluation/
- [DMXSF](https://dmxsf.com/en/about/)
- Intermediate
- Updated: 2026-11-27
- Tags: Evaluation

## After this page you will be able to

- Say what an evaluation answers: estimating performance on a whole class of tasks from a finite set of questions.
- Say what MMLU, HumanEval, GSM8K and MT-Bench each measure and how each one is checked.
- Explain how data contamination inflates scores, detect it with n-gram overlap, and know the blind spots of that check.
- Design an evaluation panel with four layers (capability, behavior, safety, experience) and walk through a practical evaluation workflow.

## What evaluation answers

Evaluating an LLM means estimating how it performs on a whole class of tasks from a finite set of questions. Any score therefore raises four questions: what ability does it test, how is it scored, how large is the error, and has the model seen the questions before? This page covers three of them; "how large is the error" is the subject of [The Statistics of Evaluation](https://dmxsf.com/en/wiki/evaluation/eval-statistics/).

Today's models play many roles at once: knowledge Q&A, mathematical reasoning, code generation, multi-turn conversation, tool calling and safe refusals. "Stronger" is therefore not one number but a set of abilities that are related yet not identical. Without good evaluation you cannot tell whether a model really improved or whether the prompt changed, a benchmark got overfit, or an external component did the work.

*Figure: MMLU, HumanEval, MT-Bench and LLM-as-a-Judge each light up a different dimension. A mature evaluation also puts behavior, safety and whole-system performance on the panel.*

## The four classic benchmarks and what each measures

| Benchmark | What it tests | Size | Scoring | Watch out for |
| --- | --- | --- | --- | --- |
| MMLU | Multiple-choice knowledge questions across 57 subjects | 15,908 questions in total, 14,079 of them in the test set | Option accuracy; random guessing gives about 25% | Exam-style format; the questions have been public for years, so contamination risk is high |
| HumanEval | Completing a function from its signature and docstring | 164 hand-written problems | Run unit tests and report pass@k | Few problems, so large error; mostly small functions |
| GSM8K | Multi-step reasoning on grade-school word problems | 7,473 training and 1,319 test problems in the official repository | Whether the final number is correct | Only the final answer is checked, not the reasoning |
| MT-Bench | Multi-turn conversation and instruction following | 80 questions, 10 in each of 8 categories, two turns each | A judge model scores 1 to 10 or compares pairs | Few questions; judges are biased |

The numbers come from the original papers: [MMLU](https://arxiv.org/abs/2009.03300), [HumanEval](https://arxiv.org/abs/2107.03374) and [MT-Bench](https://arxiv.org/abs/2306.05685). The GSM8K [paper](https://arxiv.org/abs/2110.14168) only says about 7.5K training and 1K test problems; the table gives the actual number of rows in the data files of the [official repository](https://github.com/openai/grade-school-math).

### MMLU: breadth of knowledge

MMLU consists of multiple-choice questions from 57 subjects (Hendrycks et al., 2020). The anchors from the paper at release: random guessing is about 25%, unspecialized crowd workers scored 34.5%, few-shot GPT-3 175B scored 43.9%, and the paper estimated expert-level accuracy at about 89.8% across subjects. MMLU is good for comparing knowledge coverage across models. It cannot tell you whether a model is pleasant to chat with, and the multiple-choice format limits what abilities can show. Its questions have been public for years, which makes it the benchmark most exposed to contamination.

### HumanEval: executable verification

The advantage of code problems is that test cases decide right from wrong; an answer that merely looks right will not pass. That made HumanEval the starting point of code evaluation and popularized pass@k, a metric suited to generative models. But it has only 164 small-function problems and is not real software engineering. How much error so few questions bring, and how to estimate pass@k, are covered in [The Statistics of Evaluation](https://dmxsf.com/en/wiki/evaluation/eval-statistics/).

### GSM8K: multi-step math reasoning

GSM8K has 8.5K grade-school word problems, each needing 2 to 8 steps and ending in a number (Cobbe et al., 2021). It is widely used to evaluate reasoning, for example to show the effect of [chain-of-thought prompting](https://dmxsf.com/en/blog/chain-of-thought-prompting/). It checks only the final answer, so a right answer reached through wrong steps still counts; add a check of the reasoning when it matters.

### MT-Bench: multi-turn dialogue and judges

Beyond knowledge and code questions, what users feel most directly is the conversation. MT-Bench uses 80 multi-turn questions covering writing, roleplay, information extraction, reasoning, math, coding, STEM knowledge and humanities knowledge, scored by a judge model. That is cheap, but the judge itself is biased; see [LLM-as-a-Judge: Using a Model as the Grader](https://dmxsf.com/en/wiki/evaluation/llm-as-judge/) for the details.

## Data contamination

Contamination means a benchmark's questions or answers entered the training data, so the score no longer reflects generalization. Pretraining corpora come from the internet, and the questions of benchmarks such as MMLU and GSM8K are public on the internet, so this risk is hard to avoid completely.

### How to detect it: n-gram overlap

The GPT-3 paper gives a typical procedure (Brown et al., 2020, Section 4 and Appendix C). For each benchmark, take $N$ consecutive words from a question, where $N$ is the 5th percentile of the benchmark's example length in words, ignoring punctuation and case, with a floor of 8 and a ceiling of 13. If a question shares even one $N$-gram with any document in the training corpus, mark it "dirty"; the rest are "clean". Then re-evaluate on the clean subset only. A score close to the full-set score suggests contamination probably did not inflate it noticeably; a clearly lower score on the clean subset suggests it may have.

The paper concludes that for most benchmarks the change in score is negligible, with a few exceptions. PIQA had 29% of its examples flagged and a 3-point drop on the clean subset. Winograd had 45% flagged and a 2.6% drop on the clean subset, and 132 of its questions were confirmed to appear in the training set, though in a different format from the evaluation. The paper marks these two results with an asterisk.

```python
import re

def ngrams(text: str, n: int) -> set[tuple[str, ...]]:
    words = re.findall(r"[a-z0-9]+", text.lower())   # ignore punctuation and case
    return {tuple(words[i:i + n]) for i in range(len(words) - n + 1)}

question = "Janet has 3 apples, buys 5 more, and then gives 2 to her friend. How many apples does Janet have left?"
rephrased = "After buying five more apples to add to her original three, Janet hands two over to a friend. What is the number of apples she still holds?"
unrelated = "A train leaves the station at 9 am and travels at 80 km per hour. How far has it gone by noon?"

# A hypothetical pretraining corpus: one web page quotes the benchmark question word for word.
corpus = "Practice problems for grade school students. Problem 7: " + question + " Answer: 6. Problem 8: ..."
corpus_ngrams = ngrams(corpus, 13)

for name, text in [("verbatim", question), ("rephrased", rephrased), ("unrelated", unrelated)]:
    hits = len(ngrams(text, 13) & corpus_ngrams)
    print(f"{name:<9s} 13-gram hits: {hits:2d}  ->  {'dirty' if hits else 'clean'}")

# Output:
# verbatim  13-gram hits:  9  ->  dirty
# rephrased 13-gram hits:  0  ->  clean
# unrelated 13-gram hits:  0  ->  clean
```

### The blind spot of n-grams

In the demo, the verbatim question hits nine 13-grams, while a rephrased question that means exactly the same thing hits none and would be treated as clean. Yang et al. (2023) found that after rephrasing MMLU test questions and training on them, Llama-2-13B can reach 85.9 accuracy on MMLU without being caught by n-gram overlap detection; they therefore propose a decontamination method in which a strong model checks for duplicates at the semantic level. Every detector has blind spots, so no single method should be trusted alone:

| Approach | Idea | Limitation |
| --- | --- | --- |
| n-gram overlap | Remove documents that overlap the benchmark before training; after evaluation, compare the clean subset with the full set | Catches only verbatim copies; rephrasing and translation slip through |
| Semantic deduplication | Use vector similarity or a strong model to find samples with the same meaning | Many false positives; costly |
| Private question sets | The questions are not published and are kept by the evaluator | Hard to reproduce, and no guarantee that the question types have not been seen |
| Continuously refreshed questions | Use a steady stream of new questions, such as weekly programming-contest problems and fresh user prompts (Chiang et al., 2024) | The set keeps changing, so scores from different times cannot be compared directly |
| Look at score patterns | The clean-subset score is clearly lower, or the score is sensitive to small changes in question format | Only indirect evidence |

On the training side, how to treat an evaluation set as a “duplicate document” to remove, what whole-document exact, MinHash near-duplicate and paragraph-level deduplication each catch and miss, measured on a demo corpus, is covered in [Pretraining Data Engineering](https://dmxsf.com/en/wiki/pretraining/data-engineering/).

The evaluation side asks how many copies make a model memorize a question, why n-grams cannot see a rewrite, how much model signals such as the loss gap and Min-K% can see, and how much of the inflation is left after the flagged items are dropped. [Benchmark Contamination](https://dmxsf.com/en/wiki/evaluation/benchmark-contamination/) measures all of it with a real fine-tuning experiment.

The widget below runs this detector in the browser: it recomputes the n-gram hits live on the page's imagined corpus and three texts, and the reader can edit the corpus and the candidate, change N or switch the normalisation off, with the matching spans highlighted.

## A mature evaluation: the four-layer panel

Evaluation is not an afterthought to development: what you measure is what the team will optimize first. Evaluate too narrowly and you get a model that "aces tests but is hard to use", or one that is "charming but inaccurate". A mature evaluation therefore usually covers four layers:

*Figure: What guides product and model iteration is not one benchmark's high score but whether capability, behavior, safety and experience all pass.*

| Layer | What it tests | Typical content |
| --- | --- | --- |
| Capability | Whether the model can do it | Knowledge Q&A, math and logical reasoning, code generation, long-context use |
| Behavior | Whether the model is reliable at doing things | Instruction following, stability of structured output, multi-turn consistency, tool-call success rate |
| Safety | Whether the model could cause harm | Handling of harmful requests, refusals in sensitive scenarios, overreach, hallucination and overconfidence |
| Experience and system | How users and the business feel it | Helpfulness, clarity, length and pacing of responses, plus cost, latency and end-to-end workflow results |

No single benchmark represents all four layers. Reliable teams build a combined evaluation panel instead of trusting one total score. The object of evaluation is also shifting from the bare model to the whole system: prompts, retrieval, tools and safety policies all affect results, so fix them together when you evaluate.

The four most common misconceptions:

| Misconception | Why it is wrong | What to do |
| --- | --- | --- |
| Treating a benchmark score as user experience | Offline questions and live inputs have different distributions | Build the set from real inputs and watch online metrics after launch |
| Treating a better prompt as a better model | The score also moves when the prompt, the system message or the retrieval module changes | Fix the other variables, change one thing at a time and report a confidence interval for the gap |
| Ignoring contamination | Questions in the training data inflate the score | Compare against a clean subset; use private or refreshed question sets |
| Looking only at the average | An average hides persistent failures in one high-risk category | Slice by category, read failure cases and do error analysis |

## An evaluation workflow you can adopt

1. Define the task and write down which kind of error costs the most.
2. Build the evaluation set: draw it from the real input distribution, cover the long tail and edge cases, keep a private part and record the version; question sources, label errors and item information are covered in [Building Evaluation Sets](https://dmxsf.com/en/wiki/evaluation/building-eval-sets/).
3. Choose the scoring method: use tests or rules where answers can be verified; use a judge model or humans for open-ended questions, after calibrating the judge on a small human-labeled sample.
4. Run the evaluation and report the number of questions and the standard error or confidence interval; when comparing two models, use the paired difference (see [The Statistics of Evaluation](https://dmxsf.com/en/wiki/evaluation/eval-statistics/)).
5. Fix the prompt, decoding parameters and system components, and compare against a baseline and ablations on the same questions.
6. Read failure cases, slice by category and turn typical errors into a regression set.
7. After launch, monitor online metrics, feed failures from production back into the evaluation set and check for contamination regularly.

## From offline evaluation to release decisions

The [Stanford CS324 evaluation project](https://stanford-cs324.github.io/winter2022/projects/CS324_P1.pdf) helps turn broad capability questions into testable comparisons. [Chapter 19 of CMU's Machine Learning in Production](https://mlip-cmu.github.io/book/19-testing-and-experimenting-in-production.html) extends that approach to real traffic. When replacing a support retrieval model, define answer success before deciding when to increase exposure.

| Stage | Comparison protocol | What to check |
| --- | --- | --- |
| Offline replay | Use the same historical questions, document snapshot, and grading rules for both versions | Report correctness, abstentions, and evidence coverage by language, question frequency, and unanswerable cases |
| Shadow traffic | Send requests to both versions, keep returning the original response, and isolate tools with side effects | Record timeouts, output format errors, and cost on production requests |
| Canary release | Route a small share of users to the candidate and set the observation window, promotion criteria, and rollback conditions in advance | Check failures and timeouts by version and traffic slice, then restore the original version if the criteria are met |
| A/B test | When estimating product impact, randomize at an appropriate unit such as user or session | Measure outcomes such as resolution or human handoff alongside quality and latency constraints |

Record model, prompt, retrieval index, and evaluation snapshot versions. Shadow traffic measures how the candidate handles real requests. Measuring whether users complete tasks more easily requires observing users who receive the candidate's responses.

## Reconstruct a failed request from version records

[Chapter 24 of CMU's Machine Learning in Production](https://mlip-cmu.github.io/book/24-versioning-provenance-and-reproducibility.html) covers versioning, lineage, and reproducibility. A model name identifies one part of the serving chain. Give each RAG request a trace ID that connects stage outputs to the deployment manifest at the time. At minimum, the manifest identifies the model, tokenizer, prompt, retrieval index, and application versions. Evaluation reports also identify the dataset snapshot, grader, sampling configuration, and runtime.

Suppose citation accuracy drops after a release. Replay a fixed sample on the candidate, then swap the earlier index into that candidate alone. Compare retrieved evidence and final citations. If the evidence returns and citations still fail, isolate the prompt or model next. The manifest should identify a deployable earlier combination so compatible prompts, models, and indexes can be restored together. Serving can be nondeterministic, so inspect individual traces and look for stable changes across a set of examples.

## Summary and exercises

- Ask four things of any score: what it measures, how it is scored, how large the error is and whether the model has seen the questions.
- The four classic benchmarks measure different abilities: MMLU knowledge, HumanEval code, GSM8K math reasoning, MT-Bench multi-turn conversation. None of them represents overall ability.
- Contamination needs several detectors. N-gram overlap misses rephrasing, and a clean-subset comparison is the most direct evidence.
- A mature evaluation is a combined panel across capability, behavior, safety and experience, and its object is the whole system, not just the bare model.

**1. The team rewrote the system prompt and the MMLU score rose by 2 points. Which conclusion is the most reasonable?**

- [ ] The model's ability improved by 2 points
- [x] It cannot be attributed to the model directly: fix the other variables, compare, and report a confidence interval for the gap before judging
- [ ] MMLU is no longer trustworthy and the benchmark should be replaced
- [ ] The model needs to be pretrained again

> The prompt, the system message and the retrieval module all affect the score. MMLU's test set has 14,079 questions, so a 2-point gap is usually statistically solid, but what is solid is that "the score changed", not that "the model got stronger".

**2. Which statements about detecting contamination are correct? (select all that apply)**

- [x] 13-gram overlap only finds verbatim leaks; rephrased questions slip through
- [x] A clean-subset score clearly lower than the full-set score suggests that contamination may have inflated it
- [ ] If the n-gram check finds no hits, that proves the model never saw the content of the question
- [ ] As long as the evaluation set is private, the model has certainly not seen similar questions

> No hits only means there is no verbatim overlap; it cannot rule out rephrasing, translation or similar questions. A private set lowers the risk of leakage but does not guarantee that the question types have not been seen.

**3. Which layer of the four-layer panel do "tool-call success rate" and "stability of structured output" belong to?**

- [ ] Capability
- [x] Behavior
- [ ] Safety
- [ ] Experience and system

> They measure whether the model does things reliably, so they belong to the behavior layer. The capability layer asks whether it can do something at all, such as knowledge, reasoning and code.

**4. After the GPT-3 paper marks "dirty" samples with n-gram overlap, how does it judge the effect of contamination next?**

- [ ] Add the dirty samples to the training set
- [x] Re-evaluate on the clean subset and compare the score with the full set
- [ ] Subtract 5 points from every benchmark
- [ ] Report only the score on the dirty samples

> If the clean-subset score is close to the full-set score, contamination probably did not inflate it noticeably; if it is clearly lower, contamination may have inflated it.

### Exercises

1. Design an evaluation panel for an enterprise customer-service RAG assistant: list two metrics for each of the four layers and say how each is scored.
2. Design a check for whether a benchmark score has been inflated by contamination. Write at least three steps.
3. When you read the evaluation table of a paper, what should you ask before believing that "A is better than B"? List at least four items.

<details>
<summary>Reference answers</summary>

1. There is no single answer; here is an example. Capability: retrieval hit rate (against human-labeled relevant documents) and answer accuracy (against reference answers or human grading). Behavior: compliance with the citation format (rule check) and whether the model admits it does not know when the knowledge base has no answer (human spot check). Safety: refusal rate for out-of-scope questions and resistance to prompt-injection text (red-team cases). Experience and system: time to first token and cost per request (log statistics), and user satisfaction or handoff-to-human rate (online metrics). For each metric, specify the data source (a sample of real tickets), the scoring method and the target threshold.
2. One approach: first search the training corpus or the public web for each question with $n$-gram overlap (for example 13-grams) and mark the questions with hits as "dirty". Then compute the scores on the full set and on the clean subset, compare the gap and attach a confidence interval. Next rephrase or translate the questions and see whether the model scores clearly lower on the rephrased ones than on the originals. Finally add private or newly published questions and confirm that the model ranking stays the same.
3. The number of questions; whether a confidence interval or standard error is reported; whether the two models were compared on the same questions with the same prompt and decoding parameters; $n$, $k$ and the sampling temperature for pass@k; whether contamination was checked; when a judge model is used, which one and whether it was calibrated against humans; whether the gap exceeds the noise and whether a paired analysis was done.

</details>

## Further reading

- Hendrycks et al., [Measuring Massive Multitask Language Understanding](https://arxiv.org/abs/2009.03300) (2020); MMLU
- Chen et al., [Evaluating Large Language Models Trained on Code](https://arxiv.org/abs/2107.03374) (2021); HumanEval and pass@k
- Cobbe et al., [Training Verifiers to Solve Math Word Problems](https://arxiv.org/abs/2110.14168) (2021); GSM8K
- Zheng et al., [Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena](https://arxiv.org/abs/2306.05685) (2023); MT-Bench and judge models
- Brown et al., [Language Models are Few-Shot Learners](https://arxiv.org/abs/2005.14165) (2020); the contamination analysis in Section 4 and Appendix C
- Yang et al., [Rethinking Benchmark and Contamination for Language Models with Rephrased Samples](https://arxiv.org/abs/2311.04850) (2023); rephrased samples that bypass n-gram detection
- Chiang et al., [Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preference](https://arxiv.org/abs/2403.04132) (2024); live, crowdsourced human-preference evaluation
- Liu et al., [Lost in the Middle: How Language Models Use Long Contexts](https://arxiv.org/abs/2307.03172) (2023); a pitfall in evaluating long context
- [The Statistics of Evaluation: pass@k, Confidence Intervals and Sample Size](https://dmxsf.com/en/wiki/evaluation/eval-statistics/): the error in scores, paired comparison and sample size
- [Building Evaluation Sets: Question Sources, Label Quality and Item Information](https://dmxsf.com/en/wiki/evaluation/building-eval-sets/): how label errors lower scores, the kappa trap and item discrimination
- [LLM-as-a-Judge: Using a Model as the Grader, Its Biases and Calibration](https://dmxsf.com/en/wiki/evaluation/llm-as-judge/): open-ended evaluation and judge bias

- White et al., [LiveBench](https://arxiv.org/abs/2406.19314) (2024) and Jain et al., [LiveCodeBench](https://arxiv.org/abs/2403.07974) (2024): "living" benchmarks with regularly refreshed questions, mitigating contamination and targeted overfitting.
- Kapoor et al., [AI Agents That Matter](https://arxiv.org/abs/2407.01502) (2024): makes cost a first-class citizen of evaluation alongside success rate; see [agent evaluation](https://dmxsf.com/en/wiki/applications/agent-evaluation/) for the full discussion.
- [Production evaluation](https://dmxsf.com/en/wiki/evaluation/production-evaluation/)

## Companion code

[Benchmark contamination: an n-gram detector, and a leak you can measure](https://github.com/dmxsf/dmxsf/tree/main/labs/evaluation/llm-evaluation): The page's n-gram contamination detector on its own example; a benchmark whose answers can only be memorised; a model trained with a third of it leaked verbatim, a third paraphrased and a third absent; what the detector flags and what the clean-subset check concludes.

- Run it in the companion repository (add --quick for a fast pass): `uv run dmxsf run evaluation/llm-evaluation`
- [View the lab script](https://github.com/dmxsf/dmxsf/blob/main/labs/evaluation/llm-evaluation/run.py)
- [Lab write-up](https://github.com/dmxsf/dmxsf/blob/main/labs/evaluation/llm-evaluation/README.en.md)
- [`contamination.py`](https://github.com/dmxsf/dmxsf/blob/main/src/dmxsf/evaluation/contamination.py)
- [Find this lab in the catalog](https://dmxsf.com/en/code/#llm-evaluation)

## FAQ

### Why is a benchmark score not enough?

A score is an estimate from a finite set of questions. It carries sampling error (on a 164-question benchmark, 80% accuracy has a 95% interval of about ±6 points), it can be inflated by contamination of the training data or by changes to the prompt or the retrieval module, and an average hides persistent failures in a high-risk category. Combine benchmarks, human spot checks, conversation evaluations and online metrics, and report the error.

### What do MMLU, HumanEval, GSM8K and MT-Bench each measure?

MMLU is multiple-choice knowledge across 57 subjects. HumanEval measures writing code from a function signature and docstring, judged by unit tests and reported as pass@k. GSM8K measures multi-step math reasoning on grade-school word problems and looks only at the final number. MT-Bench is 80 multi-turn conversation questions scored or compared by a judge model, which is closer to real chat and more subjective. They measure different abilities and cannot stand in for each other.

### What is benchmark contamination and how do you detect it?

Contamination means a benchmark's questions or answers entered the training data, so the score no longer reflects generalization. The usual detection is n-gram overlap: GPT-3 used n-grams of 8 to 13 words to find questions that overlap the training set, then compared the score on the clean subset with the score on the full set. Rephrased or translated questions slip past this check, so combine it with private question sets, fresh questions and manual inspection.

### How many questions does an evaluation set need?

It depends on the smallest gap you want to detect, and the number of questions needed grows with the inverse square of that gap. With accuracy around 80%, two models answering the same questions and a correlation of 0.5 between their outcomes, detecting a 2-point gap takes about 3,300 questions and a 1-point gap about 12,800 (5% significance, 80% power). A few hundred questions can only reveal large gaps.

### How do I set up an evaluation workflow?

Define the task and its costliest errors. Build the set from real inputs and keep a private part. Choose the scoring: tests where answers can be verified, and a judge model or humans for open-ended questions, calibrated first. Report the number of questions and confidence intervals, and fix the prompt and decoding parameters when comparing. Read failure cases and turn them into a regression set, then monitor online metrics after launch and check for contamination regularly.
