A unit test compares what your code returned with what you expected. That works because the same input gives the same output. An LLM breaks that: ask it the same question twice and you get two different sentences, often both correct.
You test it with evals, and a common way to grade an eval is to have another model act as the judge.
Why exact match fails
Say you have a support bot, and a customer asks: “Can I get a refund 45 days after buying?” The policy says refunds are only possible within 30 days, so the right answer is no.
You write a test with the expected answer and run the bot three times.
| Run | Answer | Test | Correct |
|---|---|---|---|
| 1 | No. Refunds are only available within 30 days of purchase. | Fail | Correct |
| 2 | Sorry, our policy only allows refunds in the first 30 days. | Fail | Correct |
| 3 | Yes! You can request a refund at any time. | Fail | Wrong |
All three runs fail the test, and two of them were right. The test checks whether the sentence is identical to the expected one, and with an LLM it almost never is.
You can loosen it by searching for the word “no” or for “30 days”. That catches some cases and misses others: “Unfortunately that's outside our window” says no without the word. Code checks still have a place for things with one right shape, like valid JSON, a field that must be present, or a number in range. For meaning, you need something that reads.
What an eval is
An eval is a test suite for model output: a set of inputs, and a way to grade each output. The inputs are real or realistic cases, ideally ones that went wrong before. There are three ways to grade them.
- Code is fast and exact, but only works for things with one right form.
- People are the most reliable, and also the slowest and most expensive. Nobody grades 5,000 conversations every time a prompt changes.
- Another model can read the output and grade it against criteria you write. This is LLM-as-a-judge.
How the judge works
The judge is a prompt like any other. It gets the question, the answer, and a rubric that says what a good answer must do, and it returns a verdict.
The rubric should be one concrete question. “Does the answer say refunds are only available within 30 days of purchase?” works. “Is this a good answer?” doesn't, for reasons the next section shows.
No. Refunds are only available within 30 days of purchase.
{
"verdict": "pass",
"reason": "States the 30-day limit.",
"quote": "only available within 30 days"
}Ask the judge for structured output: a verdict (pass or fail), the reason, and the passage of the answer the verdict rests on. A JSON schema keeps every verdict in the same shape, so you can count them, and the quoted passage lets a person check a verdict in seconds.
When the judge is wrong
A judge is a model, so it makes mistakes. The one that hurts most is the false positive, when the judge passes an answer that's wrong. Your eval says everything is fine while customers get bad answers.
Vague rubrics make this worse. Asked “is this a good answer?”, a model tends to favor answers that sound confident and complete, even when the content is wrong.
You can't tell how often your judge is wrong without checking it against people. Take a sample of answers, have a person label each one correct or incorrect, run the judge on the same sample, and compare.
- Answer 1: correct, judge says pass
- Answer 2: correct, judge says pass
- Answer 3: wrong, judge says pass, false positive
- Answer 4: correct, judge says pass
- Answer 5: correct, judge says pass
- Answer 6: wrong, judge says pass, false positive
- Answer 7: correct, judge says pass
- Answer 8: correct, judge says fail
- Answer 9: correct, judge says pass
- Answer 10: wrong, judge says fail
- Answer 11: correct, judge says pass
- Answer 12: correct, judge says pass
- Answer 13: wrong, judge says pass, false positive
- Answer 14: correct, judge says pass
- Answer 15: correct, judge says pass
- Answer 16: wrong, judge says pass, false positive
- Answer 17: correct, judge says pass
- Answer 18: correct, judge says pass
- Answer 19: wrong, judge says pass, false positive
- Answer 20: correct, judge says pass
- Answer 21: wrong, judge says fail
- Answer 22: correct, judge says pass
- Answer 23: correct, judge says pass
- Answer 24: wrong, judge says pass, false positive
Measure agreement before you trust the judge, and measure it again whenever you change the judge's prompt or model, because those are code you ship and they need tests like any other code.
Running evals on every change
Once the judge agrees with people, the eval becomes a regression test. Run it on every prompt or model change, the way CI runs unit tests, and compare the score with the last run. A drop in one category tells you what broke before a customer does.
Keep adding cases. Every bad answer you find in production goes into the set, labeled, so the same mistake can't come back unnoticed.