AI Evals: Test and Improve Your LLM App
IntermediateRead real outputs, build a test set, write graders and block a version that got worse.
You build
An evaluation suite for a small support assistant: a test set with expected behaviour, graders in code, a model grader checked against labels, a comparison of two prompt versions, and a gate that fails when a score drops.
You need
- Python basics: functions, lists, dictionaries, reading and writing files, and running a script in a terminal
- Calling a language model from Python and getting structured output: a system prompt, messages, and a reply parsed into fields your code can read (the course Build Your First LLM App in Python is one way to get this)
- Having seen an ordinary automated test: a function that runs some code and asserts on the result
To build it on your own machine
This is optional and comes with a plan. The course pack brings the starting files, a ready container and a check for every lesson. You need only Docker and git, plus your own AI coding agent if you want a tutor.
What you learn
Know whether a prompt change made your app better or worse, before it ships
A small support assistant for a made-up bike shop is handed to you finished. You build what tells you whether its answers are good: you read real answers and name what goes wrong, turn that into a test set, write graders in code, add a model as a grader and check it against human labels, compare two prompt versions, and end with a gate that blocks a change that makes the answers worse. Plain Python, no eval library. Every check runs on recorded answers, so you need no key.
- Look First. Why an exact assert cannot test a model's answer, what an eval is instead, and why reading real outputs and naming the failures you find comes before any metric.
- A Test Set and Graders. Cases that state the expected behaviour rather than one expected text, graders in code that each check one thing, and pass rates per grader instead of one comforting number.
- A Model as a Grader. What only a model can judge, a judge prompt with one criterion and a pass or fail verdict, and how to measure the judge against human labels before trusting its score.
- Decisions and Gates. Comparing two versions case by case, telling a real change from the variation between two runs of the same app, and a gate that fails when a score drops below the baseline of the accepted version.
Lessons
Read the Answers Before You Measure
Why LLM output is hard to test, What an eval is, Recorded outputs, Looking before measuring
Name the Failure Modes and Count Them
Grouping notes, Failure modes, Counting failures, Choosing what to measure
Build a Test Set
Test cases, Expected behaviour, not text, Where cases come from, Coverage by failure mode
Write Graders in Code
Code graders, One grader, one criterion, Common code checks, Pass rates
Use a Model as a Grader
Model graders, One criterion, pass or fail, The judge prompt, Reason before verdict
Check the Judge Against Human Labels
Human labels, Agreement and its trap, True positive and negative rates, Improving the judge
Compare Two Versions
A fair comparison, Case-by-case differences, Run-to-run variation, Small sets, wide margins
Block Regressions with a Gate
Baselines, A gate and its exit code, Tolerance and must-pass checks, What a gate runs
Where it fits
Course 7 of 8 on the AI Engineer path.