How to Actually Prevent AI Hallucinations: The Methods, Ranked
A while back I wrote about why AI hallucinates: it predicts plausible tokens, it was trained on incentives that reward a confident guess over an honest “I don’t know,” and so it will invent a citation, a court case, an API that doesn’t exist, and hand it to you with a straight face.
That post answered why. This one is the other half, and the more practical half: what do you actually do about it?
Because “add some guardrails” is not a plan. There are roughly ten distinct methods to reduce hallucination, and they are wildly different tools. One is nearly free and you should always use it. One multiplies your inference bill by ten. Some fix the problem at the root; others just paper over it so it’s harder to notice. If you reach for the wrong one, you spend a lot and fix little.
So this is the ranked, opinionated tour. For each method: how it works, what it genuinely costs, what it can’t do, and when it’s the right call.
First cut: fix the root, or hide the symptom?
Before the list, one distinction that sorts everything else. Some methods reduce hallucination by giving the model better information to work with. Others let it hallucinate freely and then try to catch the bad output on the way out. Both are useful. They are not the same thing.
Root fixes (upstream)
Change what the model has to work with before it generates. Give it the real document, the calculator, the current fact. It hallucinates less because it's guessing less.
RAG, tool use, fine-tuning, better prompts
Symptom catches (downstream)
Let it generate, then inspect the output and block, flag, or fix what looks wrong. Necessary, but it's cleanup: the model still made the thing up, you just caught it.
Verifier chains, guardrails, abstention, human review
Keep that split in mind. When people say “we added hallucination protection” and mean a single output filter, they’ve done the cheaper, weaker half and skipped the part that actually moves the numbers.
The whole toolkit, at a glance
Here’s every method side by side before we go deep. Read the cost column carefully: it’s the part most guides gloss over.
| Method | What it does | Cost / latency | Fixes root? |
|---|---|---|---|
| RAG / grounding | Retrieve real docs, answer from them | 1 retrieval + bigger prompt | Yes |
| Cite + verify | Check each claim against the source | +1 model pass | Catch |
| Prompt technique | CoT, "say I don't know", decompose | near free | Partial |
| Self-consistency | Sample N times, majority vote | N times inference | Catch |
| LLM-as-judge | A second model scores the first | +1 (bigger) call | Catch |
| Guardrails / schema | Force valid structure, enforce rails | cheap to moderate | Format only |
| Factuality fine-tuning | Train the weights toward truth | high upfront, free at run | Yes |
| Abstention / uncertainty | Measure doubt, decline when high | often N times sampling | Catch |
| Human-in-the-loop | A person signs off risky output | slow, labor cost | Catch |
| Tool use / KG | Offload facts to calculator, search, graph | extra tool calls | Yes |
Now the deep version. I’ve grouped them root-fixes first, catches second, roughly in the order you’d actually adopt them.
1. RAG: give it the facts instead of asking it to remember
The single biggest lever, and the first thing to reach for. Instead of hoping the answer is buried somewhere in the model’s weights, you retrieve the relevant documents at question time and put them right in the prompt. The model reads facts instead of recalling a fuzzy impression of them.
The honest caveat, which too many RAG guides skip: retrieved does not mean correct. Feed it the right document and a model can still revert to its own invented version, or the retriever fetches the wrong passage entirely. RAG drives hallucination way down; it does not abolish it. Which is exactly why you layer the next methods on top. (I went deep on doing RAG well in the RAG design post.)
2. Cite, then actually verify the citation
RAG gets the docs in front of the model. This layer makes it accountable to them. You require a source for every claim, then you check that the source actually says what the model claims it says. That check is the important part, a citation nobody verifies is just decoration.
The cost here is concrete: one extra classifier or LLM call per response, sometimes per claim. That’s latency and money on every single answer. Worth it when a wrong claim is expensive; overkill for a casual chatbot.
3. Prompt techniques: the nearly-free baseline
Before you spend anything, spend words. Three prompt moves genuinely reduce hallucination at almost zero cost. Chain-of-thought (“think step by step”) makes the model reason before answering. Explicitly permitting “I don’t know” gives it an exit that isn’t fabrication. And decomposition, breaking a hard question into checkable pieces, stops it from bluffing through a leap it can’t make.
The only real cost is tokens: chain-of-thought makes the model write more, which is a bit more latency and spend. Cheap insurance.
4 and 5. Sample-and-vote, and the second-opinion model
Two catches that both work by not trusting a single generation.
Self-consistency samples the same question several times and takes the majority answer. If the model lands on “42” four times out of five, that’s a stronger signal than one lucky (or unlucky) roll. LLM-as-judge uses a separate, often stronger model to score the first one’s output for factuality before it ships.
The catch, literally, is cost. Self-consistency multiplies your inference by however many samples you draw, five, ten, more. A judge adds a full (and usually larger, pricier) model call per answer. These buy real accuracy, and they buy it by the token.
6. Guardrails and schema-constrained decoding: structure, not truth
This one is widely misunderstood, so let me be blunt about what it does and doesn’t do. Constrained decoding forces the output to match a grammar or JSON schema, so you can’t get an invalid enum or a missing field. Guardrail frameworks add programmable input and output rails: topic boundaries, policy checks, validators.
Here’s the trap: constrained decoding guarantees the output is well-formed, not that it’s true. The model can hand you perfectly valid JSON with a completely invented value inside it. Structure is not fact.
7. Factuality fine-tuning: bake truth into the weights
Everything so far happens at inference. This one changes the model itself. You build preference pairs that reward factual answers over confident-but-wrong ones and train on them (the FactTune work does this with DPO and no human labels). The payoff is unusual: the cost is entirely upfront, and inference stays cheap.
8. Know when it doesn’t know: uncertainty and abstention
A different idea entirely: instead of trying to make every answer right, measure how sure the model is and let it decline when it isn’t. The elegant version is semantic entropy (a 2024 Nature result): sample several answers, cluster the ones that mean the same thing, and measure the spread of meanings. High spread means the model is confabulating, low spread means it’s confident. SelfCheckGPT does a black-box cousin of this by checking whether repeated samples agree.
9 and 10. The human, and the tool
Two last methods that bookend the list.
Human-in-the-loop is the highest-reliability option and the least scalable: route the risky, low-confidence, or flagged outputs to a person before they’re final. It’s slow and it costs labor, and humans have their own failure mode (they wave through fluent, wrong text because it reads well). The trick is not to review everything, but to review only what your uncertainty method (method 8) flagged.
Tool use and knowledge graphs attack the root from a different angle: stop asking the stochastic model to be a database. Let it call a calculator for arithmetic, a search API for current facts, a knowledge graph for structured relations. The exact facts live in deterministic systems; the model just orchestrates. This is why a model that’s hopeless at mental math becomes reliable the moment you give it a code tool.
So what do you actually build?
You don’t pick one. Every serious production system layers several, cheapest and most-fundamental first, because each catches a different failure.
The takeaway
Preventing hallucination isn’t one trick, it’s a budget decision. The cheap methods (good prompts, schema constraints) are worth doing always but only get you part way. The strong methods (RAG, tool use, verification, fine-tuning) cost retrieval calls, extra model passes, training runs, or human time, and you spend those where being wrong is expensive.
The mistake I see most is teams bolting a single output filter onto an ungrounded model and calling it solved. That’s the weakest, most downstream layer doing all the work. Start upstream. Give the model the facts, let it admit doubt, and only then spend on catching what slips through. Do that and you don’t eliminate hallucination, nobody does, but you push it from “the reason we can’t ship” to “a managed, measured risk.”
This is the methods companion to Why AI Hallucinates, and How We Actually Stop It. For the grounding layer in depth, see Designing a RAG System That Actually Retrieves.
References
Written from scratch; these are the primary sources behind the methods and numbers above. Nothing here is copied from them.
- Chain-of-Thought Prompting, Wei et al., 2022: https://arxiv.org/abs/2201.11903
- Self-Consistency Improves Chain of Thought, Wang et al., 2022: https://arxiv.org/abs/2203.11171
- Self-Refine: Iterative Refinement with Self-Feedback, Madaan et al., 2023: https://arxiv.org/abs/2303.17651
- Retrieval-Augmented Generation, Lewis et al., 2020: https://arxiv.org/abs/2005.11401
- SelfCheckGPT, Manakul et al., 2023: https://arxiv.org/abs/2303.08896
- Detecting hallucinations with semantic entropy, Farquhar et al., Nature 630:625-630, 2024 (probes follow-up: https://arxiv.org/abs/2406.15927)
- Fine-tuning Language Models for Factuality (FactTune), Tian et al., 2023: https://arxiv.org/abs/2311.08401
- Judging LLM-as-a-Judge, Zheng et al., 2023: https://arxiv.org/abs/2306.05685
- TruthfulQA, Lin et al., 2021: https://arxiv.org/abs/2109.07958
- AWS Bedrock, contextual grounding check: https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-contextual-grounding-check.html
- AWS Bedrock, Automated Reasoning checks: https://aws.amazon.com/blogs/aws/minimize-ai-hallucinations-and-deliver-up-to-99-verification-accuracy-with-automated-reasoning-checks-now-available/
- Azure AI Content Safety, groundedness detection: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/concepts/groundedness
- Google Vertex AI, grounding overview: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/grounding/overview
- OpenAI, Structured Outputs: https://developers.openai.com/api/docs/guides/structured-outputs
- Vectara HHEM hallucination leaderboard: https://github.com/vectara/hallucination-leaderboard