Evaluation Methodology
How to tell whether an open-ended answer is any good, and where each method fails.
Warm-up · re-test from Lesson 2
These cover the four ideas that didn't stick the first time, asked in new ways. Answer from memory.
Match each kind of training data to the stage that uses it.
1 · Why evaluation is the bottleneck
Huyen says the biggest hurdle to shipping AI is often evaluation, which can take up “the majority of the development effort.” Yet many teams just eyeball results with a few favorite prompts. Ch3 intro Foundation models are harder to evaluate than classic ML for several reasons: Ch3 · Challenges
- Smarter is harder to grade. Anyone can spot a first grader's math error. Checking a coherent book summary may mean reading the book.
- Open-ended outputs have no single ground truth to compare against.
- Black boxes. You often can't see the training data or architecture, only the outputs.
- Benchmarks saturate fast. GLUE (2018) was saturated within a year.
2 · Perplexity: grading the language model itself
Perplexity measures how uncertain a model is when predicting the next token of a text. Lower means more confident. It's the exponential of cross entropy. Structured text such as HTML gets lower perplexity than everyday prose, and a perplexity of 3 roughly means a 1-in-3 guess. Ch3 · Perplexity You won't use it to grade an app, but it shows up in three places:
- A proxy for capability: bigger GPT-2 models had consistently lower perplexity.
- Detecting data contamination: suspiciously low perplexity on a benchmark suggests the model trained on it.
- Spotting abnormal text: gibberish (“home cat go eye”) has very high perplexity.
CaveatPerplexity usually rises after post-training (SFT, RLHF), because a model that has learned to do tasks is no longer just predicting raw text. So it's a poor proxy for chat models. Ch3 · Perplexity Interpretation
3 · Exact evaluation
Exact evaluation gives a judgment with no ambiguity. Huyen covers two kinds. Ch3 · Exact Evaluation
Functional correctness: does it actually work?
This is “the ultimate metric”: did the website get built, did the reservation go through? It's easy to automate for code, which you can run against unit tests, as HumanEval and text-to-SQL benchmarks do. pass@k counts a problem as solved if any of k samples passes all its tests: solve 5 of 10 problems with k = 3 and pass@3 = 50%.
Similarity against reference data
| Method | How | Trap |
|---|---|---|
| Exact match | The output equals a reference answer. Fine for short answers like “What's 2 + 3?” | The lenient “contains the answer” variant passes “September 12, 1929” for Anne Frank's birth year, even though the date is wrong. |
| Lexical similarity | Token or n-gram overlap, or edit distance (fuzzy matching). BLEU and ROUGE are examples. | Correct answers missing from the reference set score low. OpenAI found BLEU barely differed between correct and incorrect code. |
| Semantic similarity | Turn both texts into embeddings and compare them with cosine similarity (1 = same, −1 = opposite). | Only as good as the embedding model, and it costs compute. |
Lexical vs semantic in one example: “What's up?” and “How are you?” share almost no words but mean nearly the same thing. “Let's eat, grandma” and “Let's eat grandma” look almost identical and mean very different things. Ch3 · Semantic similarity
Embeddings, brieflyAn embedding is a vector (typically 100 to 10,000 numbers) meant to capture the meaning of a piece of data, so similar texts get nearby vectors. OpenAI's text-embedding-3-small produces 1,536 numbers. CLIP puts text and images in one shared space. Embeddings come back in Chapter 6 (vector search for RAG) and Chapter 8 (deduplication). Ch3 · Introduction to Embedding
4 · AI as a judge
This means using a model to evaluate a model's outputs. It's fast and cheap, and it works without reference data, so it works in production. On MT-Bench, GPT-4 agreed with humans 85% of the time, more than humans agreed with each other (81%). Ch3 · Why AI as a Judge? It can do three jobs: score a response on its own, compare it with a reference, or pick the better of two responses.
A judge is a model plus a prompt plus sampling settings. Change any one and you have a different judge. A good judge prompt spells out the task, the criteria, and the scoring system. Classification labels such as good/bad work better than numbers, and a discrete 1–5 scale works better than a continuous one. Include an example for each score. Ch3 · How to Use AI as a Judge
| Limitation | What it looks like |
|---|---|
| Inconsistency | It's probabilistic, so the same input can get different scores. Examples in the prompt raised GPT-4's consistency from 65% to 77.5%. |
| Criteria ambiguity | “Faithfulness” is scored 1–5 in MLflow, 0/1 in Ragas, and YES/NO in LlamaIndex. The scores aren't comparable, and a quiet prompt change can shift your metrics. |
| Cost and latency | Judging 3 criteria on every response means 4× the API calls. Spot-checking a sample reduces this. |
| Biases | Self-bias (favors its own outputs), first-position bias (humans have the opposite, recency bias), verbosity bias (prefers longer answers even when they contain errors). |
Do not trust any AI judge if you can't see the model and the prompt used for the judge.Huyen, Ch. 3, “Criteria ambiguity”
Connecting to Lesson 2: the RLHF reward model is a specialized judge. It takes a (prompt, response) pair and outputs a score. Huyen also describes reference-based judges and preference models, which take two responses and predict which one users would prefer. Ch3 · What Models Can Act as Judges?
5 · Comparative evaluation: ranking by head-to-head matches
Pointwise evaluation scores each model on its own. Comparative evaluation shows two models' outputs side by side, records which one wins, and turns the wins into a ranking with a rating algorithm such as Elo or Bradley–Terry. LMSYS Chatbot Arena switched from Elo to Bradley–Terry because Elo was sensitive to the order of evaluations. It works because picking the better song is easier than scoring one. Ch3 · Ranking Models with Comparative Evaluation
- Don't use it for correctness questions. Letting people vote “Yes” or “No” on whether phone radiation causes tumors produces bad signals.
- It isn't A/B testing. In A/B testing a user sees one model's output at a time; here they see several at once.
- Pairs grow quadratically: 57 models make 1,596 pairs.
- Comparative isn't absolute. “B beats A 51% of the time” doesn't tell you whether either model is good enough, or whether B is worth twice the cost.
Practice · pick the method
For each feature, choose the best primary evaluation method. Commit to an answer before you check.
Check yourself
Read next: Huyen, AI Engineering, Chapter 3. Read all of “Exact Evaluation,” “AI as a Judge,” and “Ranking Models with Comparative Evaluation.” In “Understanding Language Modeling Metrics,” Huyen says you can skip the math and focus on how to interpret the metrics. Do that: read “Perplexity Interpretation and Use Cases” and skim the rest.
From a practitioner, about 20 min: Hamel Husain, “Your AI Product Needs Evals” (2024). It covers layering cheap assertions, human review and LLM judges, and always looking at your data. It's a good bridge to Chapter 4.