Read the Answers Before You Measure
An app built on a language model writes its answers fresh every time, so the ordinary way of testing code, comparing what came out with what you expected, stops working. Evaluating such an app (running an eval) means measuring how often its answers are good by a standard you have written down. This page explains why the ordinary test breaks, what an eval is made of, and why the first step is not choosing a score but reading real answers and judging each one.
Why comparing with one expected answer fails
An ordinary automated test runs some code and asserts that the result equals a known value. Suppose a hotel has a support assistant, and its cancellation policy is free cancellation up to 48 hours before check-in. The natural first test asks the assistant a guest's question and compares the reply with the answer you would write yourself. Here ask_assistant stands for whatever function sends the question to the app and returns its reply.
def test_cancellation_answer():
reply = ask_assistant("Can I cancel my booking and get my money back?")
assert reply == "Yes, you can cancel free of charge up to 48 hours before check-in."This test fails almost every time, and it fails for the wrong reasons. Three things about model output get in the way.
- The wording changes between runs. The same question can come back phrased differently each time you ask it. A model chooses its words with some randomness, and the setting
temperaturecontrols how much. Turning it down to 0 still does not make hosted models deterministic in practice: in one published experiment, 1000 identical requests at temperature 0 produced 80 different completions. The main cause is the server itself. It processes your request in a batch together with other people's, and the size of that batch changes the arithmetic slightly. Some providers no longer let you set the temperature at all. - Many different answers are correct. A reply that gives the right policy in other words, or adds the steps to cancel, is just as good as the one you wrote, and an exact comparison rejects it.
- A fluent answer can be wrong. The most confident, well-written reply can state the wrong policy. Loosening the test, for example checking only that the reply mentions cancelling, lets that reply through.
| Reply | Exact match | Actually |
|---|---|---|
| You can cancel without any fee as long as it is more than 48 hours before you arrive. | fail | correct |
| Sure. Open My Bookings and choose Cancel. There is no charge if you do it at least two days before check-in. | fail | correct |
| Yes, you can cancel at any time before check-in and get a full refund. | fail | wrong |
Exact match gives the same verdict to all three, so it tells you nothing. That does not make exact comparison useless: when the answer is a label from a fixed set (a sentiment of positive, negative or neutral), a number, or a field in structured output, one correct value exists and comparing with it works. It breaks on free-form text, where the quality you care about is in the meaning rather than the characters.
True or false?
Setting the temperature to 0 makes a hosted model return the same text every time, so an exact-match test becomes reliable.
False. Hosted models still vary at temperature 0, mostly because server load changes how requests are batched. And even identical text would not solve the other problem: many different wordings are correct.
Checking that a structured field such as a category label equals an expected value is a sound test for an LLM app.
True. A field with a fixed set of values has one right answer, so comparing it exactly works. The trouble is free-form text, not every output.
What an eval is made of
Since no single expected string can judge the reply, the test has to judge it against a rule instead. An eval is a repeatable measurement of how an app behaves, and it has three parts.
- A set of inputs: the questions or requests you send to the app, chosen to represent what it really gets.
- A grader: something that looks at each output and decides whether it meets a criterion, one stated quality such as "gives the cancellation window the policy states". A grader can be code, a person, or another model.
- A score: the outcome reported as a rate, the share of outputs that passed.
- Inputs what users ask
- The app model + prompt
- Outputs one per input
- Grader pass or fail on one criterion
- Score a pass rate
- Inputs to The app
- The app to Outputs
- Outputs to Grader
- Grader to Score
The score is a rate rather than a single pass or fail because a model app is never perfect on every input. If a grader passes 41 of 50 outputs, the pass rate is:
Repeatable is the important word. Run the same eval tomorrow and you should be measuring the same thing, so that a change in the score means the app changed. Unlike an ordinary test suite, an eval does not have to reach 100%: how many failures you can accept is a product decision, and the rate tells you where you stand.
True or false?
An eval that reports a pass rate below 100% has failed, in the same way a unit test with one failing assertion has failed.
False. The pass rate is a measurement. Whether 82% is good enough depends on what the failures cost, which is a product decision.
A grader judges each output against one stated criterion rather than against a single expected reply.
True. That is what lets it accept every correctly worded answer and still reject a fluent wrong one.
Recording the outputs once
Because a live call can return a different reply each time, reading or grading straight from the model would give a slightly different picture on every run, and every run would cost a model call per input. The fix is to separate producing the outputs from judging them. You run the app once over the inputs and save every reply to a file. Everything after that, reviewing by hand or grading by code, reads the file.
- Live model calls vary, cost per call
- Recorded outputs saved once
- Review by hand
- Grade today
- Grade again later
- Live model calls to Recorded outputs: record once
- Recorded outputs to Review by hand
- Recorded outputs to Grade today
- Recorded outputs to Grade again later
A recorded output is ordinary data. Each record keeps the input and the reply together, so nothing has to be looked up again later:
[
{
"id": "q-014",
"input": "Can I cancel my booking and get my money back?",
"output": "Yes, you can cancel at any time before check-in and get a full refund."
},
{
"id": "q-015",
"input": "Is breakfast included?",
"output": "Breakfast is included with every room and is served from 7 to 10 am."
}
]Reading this file gives the same result on every run and costs nothing. If you improve a grader, you can run it again on exactly the same replies and know that any change in the score came from the grader. When the app itself changes, you record a new set of outputs, because the old file describes the old app.
True or false?
Grading a recorded file twice with the same code grader can give two different scores, because the app's model varies between runs.
False. The app's model is not called when grading a recorded file. The replies are fixed text, so a code grader gives the same verdicts every time. Only a grader that is itself a model makes calls of its own, and its verdicts can vary.
Reading outputs before choosing a metric
With outputs on file, the tempting next step is to pick a score and compute it. Ready-made eval tools offer general scores such as helpfulness or coherence. They measure qualities that may not matter for your app, and a good score on them does not mean the app works. A reply that cheerfully promises a refund the policy does not allow reads as helpful and coherent, and it is the worst answer the hotel assistant could give.
The failures that matter are specific to the app: its policies, its data, the things its users ask. You find them by reading real outputs, and only then decide what to measure. Practitioners call this error analysis. When people do it, they usually find that a few specific problems account for most of the failures, and none of those problems is named by a general score.
| Reply | Helpful and coherent? | What reading finds |
|---|---|---|
| Promises a full refund at any time | yes | states a cancellation window the policy does not have |
| Offers a free room upgrade to apologise | yes | invents an offer the hotel never made |
| Guest asks for a person; reply keeps answering itself | yes | does not hand over to staff when asked |
| Gives the parking price from the hotel's information | yes | correct |
Reading is not the same as glancing at a few replies and deciding the app "seems fine". That is a vibe check, and it leaves nothing to count. Error analysis writes down a judgment for every output in a sample, so the results can be counted and compared. As a rough guide, practitioners suggest a working pool of around a hundred varied outputs, chosen to cover the different kinds of request the app gets.
True or false?
A high helpfulness score from a ready-made metric is good evidence that a support assistant gives correct answers.
False. A wrong answer can be polite, clear and confident. General scores do not know your policies, so they miss the failures specific to your app.
Choosing what to measure after reading outputs tends to produce metrics that track real problems.
True. Each metric then comes from a failure you have actually seen, instead of a quality someone guessed might matter.
Judging each output with an open note
The review itself is simple to describe. For each output in the sample you write two things.
- A verdict, pass or fail. Would this reply be acceptable to send to a real user? A two-way choice forces a clear decision. On a scale from 1 to 5, reviewers drift towards the middle and spend time debating whether something is a 3 or a 4.
- A short free note on a fail, in your own words, about the first thing that went wrong.
| Output | Question | Verdict | Note |
|---|---|---|---|
| q-014 | Cancel and get my money back? | fail | says cancel any time; policy is 48 hours before check-in |
| q-015 | Is breakfast included? | fail | claims breakfast with every room; only some rates include it |
| q-016 | Do you have parking? | pass | |
| q-017 | I want to talk to a person | fail | ignores the request and asks for the booking number |
| q-018 | Can I bring my dog? | pass | |
| q-019 | Change my dates to next week | fail | confirms a change it cannot make |
Two rules make the notes useful.
Note the first failure. Problems in a reply often cascade. If the assistant misreads which booking the guest means, everything after that is wrong too, but the cause is the misreading. Writing down the earliest thing that went wrong points at what to fix, and fixing it often clears the later problems as well.
Fix no categories in advance. A list of categories chosen beforehand makes you sort each reply into a box you already expected, and the problems that fit no box go unrecorded. So the notes are free text, like a journal, and they capture whatever is actually there. Writing notes this way, with the categories left open, is called open coding. Grouping the notes into named kinds of failure comes afterwards, from the notes themselves.
The judging works best when one person who knows the domain does it, someone who knows the hotel's real policies and can say with authority what a good answer is. Their written verdicts and notes are the raw material every later measurement is built from.
True or false?
A reviewer should start with a fixed list of failure categories, so that every note fits one of them.
False. Open coding writes free notes first. A fixed list misses the problems nobody predicted, and those are often the ones specific to the app.
When a reply goes wrong in several places, noting only the first failure is a reasonable way to start.
True. Later problems often follow from the first one, so the first failure is usually the one worth fixing.
Judging each output pass or fail is slower than rating it from 1 to 5, because the reviewer has to be certain.
False. A two-way choice is usually faster: there is no time lost deciding between neighbouring scores, and the verdicts are more consistent.