A hallucination isn't a bug in the traditional sense — it's the exact same next-token-prediction mechanism that makes an LLM useful at all, applied to a case where no reliable pattern actually exists. Understanding why makes it predictable, and defensible against, instead of mysterious.
3 min read
An LLM never has a "know" vs. "don't know" flag — the next-token-prediction mechanism from two lessons ago always produces some plausible-sounding continuation, whether or not the underlying claim is true. A hallucination is a fluent, confident, statistically plausible response that is factually wrong or entirely fabricated — and it happens for the exact same reason correct answers happen: the model is predicting what's statistically likely to come next, not verifying a fact against a source of truth. There is no separate "fact-checking module" being bypassed; there was never a fact-checking step in the mechanism to begin with.
If hallucination comes from the model generating from its own trained-in patterns with no grounding, the most direct fix is: don't make it rely purely on memory — retrieve actual, verified source documents and include them directly in the context, then instruct the model to answer strictly based on what's provided (the RAG pattern the next lesson covers). This doesn't eliminate hallucination entirely (a model can still misread or overstate what a retrieved document actually says), but it meaningfully grounds the answer in a specific source that can be checked, rather than in unverifiable trained-in statistical patterns alone.
Never present raw, ungrounded LLM output as verified fact in any feature with real consequences for being wrong — this is precisely why the AI Agents & LLM Integration domain treats a propose-then-confirm pattern (the model proposes an action or answer, a human or a deterministic check confirms it before anything real happens) as a foundational, non-optional design principle for any AI feature that writes data or states facts a user will rely on.
Check your understanding
A quick comprehension check — not tracked, not graded, just for you.
1. Why does an LLM hallucinate instead of simply saying 'I don't know'?
2. Why can an LLM generate a fake but realistic-looking citation?
3. Why is RAG considered the most direct practical mitigation for hallucination?
AI & ML Fundamentals