How to evaluate LLM outputs: testing AI features
Evaluating an LLM output means checking whether it is actually correct, grounded, safe, and useful, not just whether it sounds fluent. That distinction is the whole challenge. A language model can produce a confident, well-written answer that is quietly wrong, and no amount of reading it over will scale. Testing AI features properly means building a repeatable way to measure output quality, the same way you would test any other part of a product, adapted to the fact that the output is not deterministic.
Why LLM outputs need a different kind of testing
Traditional software is deterministic: the same input gives the same output, and a test asserts they match. LLM features break both assumptions. The same prompt can produce different wording each time, and for most real tasks there is no single correct string to compare against. Two answers can be worded completely differently and both be right, or nearly identical and one be subtly wrong.
So you cannot test an AI feature with exact-match assertions alone. You test it the way you would judge a person's work: against criteria, on a representative sample, by someone or something capable of judging quality rather than string equality.
Start with an evaluation set
Everything downstream depends on having a fixed set of real examples to test against, usually called an eval set or golden set. It is a collection of representative inputs, paired where possible with what a good answer looks like or the criteria a good answer has to meet.
Build it from reality, not imagination. Pull real user questions, real documents, and the awkward edge cases that actually occur: the ambiguous request, the question your data cannot answer, the input in the wrong format. A good eval set deliberately includes cases where the right answer is "I do not know," because a feature that never declines is a feature that is guessing.
Keep it version-controlled and let it grow. Every time a bad output reaches production, add that case to the set so the same failure can never return unnoticed. Over time this becomes the single most valuable asset in your AI feature, more than any prompt.
The dimensions that actually matter
Quality is not one number. A useful evaluation scores several dimensions, and which ones matter depends on the feature.
| Dimension | What it checks | How to test it |
|---|---|---|
| Correctness | Is the answer factually right for the input | Compare against known answers in the eval set, or expert review |
| Faithfulness | Does the answer stay grounded in the provided source, without inventing | Check each claim traces back to the retrieved or given context |
| Relevance | Does it actually address what was asked | Rate answers against the intent of the question |
| Safety | Does it avoid harmful, biased, or disallowed content | Run adversarial and sensitive inputs, check the guardrails hold |
| Format | Does it return valid structure when the app expects it | Assert on JSON validity, required fields, length, tone |
| Refusal calibration | Does it decline when it should, and only when it should | Include unanswerable cases and check it says so |
Faithfulness deserves special attention for anything built on your own data. A retrieval-augmented feature can fetch the right passage and still have the model drift beyond it, so grounding has to be measured directly, not assumed.
Who does the judging
There are three ways to score outputs, and mature teams use all three in layers.
Automated checks are cheap and instant, and they cover anything mechanical: valid JSON, required fields present, forbidden content absent, length within bounds. Run these on every output.
A model acting as judge uses a separate model call to grade an answer against a rubric, such as "is this answer supported by this source, yes or no." It scales far better than human review and suits faithfulness and relevance well, as long as you validate the judge against human ratings first so you can trust its scores.
Human review remains the ground truth for correctness and nuance. You cannot review everything, so you sample: a fixed slice of production traffic, plus the cases where the automated judges disagree or score low. Those human labels then become new eval-set entries.
Catching regressions before users do
Evaluation is not a launch-day checkbox; it is a loop that runs for the life of the feature.
Run your eval set offline whenever you change anything that affects output: the prompt, the model version, the retrieval logic, the temperature. Treat a drop in scores the way you would treat a failing unit test, and wire it into the same pipeline so a regression blocks the change. A model provider's silent update can shift behavior without a line of your code changing, which is exactly what an eval suite in continuous integration is there to catch.
Then monitor online, in production. Log inputs and outputs, track how often the feature declines or hits a guardrail, and give users a simple way to flag a bad answer. Feed everything you learn back into the eval set. Teams that treat evaluation as ongoing keep quality steady as usage grows; teams that treat it as a one-time gate watch it decay silently.
Where this fits in building an AI feature
Good evaluation is what separates an AI demo from an AI product. A demo has to work once, in front of an audience; a product has to work on the thousandth real input, including the ones nobody anticipated. That gap is exactly where disciplined AI development lives, and it is why teams shipping AI agents into production invest in evaluation infrastructure early rather than bolting it on after quality complaints start. Decide what "good" means for your feature, write it into an eval set, and measure against it continuously. The model will keep changing underneath you; your definition of good, and your way of checking it, are what stay constant.