Cloud Tech by Victor
BackendIntermediate

LLM Evaluation & Reducing Hallucinations

Why "it feels better" isn't a shippable justification for a prompt change, what an LLM-graded eval actually measures, and why explicitly allowing "I don't know" is one of the most effective, cheapest hallucination fixes available.

Updated 2026-07-243 min read

Overview

Shipping a prompt change without an evaluation suite means trusting that "it feels better" on a handful of manually-checked examples, which reliably misses regressions on dimensions nobody happened to spot-check, consistency, tone, an edge case like sarcasm. A real eval suite scores against defined success criteria using the grading method that fits the question: exact match for single-right-answer tasks, embedding similarity when wording can vary but meaning shouldn't, and LLM-graded scoring for genuinely subjective qualities a fixed rule can't capture. Hallucination reduction is a related but distinct discipline, and the cheapest, most effective techniques are concrete and specific: explicitly permitting "I don't know" as a valid answer, and for long documents, requiring the model to extract and cite direct quotes before generating analysis, rather than answering freely from memory of the text.

Quick Reference

Grading methodBest for
Exact matchSingle-right-answer tasks (classification, categorical labels)
Embedding similarityMeaning should match a reference even if wording varies
Reference-based (e.g. ROUGE-L)Comparing generated text (summaries) against a reference
LLM-graded (Likert or binary)Subjective qualities: tone, empathy, professionalism
Hallucination techniqueWhat it does
Allow "I don't know"Removes pressure to fabricate a confident-sounding answer to a real gap
Extract quotes before analyzingGrounds the response in verifiable source text, not free recall
Cite a supporting quote per claimMakes every claim auditable; unsupported claims get retracted
Chain-of-thought verificationSurfaces faulty reasoning before it becomes the final answer

Syntax

python
def evaluate_exact_match(model_output, correct_answer):
    return model_output.strip().lower() == correct_answer.strip().lower()

Examples

text
As our M&A advisor, analyze this report on the potential
acquisition of AcmeCo by ExampleCorp. <report>{{REPORT}}</report>
Focus on financial projections, integration risks, and regulatory
hurdles. If you're unsure about any aspect or if the report lacks
necessary information, say "I don't have enough information to
confidently assess this."

Volume over polish for automated evals

Official guidance is explicit: more test cases with slightly-lower-signal automated grading beats fewer, hand-graded ones. Structure eval questions for automated scoring so you can run them at real scale, not as an occasional manual spot-check.

Visual Diagram

Common Mistakes

  • Testing a prompt change on a handful of clean, manually-picked examples instead of a real eval suite covering edge cases.
  • Using exact-match grading for a task where wording legitimately varies but meaning should match, producing false failures.
  • Never telling the model uncertainty is an acceptable answer, leaving it under implicit pressure to always produce a confident, complete response.
  • Treating any single hallucination-reduction technique as sufficient; official guidance is explicit that these reduce, not eliminate, hallucination, critical claims still need independent validation.

Performance

  • LLM-graded evals cost a real model call per graded example, meaningfully more expensive than exact-match or embedding-similarity grading; reserve them for qualities that genuinely need subjective judgment.
  • Extracting quotes before analysis adds a real generation step and token cost on long documents, a deliberate trade against measurably better grounding, not a free improvement.

Best Practices

  • Build an automated, task-specific eval suite covering real edge cases before shipping a prompt change, not just a manual spot-check.
  • Match the grading method to the question: exact match for single right answers, similarity for flexible wording, LLM-graded for subjective quality.
  • Explicitly permit "I don't know" in prompts where a real information gap is possible, it's one of the cheapest, most effective hallucination reductions available.
  • For long-document tasks, require quote extraction and per-claim citation before analysis, and treat unsupported claims as ones to retract, not keep.

Interview questions

Why is an evaluation suite necessary before shipping a prompt change, instead of just testing it manually on a few examples?

A prompt change can improve one success dimension while quietly breaking another, better accuracy but worse consistency, or improved tone at the cost of latency, and manually eyeballing a handful of examples won't reliably catch a regression on a dimension you weren't specifically looking at. An evaluation suite tests against a defined, ideally large set of cases, including deliberately hard edge cases like sarcasm or mixed sentiment, and scores every dimension that actually matters, which turns "it feels better" into a measurable, defensible, trackable claim, and catches regressions before they reach production rather than after.

What is an "LLM-graded" eval, and when would you reach for it instead of exact-match or similarity-based grading?

An LLM-graded eval uses a separate model call to judge a subjective quality of the output, tone, empathy, professionalism, on a numeric scale or binary classification, rather than checking it against one fixed correct answer. Exact-match grading only works when there's one right answer (a category label); similarity-based grading (cosine similarity between embeddings) works when wording can vary but meaning should match a reference. LLM-graded evals are the right tool specifically for qualities that are inherently subjective and hard to define with a fixed rule or reference string, at the cost of being noisier and more expensive to run than a simple string comparison.

Why does explicitly telling a model it's allowed to say "I don't know" measurably reduce hallucination, and what's a second, complementary technique for the same problem?

Without that explicit permission, a model under an implicit expectation to always produce a confident, complete answer will sometimes fill a real information gap with a plausible-sounding but fabricated one; stating outright that uncertainty is an acceptable answer removes that pressure and lets the model surface "I don't have enough information" instead of guessing. A complementary technique for long documents is asking the model to first extract direct, word-for-word quotes relevant to the task before generating any analysis, grounding its response in verifiable text it actually has in front of it, and then citing which quote supports each claim, rather than generating an answer freely and hoping it stayed faithful to the source.

References

ShareXLinkedInReddit
Was this page helpful?
Suggest an improvement