June 12, 2026 · Yunus Emre Vurgun
Verifying LLM Output Against Reference Data: A Field Guide
Grounding an LLM with a small reference is one of the most reliable quality boosts you can ship. The pattern is well known; the failure modes are less so.
The basic pattern
- Identify the closed set of valid answers (e.g., HTTP status codes).
- Include the reference in the system prompt, in a compact format.
- After the model answers, post-process: does the value appear in the reference?
Code, in a few lines
def verify_status(value, ref):\n return value in ref["codes"]\nThe cheapness of the check is the point. Do not over-engineer it.
Common failure modes
- Synonyms: the model returns
404while the reference usesNot Found. Normalize before checking. - Off-by-one versions: the model knows a newer spec than your reference. Pin the reference and document the version.
- Hallucinated extensions: the model invents a new code. The check correctly rejects it; treat that as a feature, not a bug.
When not to verify
Open-ended creative tasks, summarization, free-form explanation. The check would be either trivial or wrong. Reserve verification for tasks with a real closed set.