Evaluating AI systems
How do you check that an AI system works for your case?
Lesson complete
If you like:
A vendor shows you that its model got the top score on a famous public exam. Sounds good. But the question that matters is a different one: does it work for your case?
No voice: the lesson advances on its own with subtitles.
The voice for this lesson is being recorded: for now it advances on its own with subtitles.
Review modeComment on this stepI finished the lesson
What you will achieve
- Explain what a benchmark is and why its score can mislead: saturation and contamination.
- Build an evaluation set from your own cases and choose how to grade it: with a program, a rubric, an LLM as judge, or people.
- Interpret the margin of a score (its confidence interval) and predict how it changes with the number of cases when comparing two systems.
Key ideas
- A benchmark is a fixed public exam. It is useful for comparing models in general, but it saturates and can be contaminated: its score does not tell you whether the system works for your case.
- Your evaluation set is real cases from your work, with the answer your experts accept, that the system has not seen. Include the frequent, the exceptional, the risky, and what must be refused, and report by group: the average hides where it fails.
- A program grades closed answers; open ones need a rubric applied by people or by an LLM as judge. The judge scales, but it has biases (for example, the order of the answers): grade in both orders and check it against people.
- Every score carries a margin, its confidence interval: with a hundred cases, about eight points; four times as many cases give half. If two systems differ by less than the margin, it is a tie. Compare them on the same cases.
- Evaluating is a routine: a regression test after every change, red teaming to look for the worst case, and business metrics measured in a pilot.
What many people believe
Common belief “This model tops the public benchmarks, so it will be the best one for my organization.”
What is true A benchmark measures one specific exam, and its score can be inflated by contamination or no longer tell anyone apart because of saturation. Only an evaluation on your cases, which the system has not seen and which comes with its margin of error, tells you whether it works for your case.
Check yourself
Four questions. No grade, no account: they just show whether the idea stuck.
Under the hoodFor those who want the math and the code. You do not need it to follow the course.
The margin of a score
With right answers in cases, the measured accuracy is . Its approximate 95% confidence interval is
With 78 of 100: , that is, from 70% to 86% (what the scene uses). With 400 cases, . The margin goes with : quadrupling the cases halves it, and in the worst case () it is almost exactly : 10 points with 100 cases, 5 with 400, 2.5 with 1,600.
The correct reading: if you repeated the evaluation many times with fresh cases, about 95% of the intervals built this way would contain the true accuracy. With few cases, or scores near 0% or 100%, this formula falls short; Brown, Cai, and DasGupta (2001) recommend the Wilson interval, which for 78 of 100 gives 68.9% to 85.0%. Bowyer, Aitchison, and Ivanova (2025) show that with fewer than a few hundred cases, margins based on the normal approximation tend to come out too small.
Comparing two systems on the same cases
For each case , let (A's hit minus B's hit). If only A is right on cases and only B on , the measured difference is and its standard error is
In the lesson's simulation, on each case both are right with probability 0.66, only A 0.12, only B 0.08, and neither 0.14. The variance of is ; if each system were tested on different cases, their variances would add up, : almost double. That is why, with the same cases, you need almost half as many.
The exact probability that A comes out ahead (from the multinomial distribution) is 78.5% with 100 cases, 88.4% with 200, 95.9% with 400, and 99.75% with 1,000; the scene's 100 comparisons give 78, 88, 96, and 100. With different cases, 400 cases give about 90%, and it takes about 650 to reach 95%; with the same cases, about 360 are enough. A winning is not the same as proving the difference: for the interval of to exclude zero 80% of the time takes cases.
Miller (2024) sums up the craft: report standard errors, compare in pairs (case by case), cluster cases that are not independent (for example, several questions about the same document), and plan the sample size before evaluating.
Contamination: the example's arithmetic
If a model always gets right what it saw, solves a fraction of the rest, and saw a fraction of the exam, its score is
With : gives , the same as B, and gives . It is a simplified model: real memory is partial. Contamination is searched for with text matches between the exam and the corpus (the GPT-4 report used three 50-character substrings per question; that is how it found that part of BIG-bench had slipped into training by accident, and it estimated that a quarter of HumanEval was in its data), with equivalent fresh problems, or by measuring how much probability the model assigns to the exam's questions. GSM1k (Zhang et al., 2024) is 1,205 problems written by people in the style of GSM8k: some model families dropped by up to 8 points, with bigger drops the more likely the model was to generate GSM8k examples; frontier models barely dropped.
The automatic judge
Zheng et al. (2023) compared GPT-4 as a judge with human experts on MT-bench: not counting ties, they agreed 85% of the time, more than the experts with each other (81%). They also measured its biases. Order: with two nearly identical answers, the verdict held when the order was swapped 65.0% of the time with GPT-4, 46.2% with GPT-3.5, and 23.8% with Claude-v1. Length: when 23 answers were padded with a repeated list that added no information, Claude-v1 and GPT-3.5 preferred the padded version in 21 of 23 (91.3%), and GPT-4 in 2 (8.7%). Their defense against order bias: grade twice, swapping the order, and declare an answer the winner only if it wins both times.
To measure agreement with people without being fooled by chance, Cohen's is used: , where is the observed agreement and the agreement expected by chance. Human evaluation is also done at scale: Chatbot Arena gathered over 240,000 votes from people comparing answers blind (Chiang et al., 2024), but on questions that are not yours.
Scores expire, and exams have flaws too
Chen, Zaharia, and Zou (2023) measured the same service in March and in June 2023 with 500 prime and 500 composite numbers: GPT-4 went from 84.0% to 51.1%, because the June version almost always answered “composite” (99.7%) and stopped following the step-by-step reasoning it was asked for. It is a change in behavior more than in ability, but for anyone who depends on the service the effect is the same, and you only notice by measuring again.
Exams contain errors: Gema et al. (2024) estimate that 6.49% of MMLU questions have one (57% of those reviewed in virology). And they run out: Phan et al. (2025) built a new 2,500-question exam because the best models already scored above 90% on MMLU.
In code
import numpy as np
def margin(k, n, z=1.96):
"""Half the 95% confidence interval for k right answers out of n cases."""
p = k / n
return z * np.sqrt(p * (1 - p) / n)
for n in (100, 400, 1600):
print(n, round(100 * margin(0.78 * n, n), 1))
# 100 8.1
# 400 4.1
# 1600 2.0
# Two systems on the same cases: both right 0.66; only A, 0.12; only B, 0.08; neither, 0.14
rng = np.random.default_rng(0)
def a_ahead(n, reps=20000):
c = rng.multinomial(n, [0.66, 0.12, 0.08, 0.14], size=reps) # both, only A, only B, neither
return round(float(np.mean(c[:, 1] > c[:, 2])), 2)
for n in (100, 200, 400, 1000):
print(n, a_ahead(n))
# 100 0.78
# 200 0.88
# 400 0.96
# 1000 1.0
What comes next
Measured quality is one axis; risk is another: privacy, manipulation through instructions, bias, and regulation. Lesson 35 walks through them, and lesson 36 uses this evaluation inside a pilot that scales.
Decision lens
What this idea means if your job is to decide, not to code.
- Before buying, ask for the full evidence behind each figure: which exam, with what instructions, which model version, on what date, and how contamination was ruled out. Without that, two figures cannot be compared.
- Evaluate with your data: a few hundred real, anonymized cases, with the answer your experts accept, that the vendor has not seen. Include the frequent, the exceptional, the risky, and what must be refused, and ask for results by group.
- Demand the margin of every score. If two systems differ by less than the margin, treat them as a tie and decide on cost, speed, and risk. If an LLM judge does the grading, ask how often it agrees with people and whether it graded in both orders.
- Make evaluation a routine: rerun it after every change of model, instructions, or data; have a team attack the system before launch; and decide in advance which business result justifies going on, measured in a pilot.
Terms in this lesson
- Benchmark A fixed public exam (questions with their correct answers and a way to grade them) given in the same way to every model to compare them. Useful as a general reference; it does not tell you whether a system works for your case.
- Contamination When an exam’s questions (or answers) were in the data the model was trained on. It inflates the score, because it partly measures memory rather than ability.
- Eval set (gold cases) Your own set of real cases from your work, each with the answer or criterion your experts accept, that the system has not seen. It is used to compare systems and is rerun after every change.
- LLM-as-a-judge Using a language model to grade another system’s answers against a rubric. It is cheap and scales, but it has biases (the order of the answers, their length) and must be checked against people’s grades.
- Confidence interval A range of reasonable values for a quantity measured on a sample, such as a system’s true accuracy; usually at 95%. Its margin shrinks with the square root of the number of cases: four times as many cases cut it in half.
- Red teaming Deliberately attacking a system, with people or with other models, to find its worst-case failures: harmful answers, leaks, deception. Each failure found becomes an evaluation case.
- Hallucination A fluent, confident answer from a model that is false or backed by no source. It follows from predicting plausible text, not from checking facts.
- Language model A model that, given some text (the context), gives a probability to every word or piece that can come next. It writes by adding one piece at a time.
- Pretraining The first stage of training a language model: over a huge corpus, the model guesses the next piece of text again and again and adjusts its parameters to lower the error. The result is a base model.
- Training data Examples, each with its correct answer, from which a model adjusts its parameters.
- Data leakage Information from the evaluation data that slips into training, inflating the measured result.
- Test set Held-out data used once at the end to report the expected performance on new cases.
Full transcript
Sources
- Hendrycks, D., Burns, C., Basart, S., Zou, A., Mazeika, M., Song, D., Steinhardt, J. (2020). Measuring Massive Multitask Language Understanding (ICLR 2021): 57 temas, 15 908 preguntas, figura 1 (pregunta de ejemplo), GPT-3 43.9 %, experto ≈ 89.8 %
- OpenAI (2023). GPT-4 Technical Report: tabla 2 (MMLU 86.4 %), nota 5 (BIG-bench) y apéndice C (contaminación)
- Phan, L., Gatti, A., Han, Z., et al. (2025). Humanity’s Last Exam (más del 90 % en MMLU; examen nuevo de 2 500 preguntas)
- Zhang, H., Da, J., Lee, D., et al. (2024). A Careful Examination of Large Language Model Performance on Grade School Arithmetic (GSM1k, NeurIPS 2024)
- Strathern, M. (1997). «Improving ratings»: audit in the British University system (European Review 5(3), 305–321): la formulación «cuando una medida se vuelve meta…»
- Zheng, L., Chiang, W.-L., Sheng, Y., et al. (2023). Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (NeurIPS 2023): tablas 2, 3 y 5
- Chiang, W.-L., Zheng, L., Sheng, Y., et al. (2024). Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preference
- Brown, L. D., Cai, T. T., DasGupta, A. (2001). Interval Estimation for a Binomial Proportion (Statistical Science 16(2))
- Miller, E. (2024). Adding Error Bars to Evals: A Statistical Approach to Language Model Evaluations
- Bowyer, S., Aitchison, L., Ivanova, D. R. (2025). Position: Don’t Use the CLT in LLM Evals With Fewer Than a Few Hundred Datapoints
- Chen, L., Zaharia, M., Zou, J. (2023). How Is ChatGPT’s Behavior Changing over Time? (v3: 500 primos y 500 compuestos; GPT-4, 84.0 % en marzo y 51.1 % en junio de 2023)
- Ganguli, D., Lovitt, L., Kernion, J., et al. (Anthropic) (2022). Red Teaming Language Models to Reduce Harms: Methods, Scaling Behaviors, and Lessons Learned (38 961 ataques publicados)
- Gema, A. P., Leang, J. O. J., Hong, G., et al. (2024). Are We Done with MMLU? (6.49 % de preguntas con errores)
CommentsThis lesson’s public conversation: questions, facts to check, ideas.
Comments live in GitHub Discussions, in the course’s public repository; writing one requires a GitHub account. They load from giscus.app when you open this section. The course reviewers read them, and if a change is accepted, it is applied in both languages. Open the thread on GitHub