Testing software whose answer is not fixed
A language model does not answer the same way every time. Such a feature can still be tested: with real cases, a score per case, and a run on every change.
A classic test compares a result with an expected value. For a feature with a language model behind it, that one value often does not exist. The same question can have two correct answers in different words, and a change to the prompt improves ten cases and worsens three.
The answer to that is called an eval: a collection of cases with a score, run on every change.
Cases from production
The cases come from real use, not from the team's imagination: real questions, real documents, including the unpleasant ones. A few well-chosen cases say more than many generated ones. Every error noticed in production becomes a new case. That way the collection grows where the system is weak.
{
"question": "When can I cancel?",
"source": "terms.pdf",
"expected": {
"contains": ["14 days"],
"cites": "terms.pdf"
}
}
Three ways to score
- Exact. Where the output is a value, it is compared: a category, an amount, a date.
- By rules. Is the answer valid JSON, does it contain the required statement, does it name the source, does it stay under the length.
- By a model. A second model scores the answer against fixed criteria. That scales, but needs a check of its own: people score a sample, and their verdict is compared with the model's. If the two often differ, the criteria are not clear enough.
The first two are cheap and dependable. The third is added where nothing else works.
When the eval runs
On every change that touches behavior: prompt, model, model version, search index, tools. The result is not a single number but a comparison with the last state: which cases newly pass and which newly fail. Because answers vary, important cases run several times.
A threshold in the build keeps a regression from shipping unnoticed.
What stays an ordinary test
Around the model lies ordinary code, and it is tested in the ordinary way: splitting the documents, parsing the output, the permission check before a tool call, the behavior on a timeout. Here the result is fixed. What can be checked deterministically does not belong in an eval.
Why first
The eval is written before the feature, not after. Anyone who has to write down how to recognize a good answer notices early whether the requirement is clear. And only with it can you answer what is otherwise guessed: whether the cheaper model is enough, whether the new prompt is better, whether the update broke something.