Lesson 6.1: Why AI apps need evals
Learn why AI features need repeatable evaluations, the kinds of checks you can run, how noise hides real change, and how to start with thirty test cases.
A team improves the prompt of its support assistant. The new version sounds friendlier, the examples they tried look better and the demo goes well, so they ship it. A week later the refunds team reports that the assistant has started giving wrong answers on refund questions. Nothing in the process would have caught this, because nobody tested refund questions after the change. This is the normal way AI features fail: not in a dramatic crash, but through quiet changes in quality that nobody measures. Conventional software has a remedy, which is automated tests that pass or fail the same way every time. An AI feature needs something similar, but its outputs vary, there are many acceptable answers and quality is a matter of degree. The tool for this job is the eval, a repeatable way to measure how well an AI system does its task. This lesson opens the module on evaluation. It explains why evals matter, what one is made of, the kinds of checks you can use, how to read the numbers without being fooled by chance, and how to start small. By the end you will be able to explain why ordinary tests are not enough for language-model features, describe the parts of an eval, choose between exact checks, rubric grading and human review, compute how uncertain a pass rate is on a small test set, judge whether a new version is really better than an old one, see how an average can hide a regression in one slice, and start an eval with thirty cases this week. You should have read the earlier lessons in this track. No programming is needed, and the arithmetic is percentages and a square root.
Why ordinary tests are not enough
A traditional unit test calls a function with fixed input and checks for an exact output. If it returns 4 when it should, the test passes, and it will do so every time. A language-model feature breaks all three assumptions.
The output varies. The same question can produce different wording on different runs, especially with some randomness in the sampling, as Lesson 2.3 explained. An exact-match test would fail on a perfectly good answer.
Many answers are acceptable. "Refunds take 7 business days" and "You should see the money within a week" can both be right. There is no single string to compare with.
Quality is graded. Answers are not simply right or wrong. They may be correct but rude, polite but vague, complete but too long. You care about several dimensions at once.
The system changes underneath you. A provider updates a model, a document in the index changes or a prompt is edited, and behaviour shifts without any change in your own code.
A fix in one place breaks another. A prompt tuned for one kind of question can worsen another, as the opening story showed.
Because of this, many teams rely on vibes: they try a few examples, read the results and decide that the system "feels better". Vibes have a place early on, but they do not scale. They depend on which examples you happened to try, on your mood and on what you remember from last time. They cannot tell you whether a change improved the system overall, only whether it improved the cases you looked at. Evals replace this with a measurement.
What an eval is made of
An eval has five parts.
1. Test cases. A set of realistic inputs, each with whatever you need to judge the answer: perhaps an expected answer, the passages that should be used or a description of what a good response contains.
2. A way to run. A script or tool that sends each case to your system and records the output, along with the settings used, so that it can be repeated.
3. A grader. The method that decides how good each output is: a rule, a comparison with a reference, a model with a rubric or a person.
4. A score. A number or set of numbers: the share that passed, an average rating, a breakdown by category.
5. A record. The results stored with the version of the prompt, model and data, so that you can compare this run with earlier ones.
You will build each of these in the next lessons: Lesson 6.2 covers building a test set, Lesson 6.3 grading, and Lesson 6.4 monitoring after launch. This lesson explains the case for them and gives you a first working version.
Kinds of checks
Not every check needs a model or a person. Use the cheapest check that really captures the requirement, and keep the costly ones for what the cheap ones cannot see.
Kind of check · Example · Cost · Good forFormat and rules · The reply is valid JSON with all required fields. The answer is under 120 words. It contains a citation. It does not include a banned phrase. · Almost free · Structure, length, safety rules
Exact or numeric match · The extracted invoice total equals the true total. The category is one of five labels and matches. · Almost free · Extraction, classification
Reference comparison · The answer contains the key facts from a reference answer. · Low · Questions with a known answer
Source check · Every quoted sentence appears in the retrieved text, and every number appears in a cited passage. · Low · Grounding in RAG, as in Lesson 5.3
Model as judge · A second model scores the answer against a written rubric: correct, complete, polite, on topic. · Moderate · Quality that is hard to code
Human review · A person reads a sample and rates it. · High · Judging the judge, subtle quality, high stakes
Online signals · Thumbs up or down, edits made to a draft, follow-up questions, escalations to a person · Free once built · Real-world usefulness, drift
A good eval often combines several. For a summarising feature you might check the format by rule, check that every figure in the summary appears in the source, ask a model to grade completeness and tone against a rubric, and have a person review twenty summaries a week. Lesson 6.3 returns to graders, including the pitfalls of using a model as a judge.
What to measure
The score you track should reflect what users and the business care about, which is rarely a single number.
Task success: did the system do what was asked?
Faithfulness: did it stay within its sources?
Safety and policy: did it refuse what it should and avoid what it should not say?
Tone and style: does it sound like your brand?
Cost and delay: per request, and at the tail, such as the slowest 5% of requests.
Coverage: how often does it answer, and how often does it decline?
Pick a small number, say three to five, and write down for each what counts as a pass. A vague goal such as "high quality" cannot be measured. "Answers the question using the policy, cites the section and does not promise anything the policy does not" can.
Averages hide regressions
The most useful habit in evaluation is to look at the results by slice, not only in total. Take the opening story with numbers. The support assistant is tested on 100 questions, 25 in each of four categories. Version 3 and version 4 of the prompt score as follows (per cent passed):
Category · Version 3 · Version 4Refunds · 80 · 56
Shipping · 76 · 80
Account · 72 · 76
Payments · 76 · 84
Overall · 76 · 74
The overall score fell by only two points, which might be dismissed as noise. But look at the slices. Three categories improved, and refunds collapsed by 24 points. The new prompt's friendlier phrasing made the assistant sound more willing to grant refunds than the policy allows. If the team had looked only at the overall figure, or at a few hand-picked examples, they might not have noticed, and the refunds team would have found out the hard way. Slicing by topic, by language, by user type and by difficulty turns a vague dip into a specific problem.
Predict first: a team's test set has 50 cases and the assistant passes 40 of them, so 80%. They make a change, run again and get 84%, which is 42 out of 50. Is the new version better? How much would you trust a gap of four points on 50 cases? Think about it before you read on.
Noise: how much can you trust a pass rate?
A pass rate measured on a sample is an estimate. If you drew a different 50 questions, you would get a somewhat different number. The uncertainty can be estimated. For a pass rate p measured on n cases, the margin of error at the usual 95% level is about 1.96 × the square root of p × (1 − p) ÷ n.
For p = 0.8 and n = 50, p × (1 − p) = 0.16, divided by 50 is 0.0032, whose square root is 0.0566. Multiply by 1.96 to get 0.111, which is 11 points. So an 80% pass rate on 50 cases means the true rate is plausibly anywhere from about 69% to 91%. A move from 80% to 84% is far inside that band. With more cases the band narrows, but slowly: you need four times as many cases to halve the margin.
There is a further source of noise. If the system uses any randomness, the same case can pass on one run and fail on the next. Running each case several times and averaging, or setting the randomness low, helps. Always find out how much your score moves when you run the same version twice with nothing changed. That figure is the smallest difference you can hope to detect.
Is the new version really better?
When you compare two versions on the same test set, the question is about the difference between their pass rates. Let version A pass 78 of 100 cases and version B pass 84 of 100. The difference is six points. The uncertainty in the difference comes from both: the standard error is the square root of (0.78 × 0.22 ÷ 100 + 0.84 × 0.16 ÷ 100), which is the square root of 0.00306, about 0.055, or 5.5 points. The 95% range for the difference is six points plus or minus 1.96 × 5.5, about 10.8, so from minus 4.8 to plus 16.8. Zero lies inside the range, so the data are consistent with no real improvement, or even a small harm. The result is not evidence of a better version.
A sharper way when both versions run on the same cases is to look at the cases where they differ. Suppose B fixes 14 cases that A got wrong, and breaks 8 cases that A got right. The net gain is six, but only 22 cases changed, and if the two versions were equally good, you would expect the 22 changes to split about 11 and 11. A split as lopsided as 14 to 8 happens by chance about 14% of the time. That is suggestive, not conclusive. More cases would settle it.
The practical rule is to be humble about small differences. Use bigger test sets for decisions that matter, run versions on the same cases, look at the cases that changed and read some of them yourself. A number tells you where to look, and your reading tells you what happened.
The eval loop
With an eval in place, development changes shape.
1. Set a baseline. Run the current system and record the scores by slice.
2. Make one change. A new prompt, a different chunk size, a new model.
3. Run the eval again. Same cases, same settings.
4. Compare. Look at the overall score, the slices, the cases that changed and the cost and delay.
5. Decide. Keep the change, revert it or refine it. Write down why.
6. Add the lesson. If you found a new kind of failure, add cases that would catch it next time.
Teams that work this way move faster, not slower. They can try a bold change and know within minutes whether it helped. They can swap a model for a cheaper one and see what is lost. They can upgrade without fear. It resembles test-driven development: write the check first, then change the system until it passes.
Starting small
You do not need a large platform to begin. Here is a first eval you can build in a week.
1. Collect 30 real inputs. Take real user questions from logs, support tickets or colleagues. If the product is new, write them with people who will use it. Include easy cases, hard cases and a few that should be declined.
2. Write what good looks like. For each case, note the expected answer, or a short list of things the answer must contain and must avoid.
3. Pick two or three checks. One cheap rule, such as format or length, and one rubric, such as correct and complete.
4. Run the system and grade by hand, in a spreadsheet, with columns for the case, the output, the pass or fail and a note. It takes an hour.
5. Record the baseline. Pass rate overall and by category.
6. Run it before every change, and add cases whenever a user finds a failure.
Thirty cases give a wide margin of error, about 14 points on an 80% pass rate, so use them to catch large problems and obvious regressions, not to rank close alternatives. Grow the set as the product matures. The act of looking at thirty real cases and deciding what is good will teach you more about your product than a month of demos.
Common traps
Testing on the cases you tuned on. If you edit the prompt until the test cases pass, the score is optimistic. Keep a separate set that you do not look at while tuning.
Leaking the answers. Putting test examples into the prompt as few-shot examples makes the test meaningless.
Unrepresentative cases. A set made of clean, tidy questions will overstate quality. Include typos, mixed languages, vague questions and angry ones.
Trusting a model judge blindly. A grader model has its own biases, such as favouring longer answers. Check it against human ratings, as Lesson 6.3 shows.
Measuring what is easy and not what matters. Length and format are easy. Helpfulness is not. Do not let the easy numbers stand in for the important ones.
A set that never changes. Real use drifts. Refresh the cases with new failures.
No owner. If nobody is responsible for running and reading the eval, it will rot.
Chasing noise. Reacting to a two-point move on 50 cases wastes effort.
Three worked examples
Example 1: the sliced score. The support team above finds the refund drop and adds 25 refund cases covering partial refunds, expired windows and exceptions for digital goods. They add a line to the prompt: "Never state that a refund will be given unless the policy text says so." Version 5 passes 92% of refund cases and 83% overall. The slice table caught what the average hid, and the new cases are now part of the permanent set.
Example 2: a summariser. A legal team uses a model to summarise contracts. The eval has three checks. A rule checks that the summary is under 200 words and lists the parties, dates and amounts. A source check confirms that every number in the summary appears in the contract. A model judge scores completeness and tone from 1 to 5 against a rubric, and a lawyer rates 20 summaries a week to check the judge. Over a month the number check catches six summaries with an altered amount, and the lawyer's ratings show the judge is too generous on completeness, so the team tightens the rubric.
Example 3: switching to a cheaper model. A team considers a smaller model that costs 60% less. On 200 test cases the current model passes 88% and the cheaper one 85%. The difference is minus three points, but the standard error is about 3.4 points, so the range runs from about minus 9.7 to plus 3.7, which includes zero. The test cannot say whether the cheaper model is worse. The team does two things: it examines the 17 cases that the cheaper model gets wrong and the current model gets right, and finds most are long, multi-part questions; and it decides to route those to the larger model while sending simple questions to the small one. The result keeps most of the saving without a large loss in quality.
An eval starter worksheet
1. The task. What does the feature do, and for whom?
2. What good means. Three to five measurable criteria.
3. The cases. Thirty real inputs, with categories and an expected result for each.
4. The checks. Which rules, references and rubrics will you use?
5. The baseline. Overall and by slice.
6. The noise. How much does the score move when you run the same version twice?
7. The decision rule. How big a difference counts, and on how many cases?
8. The held-out set. Which cases will you keep unseen while tuning?
9. The owner and the rhythm. Who runs it, and when?
10. The growth plan. How new failures become new cases.
Common mistakes
Relying on a handful of examples and calling it testing.
Looking only at the average.
Treating small differences as real.
Tuning on the test set.
Skipping the cases that matter most, such as rare but costly ones.
Waiting for a perfect eval before starting.
Building a large eval and never reading the outputs.
Changing several things between runs, so that the cause is unknown.
Key takeaways
AI features vary in output, accept many answers, are graded in degrees and change when models or data change, so ordinary tests are not enough. Vibes do not scale.
An eval has test cases, a way to run them, a grader, a score and a record. Use the cheapest check that captures the requirement, from rules and exact matches to rubrics, model judges and human review.
Look at results by slice. In the example, an overall dip of two points hid a 24-point fall on refunds.
A pass rate is an estimate. An 80% rate on 50 cases has a margin of about 11 points, and on 1,000 cases about 2.5. Halving the margin takes four times the cases.
A six-point gain on 100 cases each, 78% against 84%, has a range from about minus 5 to plus 17 and does not show a real improvement.
Work in a loop: baseline, one change, rerun, compare, decide, add cases for new failures.
Start with thirty real cases graded by hand this week, and grow from there.
Check yourself
1. Why is an exact-match test a poor way to check a language-model answer?
The same question can be answered in many correct ways, and the wording varies from run to run, so a correct answer may not match.
2. A pass rate of 90% is measured on 100 cases. About what is the margin of error?
1.96 × the square root of 0.9 × 0.1 ÷ 100 = 1.96 × 0.03 = 0.059, about 6 points.
3. Why report results by category as well as overall?
An overall average can hide a large drop in one category when others improve.
4. Two versions score 70% and 75% on 40 cases each. Does that show the second is better?
No. The standard error of the difference is about 10 points, so the range for the difference runs from about minus 15 to plus 25, which includes zero.
5. Name two ways to avoid fooling yourself while tuning a prompt.
For example: keep a held-out set you do not look at, do not put test cases in the prompt, and change one thing at a time.
6. What would you put in your first 30 test cases?
Real user inputs from logs or colleagues, with easy, hard and should-decline cases, each with a note of what a good answer contains.
Try this
Build and run a first eval. Set aside 90 minutes.
1. Choose an AI task you use or are building, such as answering questions from a document, summarising notes or classifying messages.
2. Collect 30 real inputs and sort them into three or four categories.
3. For each, write what a good answer contains and what it must not contain.
4. Run them through your system or an assistant tool and mark each output as pass or fail in a spreadsheet, with a one-line note on every failure.
5. Work out the pass rate overall and by category, and use the first simulator to find the margin of error.
6. Change the prompt in one way, run the same cases again and use the second simulator to say whether the change was a real improvement.
7. Write the three failures that taught you the most, and add two new cases for each.
A good result is a spreadsheet of 30 graded cases, a baseline by category, a margin of error, a comparison of two versions with an honest reading and a list of new cases drawn from the failures.
Tags: AI Engineering Evaluation Evals Testing LLM applications