June 12, 2026 · 1 min read · Yunus Emre Vurgun

Verifying LLM Output Against Reference Data: A Field Guide

llm · verification · testing · agents
In this guide
  1. The basic pattern
  2. Code, in a few lines
  3. Common failure modes
  4. When not to verify

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

  1. Identify the closed set of valid answers (e.g., HTTP status codes).
  2. Include the reference in the system prompt, in a compact format.
  3. 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"]\n

The cheapness of the check is the point. Do not over-engineer it.

Common failure modes

  • Synonyms: the model returns 404 while the reference uses Not 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.

Search the library

Search by a topic, title, or keyword.

Start with a collection

Browse all 205 datasets