An AI hallucination is an answer that sounds fluent and confident but is wrong, made up or unsupported. A chatbot might invent a book that does not exist, give a wrong date, or cite a legal case that was never decided. Hallucinations are one of the most important limits of today's language models, and learning to handle them is essential for anyone who uses AI for real work.
Why hallucinations happen
A language model is trained to predict plausible next words, not to look up verified facts. That has several consequences.
- Plausible is not the same as true. If a sentence looks like something that could be written, the model may produce it even when no fact supports it.
- Gaps in knowledge. The model may never have seen the information, or only saw it rarely. Instead of saying "I do not know", it fills the gap with a guess.
- Outdated information. Models are trained up to a cut-off date and do not automatically know about later events.
- Ambiguous questions. Vague prompts push the model to assume details.
- Pressure to answer. Models are often tuned to be helpful, which can discourage admitting uncertainty.
- Long contexts. In very long conversations, early details can be lost or confused.
Typical forms of hallucination
- Invented sources: fake book titles, research papers, quotes or web links.
- Wrong details inside a correct story: right topic, wrong name, number or date.
- Confident calculations that are off: arithmetic or unit conversions done "in the head".
- Fabricated code: functions, libraries or options that do not exist.
- False summaries: a summary that adds claims not in the original document.
How to spot a hallucination
Look for warning signs.
- Very specific details with no source, such as exact percentages, page numbers or case numbers.
- Citations you cannot find when you search for the title or link.
- Answers that agree too easily with a wrong premise in your question.
- Different answers when you ask the same question twice.
- Internal contradictions between one paragraph and another.
A fast test is to ask the same question in a different way, or ask the model "How sure are you, and what would you check to verify this?" Neither is a guarantee, but inconsistent answers are a red flag.
Practical ways to reduce hallucinations
1. Give the model the facts
Paste the relevant document, data or policy into the prompt and instruct: "Answer only using the text below. If the answer is not there, say you cannot find it." This is the idea behind retrieval-augmented generation and is one of the most effective methods.
2. Allow "I do not know"
Add explicit permission: "If you are unsure, say so instead of guessing." Models often follow this instruction well.
3. Ask for sources, then check them
Request references, but treat them as leads, not proof. Open each link and confirm that it says what the model claims.
4. Break big questions into steps
A complex task answered in one go gives more room for error. Ask for an outline, then fill in each part, and check as you go.
5. Keep the context focused
Start a new chat for a new topic and remove irrelevant text. Fewer distractions reduce confusion.
6. Use tools for exact tasks
For calculations, dates, database lookups or current information, use a calculator, code execution or a search tool instead of relying on memory.
7. Lower the randomness
In applications you can reduce the temperature setting so that the model chooses more predictable words. This helps consistency, though it does not remove wrong facts.
8. Verify important output
For health, legal, financial or safety matters, always confirm with an authoritative source or a qualified professional.
A simple verification workflow in code
Developers can add a lightweight check that flags answers not supported by the supplied text. The example below asks a model to answer from a document and then to quote the supporting sentence:
import anthropic
client = anthropic.Anthropic()
DOC = "Our shop is open from 9 am to 6 pm, Sunday to Friday. Delivery inside Kathmandu is free above 2000 rupees."
def grounded_answer(question: str) -> str:
prompt = (
"Answer the question using ONLY the document. "
"Then add a line 'Evidence:' with the exact sentence you used. "
"If the document does not contain the answer, reply exactly: NOT IN DOCUMENT.\n\n"
f"Document:\n{DOC}\n\nQuestion: {question}"
)
reply = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=200,
messages=[{"role": "user", "content": prompt}],
)
return reply.content[0].text
print(grounded_answer("Is the shop open on Saturday?"))
Requiring evidence makes it easier for a person, or another script, to check that the quoted sentence really appears in the source.
When hallucinations matter most
The risk grows with the cost of being wrong. A wrong movie recommendation is harmless; a wrong medicine dose or a wrong legal clause is not. As a rule, use AI freely for drafting, brainstorming and explaining, and add human verification wherever people, money or safety are involved.
Frequently Asked Questions
Can hallucinations be eliminated completely?
Not at present. They can be reduced with good prompts, grounding in trusted documents and verification, but no current model is perfectly reliable.
Do newer models hallucinate less?
Often they do, but the problem remains. Always check important claims regardless of which model you use.
Why does the AI sound so confident when it is wrong?
It is trained to produce fluent, natural text. Fluency and accuracy are separate qualities, so a wrong answer can sound exactly as sure as a right one.
Is searching the web with AI safer?
It can help because answers are based on retrieved pages, but the model can still misread or misquote sources, so open the links yourself.
Conclusion
Hallucinations come from the way language models work: they generate likely text rather than verified truth. Give them reliable source material, allow uncertainty, ask for evidence and verify what matters. Treated as a fast but fallible assistant, AI is very useful.