AI Engineering · Module 08
Evaluating AI applications
- Lessons
- 15
- Free
- 0
- Reading
- ~5 h
Your progress
0 / 15 lessons done
Sign in to trackLessons
- Evals: testing systems that never answer the same wayEvery change to a prompt, a model or a retrieval setting changes thousands of replies at once, and a few tries by hand can’t show which ones got worse. An eval is how you find out before your users do.
- Building an eval set from real examplesEvery eval score is only as good as the examples behind it. Engineers who build the set carefully can tell a better prompt from a lucky one; engineers who don’t ship changes on noise and learn about them from customers.
- Code-based checks: exact match, rules and schemasEvery eval starts with the checks that cost nothing to run. They catch broken output on every change, in seconds, and leave the paid judge only the questions that need judgement.
- Testing code that calls a model: fakes and recordingsMost bugs in a model feature live in the code around the call: ids, retries, limits and error handling. Tests that fake the model catch them on every push, in seconds and for free, and leave the evals to judge what the model writes.
- LLM-as-judge: grading outputs with a modelMost of what makes an AI feature good, such as following a policy or answering the real question, can’t be checked by code, and people can’t read every output after every change. A judge you can trust lets you change a prompt and know within the hour whether it got worse.
- Judge calibration: checking LLM judges against peopleOnce a model grades your AI feature, every release decision rests on that grader. If nobody has checked it against people, a judge that passes bad outputs makes a worse release look like a better one.
- Human review and labelingEvery eval and every LLM judge is only as good as the human labels it is checked against. When you ship an AI feature, someone has to decide what “good” means and grade real outputs against it, every week, without wasting the time of the people who know the work best.
- Evaluating RAG: retrieval and answer qualityEvery RAG feature keeps changing: new chunking, a new embedding model, a new prompt. When quality drops, two stage scores tell you in minutes which half to fix; one pass rate leaves you reading drafts for a day.
- Evaluating agents: task success and trajectoriesAn AI agent that passes a demo ticket can still fail the same ticket on another run. Before it touches thousands of real tickets, you need tests that check what it left behind, how it got there and how often it gets the same right answer.
- Simulated users: testing agents before launchAs soon as an AI agent asks a person something and waits, the next input depends on its own last message, so a fixed test can’t follow it. A model that plays the person is how teams test those conversations before real customers meet them, and knowing where that model lies to you is what makes its results worth trusting.
- Regression testing for prompts and modelsA prompt edit or a new model id passes every unit test while it changes what thousands of replies say. A regression run on a fixed eval set, compared ticket by ticket, is how you find out before your users do.
- Online evaluation: A/B tests and user feedbackEvery AI feature ships with an offline eval that passed. Whether people actually find it more useful only shows up in live traffic, and a badly run test there either ships a worse version or hides a better one.
- Error analysis: finding what to fix firstEvery eval run ends with a pile of failures and a temptation to change the prompt. Engineers who read and sort the failures first fix the cause that matters most, and often find that some failures belong to the eval itself.
- Case: how Shopify evaluates its merchant agentEvery team that ships an AI agent has to decide when a change is good enough for real users. Shopify published how it makes that call for Sidekick, so you can see a full eval pipeline at large scale and take the parts that fit your own size.
- Lab: an eval harness for a support assistantEvery prompt or model change to an AI feature raises the same question: what did it fix, and what did it break? A small harness that saves outputs and splits cheap checks from model grading answers it in minutes, for about a dollar.
Practise with
Terms this module teaches 83
Open glossaryA/B test
An experiment that sends a random share of live traffic to each of two versions and compares an outcome between them.
Anchoring
The pull a number or answer you have just seen has on your own judgement, even when you are told it may be wrong.
Axial coding
Grouping open-coding notes that share a cause into a short list of named categories, then counting each.
Baseline
The scores of the current version on an eval set, saved so that every change can be compared with them.
Cassette (recorded HTTP)
A file in which a record-and-replay tool such as vcrpy stores each HTTP request and the response that came back, so later test runs can replay them without the network.
Code-based check
A check on a model’s output written as ordinary code, such as a comparison, a pattern or a rule, so it runs in microseconds and costs nothing.
Cohen’s kappa
An agreement score between two graders that removes the agreement expected by chance: (observed − chance) ÷ (1 − chance). 1 is perfect; 0 is no better than chance.
Confidence interval
A range around a measured value that would contain the true value in a stated share of repeated samples, usually 95%.
Confusion matrix
A table that counts how often two sets of labels agree and disagree, one row per label from one source and one column per label from the other.
Contamination (experiments)
When one group in an experiment influences the other, so the measured difference between versions is wrong, usually too small.
Continuous integration (CI)
Automated checks, such as tests and type checks, that run on every push to a shared code repository, so a change that breaks something is caught before it ships.
Criteria drift
The way people’s grading criteria change as they grade real outputs: they need criteria to grade, but grading is how they discover what the criteria should be.
Decided case
A borderline example that labellers disagreed on, added to the labelling guidelines with the agreed answer and the reason, so later labellers handle the same kind of case the same way.
Design effect
How many times more samples a test needs when it assigns groups, such as whole shops, instead of single items, because items in a group are alike: 1 + (items per group − 1) × how alike they are.
Development split
The part of an eval set the team runs and reads freely while improving a prompt or model.
Edit size
How much a person changed an AI draft before sending it, from 0 (sent as is) to 1 (no word kept), computed by comparing the draft with the sent text.
End state (agent eval)
What an AI agent’s run leaves behind in its environment, such as rows written and the run’s status, checked against the state a correct run would leave.
Error analysis
Reading a system’s failures, describing and grouping them into categories, and counting each, to decide what to fix first.
Eval
A repeatable test that runs an AI feature on many realistic inputs and scores each output, to measure how often it is good enough.
Eval harness
The code that runs an AI feature on every case in an eval set, saves each output, grades it with checks and judges, and reports the scores.
Eval set
The saved inputs an eval runs on, each one a case, sometimes with notes on what a good output must do. The same set is reused for every run so scores can be compared.
Exact match
An eval check that passes only when the output equals the expected value character for character.
Explicit feedback
A judgement a person chooses to give, such as a thumbs up or down or a rating. Clear, but rare and given mostly when something is wrong.
Failure category
A named group of failures with the same cause, specific enough to point at the part of the system to change.
False fail rate
Of the outputs people passed, the share an automatic grader failed. It measures how often good outputs are flagged for nothing.
False negative
A check result that says pass, or not found, for a case that should have failed.
False pass rate
Of the outputs people failed, the share an automatic grader passed. It measures how many bad outputs the grader lets through.
Fault injection
Making a dependency fail on purpose during a test, such as a timeout or an error, to check how the system behaves when it does.
Golden dataset
An eval set the team writes by hand, with the inputs it expects and an ideal answer for each.
Grader
The part of an eval that scores one output on one criterion: a piece of code, a model acting as judge, or a person.
Ground truth set
An eval set sampled from real production traffic, in the same mix, with labels from people who know the product.
Grounded answer
An answer in which every claim is supported by a source the model was given. Grounding is checked against what the model saw, so a grounded answer can still be wrong if the needed source was never sent.
Guardrail metric
A metric that must not get worse during an experiment, with a stop rule written in advance, whatever the main metric does.
Hard gate
An eval check that blocks a release on any failure at all, rather than comparing a score with the previous version.
Held-out split
The part of an eval set kept unread and used only to decide a release, so the score isn’t inflated by tuning on it.
Implicit feedback
Signals about quality taken from what people do, not what they say, such as edits, time spent or a ticket being reopened.
JSON Lines
A text file format with one complete JSON object on each line, easy to append to, stream and compare line by line.
Labelled set
A small set of real past cases, each with the correct outcome a person confirmed, used to compare two versions of a feature.
Labeller agreement
How often different people give the same label to the same item, measured on items that several people label without seeing each other’s answers.
Labelling guidelines
A short written definition of each grading criterion, with examples that pass, examples that fail and decided borderline cases, so different people label the same output the same way.
LLM judge (LLM-as-judge)
A model call that grades another model’s output against written criteria, given the input, the sources and the output, and returns a structured verdict.
Luhn check
A simple checksum over a number’s digits that every valid payment card number passes, used to tell a card number from other long digit runs.
McNemar’s test
A statistical test for paired pass or fail results that looks only at the cases that changed, asking how likely their split would be by chance.
Mean reciprocal rank (MRR)
For each query, 1 divided by the position of the first relevant result (0 if none is found), averaged over all queries. It rewards finding one relevant result early and ignores the rest.
MockTransport
An httpx2 transport that passes each request to a function you write and returns that function’s response, so a client makes no network calls.
Normalised match
An eval check that cleans both values in ways that can’t change their meaning, such as spaces and letter case, and then compares them.
Novelty effect
A change that looks better at first because it is new, with the effect fading as people get used to it.
Online evaluation
Measuring a version of an AI feature by what happens in production: what users do with its output and what follows, rather than scores on a fixed test set.
Open coding
Writing a short free-text note on each failure, about the first thing that went wrong, before deciding on any categories.
Paired comparison
Comparing two versions on the same examples and looking only at the examples where their results differ.
Pairwise comparison
Grading by showing a judge two outputs for the same input and asking which is better, or whether they tie.
Pass rate
The share of eval cases on which one check passes, reported per check so a single failing rule isn’t hidden in an average.
pass@k
The chance that at least one of k runs of a task succeeds, averaged over tasks. It rises as k grows.
pass^k
The chance that all k runs of a task succeed, averaged over tasks; a measure of how consistently an AI agent gets the same task right. It falls as k grows unless every run passes.
Pearson correlation
A measure from −1 to 1 of how closely two sets of numeric scores rise and fall together in a straight-line relationship.
Peeking (A/B tests)
Checking an experiment’s result repeatedly and stopping as soon as it looks significant, which makes false wins far more likely than the stated rate.
Persona (simulated user)
The description a simulated user plays from: the goal, the facts the person knows, when they share each one and how they write. The AI agent under test never sees it.
Persona drift
A simulated user leaving its persona during a conversation: forgetting or inventing facts, changing its mood or starting to act like the support side. A drifted conversation says nothing about the agent under test.
Personal data
Any information that identifies a person, such as a name, email address, street address, phone number or card number.
Pointwise grading
Grading each output on its own against a rubric, so results are absolute and can be compared across runs.
Position bias (LLM judges)
A judge’s tendency to prefer an answer because of where it appears in the prompt, usually first, rather than because it is better.
pytest
A Python test runner that finds test functions, runs them and reports which passed and which failed.
Randomisation unit
The thing an experiment assigns at random to a version: a request, a user, an account or a whole customer organisation.
Raw agreement
The share of items on which two graders give the same label, without correcting for agreement by chance.
Recorded tool result
A real response from a tool’s backing service, saved once with personal data removed and replayed in tests, so every run sees the same realistic answer.
Reference answer
One known-good output stored with an eval example, which a grader compares a new output against.
Regular expression
A pattern that describes text to search for, such as “13 to 19 digits with optional spaces”, used by code to find or check matching strings.
Reward hacking
When a system tuned against a score finds ways to raise the score without doing the task the score was meant to measure.
Rubric
The written criteria a grader applies, each with what passes and what fails, so different graders score the same output the same way.
Run-to-run variance
How much an eval score moves when the same version runs twice, because the model’s outputs and the judge’s grades differ between runs.
Saturation (theoretical saturation)
The point where reading more failures no longer adds new categories or changes the existing ones.
Scenario (agent eval)
One test case for an AI agent: a task such as a ticket, a fake world for its tools to read, and the end state a correct run should leave behind.
Self-preference bias
A judge’s tendency to rate outputs from its own model, or its own model family, higher than equally good outputs from others.
Sign test
A test that asks how likely a split of changes in one direction against the other would be if each change were a fair coin toss.
Simulated user
A second model that plays the person an AI agent talks to. It is given a persona and a hidden goal, and writes that person’s messages one turn at a time, replying to whatever the agent says.
Statistical power
The chance that a test detects a real effect of a given size. 80% is a common target.
Stratified sampling
Splitting a population into groups, called strata, and drawing a fixed number at random from each group, so small groups are well represented.
System under test
The exact version of a feature an eval is measuring: its prompt, model and settings. It is the one thing that changes between two runs being compared.
Test double (fake)
A stand-in for a real dependency that a test controls, so the code under test can run without the real thing.
Trajectory (of an AI agent)
The steps an AI agent takes in one run, in order: its model calls and the tool calls they asked for.
Unit test
An automated test that runs one small piece of code on a fixed input and checks that it returns one expected output.
Verbosity bias
A judge’s tendency to rate longer answers higher even when the extra length adds nothing.