AI Hallucinations
When the LLM invents information that sounds credible but is wrong. The #1 problem in AI products — and here are 9 proven techniques to reduce it.
What a hallucination is
A hallucination is when a language model produces information that is wrong or made up — with full confidence. It will invent a fact, a quote, a number, a link or a name, and phrase it in a completely convincing way. It's dangerous precisely because it sounds credible.
Examples: inventing a law that doesn't exist, citing a study that was never written, giving a wrong product price, or "remembering" a company policy that never existed.
In a personal chat a hallucination is a nuisance. In a product (support, advice, legal, medical) — it can cause real harm and erode trust. Reducing hallucinations is the heart of AI Engineering.
Why it happens
This isn't a "bug" — it's built-in behavior. A language model doesn't retrieve facts from a database; it predicts the statistically likely next word based on the patterns it saw in training. When it has accurate information — it's accurate. When it doesn't — it still produces something that sounds right, because that's what it does. It "prefers" a fluent answer over "I don't know."
So the solution isn't just a "smarter model," but proper engineering: give it a real source, and let it say it doesn't have an answer.
Types of hallucination
- Factual: a wrong fact about the world (a date, a number, a name).
- Faithfulness: contradicting the source provided — e.g. in RAG, the model says something not written in the retrieved passage.
- Fabricated citations: sources, links or studies that don't exist.
- Wrong instructions: "inventing" a step in a process or an API parameter that doesn't exist.
9 proven techniques to reduce them
- Grounding / RAG. The most effective. Give the model the relevant information via RAG and instruct it to answer only from it.
- Allow "I don't know." Add to the prompt: "If the answer isn't in the context, say you don't know and offer to hand off to a human." This changes everything.
- Require citations. Ask that every claim point to a source passage. No source — no claim. It also makes verification easier.
- Low temperature (0–0.3). For factual tasks. Less "creativity" = fewer fabrications.
- Structured output + validation. A JSON schema limits the output space, and validation on your side catches invalid values.
- Self-consistency. For critical tasks — run several times and compare. If the answers contradict, that's a red flag.
- A verification step. A second model (or code) checks the answer against the source before showing it to the user.
- Clear, narrow instructions. A vague prompt invites guessing. Define the scope, format and constraints.
- Hallucination evals. Measure the hallucination rate with evals (e.g. an LLM-judge that checks faithfulness to the source), so you know whether you improved.
Grounding in a source + permission to say "I don't know" eliminate most hallucinations. That's the starting point of any factual system.
Defense layers in a real system
In a critical product you don't rely on a single technique — you build several layers:
- Prevention: RAG + instructions + low temperature.
- Control: output validation and verification against the source.
- Boundaries: Guardrails that block answers on sensitive topics without a source.
- Measurement: Evals and monitoring in production to catch hallucinations that slip through.
- Human in the loop: for high-risk decisions — human approval before acting.
Next step
The #1 technique is grounding. Learn RAG in depth, and add control with guardrails and evals.