Phase 5 · Grounding & KnowledgeModule 18~32 min read

Why Models Hallucinate — and How to Ground Them

Models make things up with total confidence. Understand why hallucination happens and the prompting moves that keep answers tied to real, provided facts.

What you'll learn

The most notorious failure mode of language models is the hallucination: a fluent, confident statement that is simply false. It isn't a glitch — it's a direct consequence of how models work. This phase is about the single best cure: grounding the model in real, provided facts.

By the end of this module you'll be able to:

  • Define hallucination and explain why next-token prediction causes it
  • Ground answers in context you provide, dramatically cutting made-up facts
  • Prompt for citations and honest "I don't know" responses
  • Spot the situations where hallucinations are most likely

What a hallucination is

A hallucination is output that is presented as fact but isn't true — an invented statistic, a fake citation, a nonexistent function, a plausible-but-wrong date. The danger isn't that the model is obviously confused; it's that hallucinations are fluent and confident, so they slip past a casual reader.

Why next-token prediction invents facts

Recall Module 2: a model generates the most plausible-sounding continuation, not a verified one. When it doesn't actually "know" something, the statistically likely next tokens still form a confident-looking sentence — so it produces one. The model has no built-in sense of "I'm not sure" unless the prompt gives it room to say so.

Hallucinations spike when…Because…
You ask about niche or obscure factsSparse training signal — the likely continuation is a guess
You ask about events after the training cutoffThe model simply has no data, but still completes the text
You demand a specific detail (a date, a quote, a source)It fills the slot with something plausible rather than leaving it blank
The prompt provides no grounding contextThere's nothing to anchor the answer to
Every trigger is the same root cause: the model produces likely text even when it lacks the facts.

Grounding in provided context

The fix is to stop relying on the model's memory and instead hand it the facts in the prompt, with an instruction to use only those. This is "open-book" prompting — and it's the idea that RAG (next module) automates at scale.

✗Weak prompt

Prompt

What is the refund window for TaskFlow Pro?

Response

TaskFlow Pro offers a 30-day money-back guarantee — if you're not satisfied within 30 days, contact support for a full refund. (…confident, and entirely invented.)
✓Strong prompt

Prompt

Using ONLY the policy below, answer the question. If it's not covered, say "Not specified." Policy: "Refunds are available within 14 days of purchase. After 14 days, sales are final." Question: What is the refund window for TaskFlow Pro?

Response

Refunds are available within 14 days of purchase; after that, sales are final.
Left: no context, so the model invents a plausible '30 days'. Right: given the real policy, it answers correctly — 14 days.

Key idea

The most reliable anti-hallucination move is to provide the facts and constrain the model to them: "Answer only from the text below." You turn a memory test into a reading-comprehension task, which models do far more reliably.

Citations & "I don't know"

Two prompt habits make grounding even stronger. First, give the model explicit permission to decline (Module 5): "If the answer isn't in the context, say so." Second, ask it to citewhich part of the context it used — this both helps you verify and discourages it from drifting off-source.

Prompt

Answer from the context and quote the exact sentence you used. If unsupported, reply "Not in the document." Context: "The workshop runs from 9am to 12pm. Lunch is not provided." Question: Is lunch included?

AI response

No — lunch is not included. Supporting quote: "Lunch is not provided."
Requiring a supporting quote makes the answer checkable and keeps the model anchored to the source.

Spotting hallucinations

Until grounding is airtight, stay skeptical. Red flags to watch for:

  • Oddly specific, unverifiable details — exact figures or dates with no source.
  • Citations you can't find — plausible-looking papers, URLs, or quotes that don't exist.
  • Answers to impossible questions — confident replies about the future or private data.
  • Overconfidence on the obscure — the more niche the topic, the more you should verify.

Watch out

Grounding reduces hallucination; it doesn't eliminate it. A model can still misread provided context or blend it with training memory. For high-stakes answers, keep a human check and require citations you can actually follow.

Recap & quick check

Key takeaways

  • A hallucination is confident, fluent output that is factually wrong — dangerous precisely because it sounds right.
  • It happens because the model produces plausible-sounding text, not verified facts, and defaults to guessing when unsure.
  • The best fix is grounding: provide the facts in the prompt and instruct the model to use only them.
  • Give an explicit 'say I don't know' path and require citations to keep answers anchored and checkable.
  • Grounding reduces but doesn't remove hallucination — verify high-stakes answers and stay skeptical of unsourced specifics.

Quick check

1. Why do language models hallucinate?

2. What is 'grounding' a model?

3. Which habit makes a grounded answer easiest to verify?

4. When are hallucinations MOST likely?

Grounding by hand works for one document. To ground a model in thousands, you retrieve the right passages automatically. Next up: Module 19 — Retrieval-Augmented Generation (RAG).