Programming
We provide developers and engineers the guides and tutorials they...
Search
We provide developers and engineers the guides and tutorials they...
Content is king. It's not just about how you're going to write, b...
Looking for an engaging connection with thousands of other people...
Why AI language models make things up: next-token prediction, missing knowledge, training incentives and sampling, plus practical ways to reduce it.
Quick answer: A language model generates text by predicting plausible next words. It was trained to produce text that looks like its training data, not to check statements against the world. Most of the time, plausible and true are the same thing. When the model lacks the relevant knowledge, the same process still produces a fluent, confident answer, because nothing in it distinguishes "I know this" from "this sounds right". The result is a hallucination: an invented fact, citation, quote or function name. Hallucinations can be reduced a great deal by giving the model the source material and tools it needs, but not removed entirely.
Also Read: How Tokenization Works and Why It Affects AI - How To's
The term covers output that is fluent and confident but false or unsupported. Researchers, as in A Survey on Hallucination in Large Language Models, usually separate two kinds:
| Type | Meaning | Example |
|---|---|---|
| Factuality hallucination | Contradicts real-world facts, or cannot be verified | Citing a court case that does not exist |
| Faithfulness hallucination | Contradicts the user's instructions or the supplied document | A summary that includes a claim the source never made |
Typical forms:
Some people prefer the word "confabulation", since the model is not perceiving anything. "Hallucination" is the term that stuck.
As explained in how LLMs predict the next word, a model outputs a probability for each possible next token and picks one. There is no database of facts inside it and no step where a claim is checked.
What it knows is stored as patterns in its weights: a lossy, compressed impression of its training text. Facts that appeared thousands of times are captured firmly. Facts that appeared once or twice are captured faintly, or blended with similar ones.
So when you ask for the title of an obscure researcher's 2014 paper, the model produces something with the right shape: a believable title, a believable journal, a believable year. It is generating the most likely text of that kind, which is not the same as retrieving a record.
When a person does not know something, they usually notice. A language model has no such built-in signal available to it by default. The process that produces a correct, well-supported answer is the same process that produces a fabricated one, and both come out equally fluent.
A model's internal probabilities do carry some information about uncertainty, but confident-sounding prose is not a reliable guide to it.
Model developers now train deliberately for calibrated refusals: saying when information is missing or uncertain. That has improved matters significantly, but the tension between being helpful and being cautious remains.
The most effective technique is to put the relevant source text in the prompt and ask the model to answer from it. This is retrieval-augmented generation, introduced in the paper Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. The model's job shifts from recalling to reading. See how RAG works.
Let the model run a web search, query a database, call a calculator or execute code, then answer from the results. See how AI agents use tools.
Have the model quote the passage that supports each claim, or cite the document it came from. Claims with no supporting quote can be dropped or flagged.
Also Read: Transformers Explained: The Architecture Behind AI
Explicitly state that "the documents do not say" is an acceptable answer. This simple instruction prevents a lot of invention.
For choosing among approaches, see fine-tuning vs prompting vs RAG.
Not completely. A system that generates language from learned patterns will sometimes produce something false. Even with the right document in front of it, a model can occasionally misread or over-generalise.
The same ability that causes hallucination is also what makes these models useful: producing new text that was not in the training data. Writing a story, drafting an email or proposing a design all require going beyond stored facts. The aim is to keep that flexibility while anchoring factual claims to evidence.
Rates have fallen substantially as models, training methods and tooling have improved, and well-grounded systems can be very reliable. The sensible stance is to treat unsupported model output as a draft from a knowledgeable but fallible assistant.
Output from a model that is presented confidently but is false, fabricated or not supported by the provided sources.
They learned what citations look like and generate text in that format. Without access to a real database of sources, the result can be a plausible invention.
It reduces randomness but does not fix missing knowledge. A model can be consistently wrong at temperature zero.
It reduces them substantially by supplying real source material. Errors can still occur if retrieval returns the wrong passages or the model misreads them.
Language models hallucinate because they are built to produce plausible text, and plausibility is not truth. They have no automatic sense of the edge of their knowledge. The practical response is to supply what they need: source documents, tools, permission to abstain, and a verification step. Do that, and the problem shrinks from a deal-breaker to a manageable risk.