LLM hallucinations: causes, detection and mitigation
LLMs hallucinate because training rewards a confident guess over saying I don't know. Ground answers in sources, check each claim, and gate risky actions.
An LLM hallucination is a confident answer that is false, or that contradicts the documents and instructions the model was given. Models do it because they predict plausible text, and because training and most benchmarks reward a guess over "I don't know". You cannot remove it entirely, so the practical approach has three parts: ground answers in real sources, check each claim before a user sees it, and make sure no costly action runs on an unchecked answer.
The answer that sounded right
As an illustration, picture an HR assistant at a 600-person company. An employee asks how many unused leave days carry over into next year. The assistant answers "up to 15 days, as per the leave policy", in a friendly tone, with the policy name spelled correctly. The real policy says 10. Nobody notices until March, when a dozen people have planned holidays around the wrong number.
Nothing in that answer looked broken. That is what makes hallucination harder than an ordinary bug: the output is fluent and wrong, and the reader has no signal that it is wrong.
This has already been tested in a tribunal. In Moffatt v. Air Canada (decided 14 February 2024), the airline's website chatbot told a customer he could apply for a bereavement fare after travelling, while the airline's own bereavement page said the policy did not apply to requests made after travel was complete. The British Columbia Civil Resolution Tribunal rejected the argument that the airline could not be liable for what its chatbot said, held it responsible for all information on its website, and ordered it to pay $812.02 in damages, interest and fees. (These details come from a law firm's summary of the decision; the tribunal's own site was not reachable when this was written.) The sum was small. The principle was not.
Two failures share one name
"Hallucination" gets used for two different things, and they need different fixes.
The first is a factual error: the model states something about the world that is untrue. A wrong date, an invented court case, a product feature that does not exist. NIST's Generative AI Profile (NIST AI 600-1, July 2024) uses the term confabulation for this, and defines it as the production of confidently stated but erroneous or false content by which users may be misled or deceived.
The second is a faithfulness error: the model had the right material in front of it and still contradicted it, ignored an instruction, or reasoned its way to a conclusion its own steps did not support. The survey by Huang and colleagues, published in ACM Transactions on Information Systems, splits the problem along exactly this line, into factuality hallucinations and faithfulness hallucinations, with subtypes such as context inconsistency and logical inconsistency.
The leave-policy example could be either. If the policy document never reached the model, it guessed from what leave policies usually say, which is a factual error filled in from memory. If the policy was in the prompt and the model still said 15, it was unfaithful to its context. You only find out which by looking at what the model actually received, which is why this distinction is practical and not academic.
| Type | What it looks like | Usual cause | First check to add |
|---|---|---|---|
| Factual error, no sources given | Invented citation, wrong date, made-up feature | Gap in what the model learned; pressure to answer anyway | Agreement across several sampled answers |
| Factual error, sources given | Answer cites a passage that is outdated or about something else | Retrieval found the wrong or stale document | Log and review the retrieved passages |
| Unfaithful to context | Correct passage present, answer contradicts it | Long or noisy context, weak instruction to stay inside it | Claim-by-claim check against the passages |
| Wrong number | Totals, percentages or dates that do not add up | The model doing arithmetic or recalling figures | Move the number into a tool or query |
Why models make things up
A language model is trained to predict the next piece of text. For facts that appear thousands of times in its training data, the most likely continuation and the true one are the same. For a rare fact (a mid-sized company's leave rule, a minor court ruling, someone's birthday) they come apart, and the model still produces the most plausible-looking continuation, because that is all it knows how to do.
A September 2025 paper by Kalai, Nachum, Vempala and Zhang, Why Language Models Hallucinate, makes a sharper argument about why this persists after all the extra training. They treat hallucinations as errors that arise from ordinary statistical pressure when false statements cannot be told apart from true ones, and then point at evaluation. Most benchmarks score a wrong answer and "I don't know" the same, as zero, so a model that guesses scores higher than one that abstains. In their words, models are optimised to be good test-takers. Their proposed fix is to change how existing benchmarks are graded, so that admitting uncertainty is no longer penalised.
I find this the most useful framing for anyone building on a model: the default behaviour is to answer, so if your product never gives the model a respectable way out, you will get guesses.
The Huang survey lists other contributors that show up in practice. Knowledge has a cut-off date, so anything that changed after training is missing or stale. Fine-tuning on answers the model does not actually know can teach it to sound sure. Preference training can make models agreeable, so they go along with a false premise in the question. And sampling randomness at higher temperatures makes low-probability, sometimes wrong, tokens more likely.
Most enterprise hallucinations start before the model
In company systems the model is rarely answering from memory. It is answering from retrieved documents, query results and tool outputs, as described in our RAG guide. That changes where errors come from. If retrieval hands the model last year's policy, a draft that was never approved, or a passage about a different product, the model will faithfully summarise the wrong thing. From the outside this still looks like a hallucination, and teams often spend a week tuning the prompt when the fault is in search.
Retrieval does reduce the problem. It does not end it. The Stanford team behind Hallucination-Free? (Magesh and colleagues, 2024) ran a preregistered test of AI legal research tools from two large legal publishers, products marketed on their reliability and built on retrieval. Each still produced hallucinated answers between 17% and 33% of the time. They hallucinated less than a general-purpose chatbot, but nowhere near zero.
So when an answer is wrong, the first question is what the model was given. If you cannot see the retrieved passages, the tool calls and the prompt version for that exact answer, you are debugging blind. CloudOEngine's AI runtime traces every agent step and tool call so each one can be inspected after the fact, which is where this kind of investigation starts. Retrieval quality itself is a separate fix: exact codes and policy numbers often need keyword matching alongside vectors, which we covered in hybrid search.
Catching them before the user does
Detection methods fall into two families, and which one fits depends on having sources to check against.
When the answer is supposed to come from documents, check it against those documents. Split the answer into individual claims, and for each one ask whether the retrieved passages support it. That question can be put to a small natural language inference model or to a second LLM call with a narrow prompt ("Does this passage state that unused leave up to 15 days carries over? Answer yes, no or not mentioned"). Claims with no support get flagged. This is cheaper and more reliable than asking a judge model "is this answer good?", because a narrow yes/no question about one sentence and one passage leaves less room for the judge to be impressed by fluent prose.
When there are no sources, you can use the model's own consistency. SelfCheckGPT (Manakul, Liusie and Gales, 2023) rests on a simple observation: if a model really knows something, answers sampled several times for the same prompt tend to agree; if it is guessing, they drift and contradict each other. It works on black-box models, with no access to internal probabilities.
Semantic entropy, published in Nature in 2024 by Farquhar, Kossen, Kuhn and Gal, refines this. It samples ten answers, groups the ones that mean the same thing (two answers land in the same group when each entails the other), and measures how spread out the groups are. Ten different wordings of one fact form one group and score as confident; three different facts score as uncertain. Averaged across 30 combinations of task and model, it reached an AUROC of 0.790 against 0.691 for plain entropy over the raw text. It targets the arbitrary errors that change with the random seed, not errors the model makes the same way every time, so it is not designed to catch a falsehood the model has firmly learned.
Both consistency methods cost several extra model calls per answer. That is too expensive for every chat message in most products, but reasonable for answers that feed a decision, or as a nightly sample over production traffic to estimate your error rate.
Whatever you detect, feed it back. Every flagged answer is a test case for the next prompt or retrieval change. Our article on evaluating LLM applications covers how to turn those cases into a regression set and how far to trust a model as a grader.
Numbers deserve their own rule
Of all hallucinations, wrong numbers do the most damage per word, because people copy them into spreadsheets and decisions without rereading the sentence around them. They are also the easiest to prevent. A model should not be the thing that remembers your quarterly revenue or adds up 40 invoice lines. A database query or a calculation tool should do that, and the model should only phrase the result.
In practice this means giving the model tools for every figure it might be asked about and an instruction to say it cannot answer when no tool covers the question. Then check that the numbers in the final answer match the numbers that came back from the tools, which is a string comparison, not an AI problem. In CloudOEngine, agents run real tools, and each tool call and its result is recorded, so the figure in an answer can be traced back to the call that produced it.
Mitigation, in the order I would do it
Most teams reach first for a bigger model or a longer system prompt. The changes below do more, roughly in order of payoff for effort:
- Give the model a respectable way out. State in the prompt that "I don't have that information" is an acceptable answer, and treat abstentions as a normal outcome in your interface instead of an error. This goes straight at the guessing incentive Kalai and colleagues describe.
- Ground answers in retrieved sources and require a citation for each factual claim, so a reader can click through. Ask the model to quote the relevant passage before it answers when documents are long.
- Fix retrieval before touching the prompt. Look at the passages behind 50 bad answers; remove outdated and duplicate documents; add keyword search for codes and names.
- Move every number, date and record lookup into a tool or a query.
- Add the claim-by-claim check from the previous section for answers that matter, and route unsupported claims to an abstention or a person.
- Lower the sampling temperature for factual tasks. It will not fix knowledge gaps, but it removes some of the randomness the Huang survey points to.
- For long-form answers, try a verification pass. Chain-of-Verification (Dhuliawala and colleagues, 2023) drafts an answer, plans questions that would check its facts, answers those questions separately without seeing the draft, and then writes a corrected answer. Answering the check questions independently is the important part, because a model rereading its own draft tends to agree with it.
None of these gets you to zero. Decide in advance what error rate is acceptable for each use and measure against it, instead of chasing a perfect score.
Where a person still has to look
The size of the risk depends less on how often the model is wrong than on what happens next. A wrong answer in an internal search tool costs a minute. A wrong answer that triggers a refund, changes a price or emails a customer costs money and trust, and in Air Canada's case a tribunal order.
So draw the line by consequence. Answers that only inform can go out with citations and a way to report a problem. Actions that change something outside the conversation should wait for a person when they are costly or hard to reverse. CloudOEngine's Autopilot runs triggered agents with approval rules: a person approves the action, in the app or through an email approve link, before it runs. Our piece on human-in-the-loop AI goes into which actions deserve that step and how to keep approvers from clicking through on autopilot themselves.
If you are starting this week, take 100 recent production answers, have someone who knows the subject mark each one right, wrong or unsupported, and for every wrong one note whether the model had the right source in front of it. That one afternoon shows if your problem is retrieval, the model or missing tools, and which of the steps above to do first.
How CloudOEngine helps
CloudOEngine puts data connections (databases, files and camera streams), pipelines, an AI runtime with an LLM gateway, agents with tool access and RAG, Vision AI and live video into one platform and console, with one permission model and one audit trail. For hallucinations, that matters because the documents an answer was retrieved from and the data a tool queried live in the same place as the agent that used them.
Agents run real tools, for example filing a ticket, and every step and tool call is traced and can be inspected. When an answer is wrong, you can see what the agent retrieved and which calls it made, and tell a retrieval fault from a model fault without guessing.
Autopilot runs triggered agents with approval rules. A person approves an action in the app or through an email approve link before it runs, so an answer built on a hallucinated fact does not turn into a refund or a customer email on its own.
Governance is included, not sold as an add-on: tenant isolation, role-based access, audit logs and per-tenant encrypted secrets.
Built in Bengaluru, India.
Frequently asked questions
What is an LLM hallucination?
It is output that is stated with confidence but is false, or that contradicts the documents or instructions the model was given. NIST calls the same thing confabulation: confidently stated but erroneous or false content by which users may be misled.
Why do large language models hallucinate?
A model predicts likely text, and on rare facts likely and true come apart. A 2025 paper by Kalai and colleagues argues that training and most benchmarks also reward guessing over admitting uncertainty, so models learn to produce an answer instead of saying they do not know.
Does RAG stop hallucinations?
It reduces them but does not stop them. A 2024 Stanford study found that legal research tools built on retrieval still produced hallucinated answers between 17% and 33% of the time, so you still need claim checks and citations a reader can follow.
How can you detect hallucinations automatically?
Check each claim in the answer against the passages it was supposed to come from, and for questions without sources, sample several answers and measure whether they agree in meaning. Semantic entropy, published in Nature in 2024, uses ten samples clustered by meaning and beat simpler uncertainty scores on average.
Can you get an LLM to zero hallucinations?
No current technique guarantees it. Plan for a residual error rate: let the model abstain, show sources, keep numbers in tools rather than in the model's memory, and put a person in front of any action that is costly to undo.
Sources
- Kalai, Nachum, Vempala, Zhang: Why Language Models Hallucinate (arXiv, September 2025)
- NIST AI 600-1: Artificial Intelligence Risk Management Framework, Generative AI Profile (July 2024)
- Huang et al.: A Survey on Hallucination in Large Language Models (ACM TOIS)
- Farquhar, Kossen, Kuhn, Gal: Detecting hallucinations in large language models using semantic entropy (Nature, 2024)
- Manakul, Liusie, Gales: SelfCheckGPT, zero-resource black-box hallucination detection
- Dhuliawala et al.: Chain-of-Verification Reduces Hallucination in Large Language Models
- Magesh et al.: Hallucination-Free? Assessing the Reliability of Leading AI Legal Research Tools (Stanford)
- DWW summary of Moffatt v. Air Canada, 2024 BCCRT 149 (secondary report)
