Why LLMs Hallucinate
What if the answer has page numbers, and the paper doesn't exist? Navika asks a chat assistant for a study showing that AI raises fruit sales, for a school project. She gets a confident answer with a title, a journal, a year and page numbers. She searches for it, and finds nothing. The assistant made it up.
That is a hallucination. This lesson explains why LLMs produce them, and how to catch them before they cause trouble.
What a Hallucination Is
A hallucination is an output that sounds fluent and confident but is false or unsupported: an invented fact, quote, source, number or event.
The citation in the picture is an invented example, written to show the kind of answer a model can produce.
Why It Happens
| Cause | What it means |
|---|---|
| It predicts what fits, not what is true | Next-token prediction, from "How an LLM Generates Text", picks likely text; a realistic-looking citation is very likely text |
| Gaps in its training data | When it never saw the answer, it still produces something that fits the pattern |
| Knowledge cutoff | It doesn't know events after its training data ended |
| Pressure to answer | Models are trained to be helpful, and may produce an answer rather than say "I don't know" |
| Misread context | It may mix up details from your prompt or documents |
Hallucinations are most likely for: specific sources and quotes, exact numbers and dates, niche or very recent topics, and details about people who aren't famous.
Protecting Yourself
| Habit | How |
|---|---|
| Ask for sources, then open them | A link or citation you haven't opened isn't evidence |
| Check numbers and dates | Against an official or original source |
| Ask it to say when it isn't sure | "If you don't know, say so" reduces, but doesn't remove, invented answers |
| Give it the source | Paste the document and ask it to answer only from it; see "Grounding Prompts in Sources" |
| Match checking to the stakes | Health, money, law and anything about real people always need verifying |
Common Mistakes
Trusting an answer because it is detailed. Page numbers and author names can be invented as easily as anything else.
Thinking a newer model never hallucinates. Hallucinations become rarer as models improve, but they still happen.
Asking the same model "Are you sure?" as the only check. It may confidently confirm its own mistake; check an independent source.
Interview Corner
What is a hallucination in an LLM?
A fluent, confident output that is false or unsupported, such as an invented fact, number, quote or citation.
Why do LLMs hallucinate, and how do you reduce it?
They generate text that fits learned patterns rather than retrieving verified facts, so gaps, cutoffs and pressure to answer lead to invented content. Reduce it by grounding the model in source documents, asking it to admit uncertainty, using search tools, and verifying important outputs against independent sources.
Practice
Exercise: catch a hallucination. Ask a chat assistant for three research papers, with authors and years, on a narrow topic you know. Look up every one. How many exist exactly as described? Then repeat with the instruction "If you are not sure a paper exists, say so" and compare.
Check your understanding:
- What makes something a hallucination rather than a typo?
- Why does next-token prediction lead to invented citations?
- Name three habits that protect you.
Key Takeaways
Quick reference
| Term | Meaning |
|---|---|
| Hallucination | A confident output that is false or unsupported |
| Grounding | Giving the model source material to answer from |
| Verification | Checking an output against independent sources |
Was this tutorial helpful?