Evaluation and Security

Hallucination Controls Belong in the System, Not One Prompt

May 9, 202611 min readUpdated Jul 26, 2026

Hand-drawn pen-and-ink diagram of the mechanism explained in "Hallucination Controls Belong in the System, Not One Prompt".
01 / 09

Classify the failure before choosing a control

Hallucination describes several failures that need different remedies: an unsupported factual claim, an incorrect transformation of provided data, an invented citation, a tool result that never occurred, or overconfidence about ambiguity. Retrieval helps only when missing knowledge caused the error. It cannot fix arithmetic mistakes, stale tools, or a prompt that asks the model to infer unavailable account state. Build a taxonomy from real incidents and attach controls to each class.

Define the system’s epistemic boundary. Some claims may come from immutable product documentation, others from authenticated live tools, and others from the model’s general knowledge. Label these sources internally and decide which are permitted for each workflow. A medical or financial experience may require evidence for every material claim, while creative ideation can tolerate invention if clearly framed. One global instruction to be accurate cannot express these different contracts.

Measure claim-level support rather than whole-answer plausibility. Split responses into atomic verifiable claims, associate each with source spans or tool receipts, and mark opinions or transitions separately. This representation exposes a common pattern: the central answer is supported, but the model adds a confident qualifier not present anywhere. Users often act on the qualifier, so sentence-level grading can still be too coarse.

02 / 09

Constrain generation with evidence and schemas

Provide only the evidence needed and identify it with stable IDs. Tell the model which fields may be inferred and which must be copied exactly. For data workflows, structured outputs can separate source-backed values, calculations, assumptions, and unknowns. Validate types, ranges, identifiers, and cross-field rules in code. Grammar-constrained JSON prevents malformed syntax, but semantic validation is still required because a perfectly valid number can be invented.

Quotes and citations should be selected from supplied evidence rather than generated freehand. The application can require an evidence ID and character offsets, then verify that the referenced text exists. When exact spans are inconvenient, validate a cited claim with an entailment model or second-stage judge. Keep the original evidence available for user inspection. Citation formatting without support checking can make hallucinations more persuasive.

Tool execution should return authoritative records and receipts that the generator cannot alter. Pass compact typed fields into the response step, and format critical values such as prices, dates, and identifiers in deterministic code where possible. If a model computes a total, independently recompute it. Moving simple transformations out of generation reduces both error surface and evaluation burden without reducing the model’s value in explanation.

03 / 09

Verify before the answer crosses the boundary

A verification pass should operate on claims and evidence, not ask the same model vaguely to double-check itself. Extract claims, test support, and return specific failures for revision or removal. Use a different model or deterministic rule where independence matters, but recognize that all learned verifiers have blind spots. High-risk decisions may require expert review or a tool-based validation that directly queries the source of truth.

Revision loops need bounds. If an unsupported claim survives one targeted rewrite, repeated self-correction may add latency while rearranging the same error. Fall back to a conservative template, show verified facts only, or abstain. Log the rejected draft and verifier reason securely for diagnosis. The user should see an honest limitation rather than internal debate or a polished answer produced after an unbounded loop.

Verification also checks freshness and authority. A claim can be entailed by a retrieved document that is obsolete or superseded. Rank sources by authority, apply validity intervals, and detect conflicts before generation. When authoritative sources disagree, present the disagreement with dates and provenance instead of allowing the model to synthesize false certainty. Correct uncertainty is a feature, not a degraded answer.

04 / 09

Design abstention users can trust

Abstention should be triggered by observable conditions: no eligible evidence, weak support, conflicting sources, tool failure, or a request outside policy. Calibrate thresholds on the cost of false answers and false refusals. A support chatbot can ask a clarifying question when product identity is ambiguous; a compliance assistant may need to stop immediately. The response should state what is missing and offer the smallest next step that can resolve it.

Do not let confidence come solely from the generator’s self-reported probability. Combine retrieval scores, evidence coverage, verifier outcomes, source authority, and tool health. Calibrate this decision on labeled data and monitor by slice. New query patterns can make a formerly safe threshold overconfident. Track answer, clarify, and abstain rates alongside downstream correction and escalation, not as isolated success metrics.

The strongest hallucination program improves upstream systems. Unsupported-answer logs may reveal missing documents, poor chunking, ambiguous product language, or a broken API. Route each incident to the owning layer and add it to regression tests. Prompt edits are appropriate for some behavior, but lasting reliability comes from evidence architecture, constrained interfaces, verification, and a product experience that makes uncertainty legible.

05 / 09

Research foundation and scope

TruthfulQA shows that language models can reproduce common falsehoods, while RAG supplies an external evidence path but does not itself guarantee supported prose [TRUTHFULQA] [RAG]. Hallucination control is therefore a chain of evidence, constraints, verification, and product behavior. These sources establish the mechanism, but they do not remove the need to measure the local implementation. A paper's result belongs to its checkpoint, dataset, hardware, traffic, and experimental protocol; a standard describes a contract or risk practice, not a guarantee that a particular product follows it. The useful engineering move is to convert each cited idea into a hypothesis that can be falsified with representative inputs and observable intermediate state.

Distinguish unsupported factual claims, stale evidence, entity confusion, instruction noncompliance, invalid structure, and creative output judged outside its intended mode. Each failure class needs a different control and metric. Write these conditions into the design review before selecting a library or provider. Specify the authoritative source of truth, the authenticated principal, the versions that influence behavior, the maximum consequence of an error, and what the system will do when required evidence is missing. This boundary statement makes later optimization honest: teams can compare speed, cost, or convenience only after candidates satisfy the same correctness, authorization, privacy, and recovery contract.

