In this post
Why do language models hallucinate?
A model predicts the next piece of text from patterns in its training data. When it lacks the facts, it can still produce a fluent answer, and nothing inside it checks that answer against a source. Gaps in its knowledge and ambiguous questions make this more likely.
What do hallucinations look like?
Typical cases are invented references, made-up functions or settings in code, wrong numbers presented precisely, and details of a document that was never provided. They are hard to spot because the tone is the same as for correct answers.
How does retrieval help?
Giving the model relevant source text and asking it to answer from that text, with citations, grounds the answer in something checkable. It reduces hallucination but does not remove it, because the model can still misread or ignore the source. See RAG explained.
What prompt and design choices help?
Ask for answers only from the supplied material, allow “I don’t know” as a valid reply, and request quotations that can be matched against the source. Lower sampling randomness for factual tasks, and break large tasks into smaller checked steps.
How should output be checked?
Verify claims against the source, run generated code and its tests, and sample answers for human review. For high-stakes uses, such as legal, medical or financial content, a person should confirm the result before anyone relies on it.
Can hallucination be eliminated?
Not today. It can be reduced and made detectable, so the aim is to design the system so that a wrong answer is caught before it causes harm. Measure the rate on your own questions, and keep measuring after each change.
Sources and further reading
- Ji et al. Survey of Hallucination in Natural Language Generation. ACM Computing Surveys, 2023.
- NIST. AI Risk Management Framework. nist.gov/itl/ai-risk-management-framework.
IICTP is an independent technical credentialing body.