Skip to main content

Hallucinations & How to Reduce Them

Intermediate
What you'll learn
  • Understand WHY models fabricate confident, well-formed answers
  • Recognize the 5 high-risk zones where you should be most skeptical
  • Apply a 6-part toolkit to drastically reduce hallucinations
  • Use one copy-paste anti-hallucination prompt that grounds, gives an out, and forces citations
  • Adopt the mindset that matches verification effort to the cost of being wrong

A hallucination is when a model states something false with complete confidence. It's not lying and not broken — it's the flip side of how LLMs work: they generate plausible text, and plausible isn't always true (see What Is an LLM?). You can't prompt this away entirely, but you can drastically reduce it and catch the rest.

Why it happens

The model predicts a likely continuation. When it doesn't "know" something, the most likely-looking continuation is often a confident, well-formed — and wrong — answer. There's no built-in "I'm unsure" signal unless you create room for one.

Pro tip
  • The fix for most hallucinations is to deliberately create room for uncertainty — give the model permission to say it doesn't know.

The high-risk zones

Be most skeptical when output involves:

  • Citations, quotes, and references — fabricated papers, fake URLs, misattributed quotes.
  • Specific numbers, dates, and stats — plausible but invented figures.
  • Niche or very recent facts — beyond what the model reliably learned.
  • APIs and library details — methods or parameters that don't exist.
  • People and legal/medical specifics — high stakes, easy to get subtly wrong.

The reduction toolkit

Stack these — each one helps:

Guided walkthrough1 of 6
  1. Paste the source text and say "answer only from the text above; if it's not there, say so." This is the core idea behind RAG (/docs/foundations/rag).

A copy-paste anti-hallucination prompt

Most of the toolkit above collapses into one reusable wrapper. Paste your source where shown and ask your question — it grounds the answer, gives the model an out, and forces citations in a single shot:

Anti-hallucination wrapper

You answer ONLY from the SOURCE below.
Rules:
- If the answer is not in the SOURCE, reply exactly: "Not stated in the source."
- After every claim, quote the exact sentence from the SOURCE that supports it.
- Do not add outside knowledge, estimates, or assumptions.

SOURCE:
"""
[paste the document, transcript, or data here]
"""

QUESTION: [your question]

Why it works: the "Not stated in the source" escape hatch removes the pressure to guess, and the quote-the-sentence rule makes any unsupported claim impossible to hide. Drop the SOURCE block when you genuinely want the model's own knowledge — but then verification is back on you.

The mindset that actually protects you

Watch out
  • No prompt makes output 100% reliable. For anything consequential — a number in a report, a citation, a command you'll run, a medical/legal/financial detail — check it against a trusted source. Treat AI as a fast first draft, not a final authority. This is the heart of Responsible Use (/docs/security/responsible-use).

A simple rule: the cost of being wrong sets the amount of verification. Brainstorming? Trust freely. Publishing a statistic? Verify every time.

Key takeaways
  • Hallucinations are a byproduct of plausibility-based generation, not a bug you can fully prompt away.
  • Be most skeptical with citations, numbers/dates, niche or recent facts, API details, and people/legal/medical specifics.
  • Stack the toolkit: ground in sources, give an out, demand citations, lower temperature, use tools, cross-check.
  • One wrapper prompt grounds + gives an out + forces citations in a single shot.
  • Match verification effort to the cost of being wrong — trust freely when cheap, verify every claim when consequential.

Check yourself

0/5
  1. Why do models hallucinate?
  2. Which of these is a high-risk zone where you should be most skeptical?
  3. What is the single most direct effect of giving the model an explicit out like "If you're not sure, say 'I don't know'"?
  4. What rule decides how much verification an answer needs?
  5. In the anti-hallucination wrapper prompt, what makes any unsupported claim impossible to hide?

Next