Read [TRUTHFULQA], [RAG], [NIST-GAI] together rather than treating one source as a recipe. TruthfulQA: Measuring How Models Mimic Human Falsehoods supplies one part of the foundation; Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks supplies a second perspective; Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile helps connect the mechanism to evaluation, governance, or operations. The citations are deliberately primary papers, standards, or official documentation. Product-specific claims still require local evidence, and any dated behavior must be rechecked against the cited version before an article or architecture decision is refreshed.

06 / 09

A production implementation blueprint

Route factual tasks to authoritative sources, attach evidence IDs, constrain output shape, validate deterministic fields, check claim support, expose uncertainty, and make abstention or clarification a normal result rather than an exception. Begin with one thin vertical path that preserves all decision evidence. Give each run a stable identifier; capture normalized input, authenticated scope, relevant dependency versions, selected policy, timing, result status, and any external receipt. Keep large or sensitive payloads in a separately governed store and pass bounded references through the orchestration layer. This produces a debuggable system without making raw customer content the default telemetry substrate.

Make state transitions explicit and make every external boundary return a typed result. Distinguish validation failure, permission denial, missing evidence, rate limit, timeout, dependency outage, user cancellation, and internal defect. The distinction matters because each permits a different response: clarify, retry, fall back, defer, compensate, or stop. A generic exception handler that asks the model to try again turns uncertainty into repeated cost and can duplicate irreversible effects. Retries require an idempotency strategy and a stored receipt, not optimism.

Roll out the implementation as a versioned policy. Record which cohort receives it, what baseline it replaces, which metrics can stop the rollout, and how to reverse stateful artifacts such as indexes, caches, adapters, or workflow histories. Review privacy and retention alongside performance. If raw content is needed temporarily for diagnosis, state the purpose, access, sampling, encryption, and deletion window. Production readiness means the team can explain, contain, and reverse behavior under load—not merely demonstrate the happy path once.

07 / 09

Failure lab and evaluation plan

Create answerable, conflicting, stale, and unanswerable cases with known evidence. Remove the correct source to test abstention, inject persuasive irrelevant passages, and compare model self-checking with an independent verifier. Keep the arrival pattern, data distribution, authorization, and dependency versions close to production. Use a paired baseline where possible and retain per-case results so averages cannot hide a severe slice. Offline evaluation should localize the failing stage; shadow evaluation should expose integration and traffic effects; a canary should confirm user-facing outcomes with a small blast radius. Each stage needs an exit criterion rather than a vague request to 'look good.'

Test citations that exist but do not entail a claim, numeric drift, temporal ambiguity, wrong-entity retrieval, tool failure hidden by prose, and confident completion after missing authorization. Verify the application rejects unsupported mappings. Add adversarial boundary cases and partial failures, not only malformed inputs. Terminate a worker after an external system may have committed, revoke access after a cache was populated, change one dependency version, and delay one branch until its data is stale. Confirm that cancellation releases resources and that a fallback preserves semantics. The test passes only when the external outcome, audit evidence, and user-visible state agree; a fluent final message is not proof of completion.

Evaluation data needs lineage equal to production data. Record why each case exists, who reviewed the expected behavior, which source or policy supports it, and when it must be refreshed. Separate generated cases from production incidents and prevent test cases from leaking into training. When a metric changes, inspect changed examples before accepting an aggregate. A statistically small regression can still block release if it crosses an authorization, privacy, safety, or irreversible-action boundary.

08 / 09

Operating metrics and decision record

Track unsupported-claim rate, citation precision and coverage, factual correction, abstention precision and recall, stale-answer rate, verifier disagreement, user escalation, and consequence-weighted harm. Define every metric with a numerator, denominator, unit, time window, exclusions, and responsible owner. Segment by workload and consequence so a dominant easy class cannot hide a rare costly failure. Pair service signals with product outcomes: latency without completion encourages fast useless answers, while answer quality without queue and cost data can produce an uneconomic service. Review percentiles and distributions rather than relying on a single average.

Set evidence and abstention policy by consequence: a brainstorming assistant and a system recommending an irreversible action must not share the same release threshold. Put that choice in a short architecture decision record containing context, alternatives, evidence, assumptions, selected policy, rollout, reversal trigger, and unresolved risk. Link the evaluation snapshot and source versions. This document prevents a benchmark from becoming folklore and tells the next engineer which evidence must be repeated when the model, provider, traffic, data, regulation, or product promise changes.

Monitor leading and lagging signals after release. Leading signals reveal pressure—queue age, cache allocation, disagreement, validation failure, policy denial, or retry growth—before users report harm. Lagging signals show whether the job was actually completed and trusted. Alert on a service objective tied to user consequence, and make the run identifier available to support without exposing private content. Every serious miss should become a reproducible regression case and, when relevant, a new threat or data-quality control.

09 / 09

Primary sources and further reading

  1. TruthfulQA: Measuring How Models Mimic Human FalsehoodsOriginal research paper · paper
  2. Retrieval-Augmented Generation for Knowledge-Intensive NLP TasksOriginal research paper · paper
  3. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence ProfileNational Institute of Standards and Technology · standard

Written by

Vishal RajpurohitCo-founder & CTO, ViitorCloud

Co-founder & CTO of ViitorCloud · Founder of LaraCopilot · Organizer of Laracon India · Shipping production software since 2005

More about Vishal