What is AI hallucination, and why do LLMs make things up?
An AI hallucination is output from a language model that sounds confident and fluent but is false, unsupported or made up, such as an invented citation, a wrong date or a function that does not exist. It happens because models are trained to produce likely text, and a plausible falsehood can be very likely.
A hallucination is not a bug in one answer; it is the model doing exactly what it was trained to do in a situation where that goes wrong. The model writes the most plausible continuation. When it lacks the facts, plausible and true come apart.
Why do LLMs hallucinate?
LLMs hallucinate because they generate likely text rather than retrieve verified facts, and nothing in the basic mechanism checks the output against reality. A large language model stores knowledge as statistical patterns. For facts it saw many times, the pattern is strong and the answer is usually right. For rare facts, recent events, or specifics like page numbers and exact figures, the pattern is weak, but the model still produces fluent text in the right shape.
Training incentives make this worse. A 2025 paper from OpenAI researchers, "Why Language Models Hallucinate", argues that most benchmarks grade answers as simply right or wrong, so a model that guesses scores better than one that says "I don't know". Like a student who guesses on every multiple-choice question, models learn that confident guessing pays. The authors propose scoring that penalises confident errors more than abstentions.
What are the common types of hallucination?
| Type | Example | Why it happens |
|---|---|---|
| Fabricated fact | A wrong founding year or statistic | Weak or missing knowledge, filled with a plausible value |
| Fake citation | A real-sounding paper title, authors and DOI that do not exist | The model knows what citations look like, not which exist |
| Invented API or code | A library function that was never written | Plausible naming patterns from similar libraries |
| Unfaithful summary | A summary that adds a claim not in the source | Prior knowledge leaking into a task that should use only the input |
| Wrong reasoning | Correct-looking steps that reach a false conclusion | Each step is locally plausible; errors compound |
It helps to separate two kinds. Factuality errors contradict the world. Faithfulness errors contradict the documents you gave the model. Retrieval helps with the first; careful prompting and checking help with the second.
How can you reduce hallucinations?
You cannot eliminate hallucinations, but you can make them rare and catchable. The most effective techniques supply the facts, give the model permission to decline, and verify the output.
- 1Ground the answer in sourcesUse RAG or tool calling so the model reads the facts instead of recalling them.
- 2Allow "I don't know"Say explicitly that it is fine to answer "not in the provided documents". Models follow this much more often when told.
- 3Ask for quotes firstFor long documents, have the model extract the relevant quotes, then answer only from those quotes.
- 4Require citationsAsk the model to cite a passage for each claim, then check automatically that each cited passage exists and supports it.
- 5Lower the temperatureFor factual tasks a low temperature reduces odd, low-probability choices.
- 6Verify with codeValidate IDs, dates, URLs, prices and function names against real systems before showing them.
- 7Measure itBuild an eval set of questions with known answers, including some that should be declined, and track the error rate.
For high-stakes answers, add a second check: a separate model call, or a guardrail, that compares each claim against the source documents and flags anything unsupported.
Do newer models hallucinate less?
Generally yes, on the tasks they are tested on, but not to zero, and it varies by task. Larger and better-trained models know more facts and are more often trained to express uncertainty. Reasoning models can catch some of their own mistakes. They can also produce longer chains of confident reasoning, so a wrong premise can travel further. Measure on your own use case rather than relying on a general claim.
- Do: Treat model output about facts, numbers and citations as unverified until checked
- Do: Give the model the documents it needs, and tell it to use only those
- Do: Keep a set of questions it should refuse, and test that it does
- Avoid: Ask a model for sources without checking that the sources exist
- Avoid: Assume a confident tone means a correct answer
- Avoid: Rely on the model to know events after its training cutoff
Frequently asked questions
Why is it called hallucination?
The term describes a model perceiving and stating things that are not there. Some researchers prefer "confabulation", since the model is filling gaps with plausible inventions rather than perceiving anything, but "hallucination" is the common term.
Can RAG stop hallucinations completely?
No. Retrieval supplies relevant facts and greatly reduces made-up answers, but the model can still misread a passage, combine passages wrongly or add claims from its own training. Citations and automatic checks catch most of what remains.
How do I know if an AI answer is hallucinated?
Check specific claims against a trusted source, especially names, numbers, dates, quotes and citations. Ask the model to point to the exact passage that supports each claim; if it cannot, treat the claim as unsupported.
Does lowering temperature stop hallucinations?
It helps a little, because the model picks its most likely tokens, but it does not fix missing knowledge. A model at temperature 0 can still state a wrong fact confidently if that is its most likely continuation.
Last checked for accuracy on . Written by the solidcoder team.