- Explain why next-token prediction produces fluent errors, especially for rare, one-off facts.
- Calculate how small per-claim error rates compound across long lists of citations or multi-step reasoning.
- Analyse how binary grading rewards guessing, and how a confidence target with a penalty for errors changes the incentive.
- Apply grounding, consistency checks and independent source verification proportionate to the stakes.
- Implement a simple automated check that quoted passages actually appear in a source document.
Before this: Prompting Fundamentals, How Large Language Models Work
AI models sometimes state things that are simply false, in the same fluent, confident tone they use for true things. Knowing why this happens, and when it is most likely, lets you use AI for real work without getting caught out.
What a hallucination is
A hallucination is an output that sounds plausible but is wrong or made up: a citation to a paper that does not exist, a statistic with no source, a quote nobody said, a software function that was never written. The word is a little misleading, since the model is not seeing things. It is producing text that fits the pattern of a good answer without that text being anchored to a real fact.
Why confident wrong answers happen
A language model is trained to predict likely next words based on patterns in enormous amounts of text. It is not looking facts up in a database, and during its basic training it is never told which sentences are true and which are false. That has a few consequences (this is a simplification, but the core idea is sound):
- Patterns are learned well; one-off facts are not. Grammar, common knowledge and widely repeated facts appear thousands of times in training data, so the model gets them right. A specific person's birthday or the page number of a court ruling may appear rarely or never, so the model has no pattern to follow and produces a plausible-looking guess instead.
- Fluency is not a confidence signal. The model writes a made-up citation in exactly the same style as a real one. Its tone tells you nothing about whether it is right.
- Guessing has been rewarded. OpenAI researchers argued in 2025 that common training and testing methods reward models for guessing rather than saying "I don't know", much as a multiple-choice exam rewards a lucky guess over a blank answer. Developers are working on this, but no current model is free of the problem.
An analogy: imagine a well-read friend at a dinner party who hates admitting they do not know something. Most of what they say is right. But when you ask about something obscure, they will still give you a smooth, specific answer, and you cannot tell from their delivery which answers were invented.
A real example
In 2023, lawyers in a US federal case, Mata v. Avianca, filed a brief that cited court decisions generated by ChatGPT. Several of the cases did not exist. When questioned, the lawyers asked the chatbot whether the cases were real, and it said they were. The judge sanctioned the lawyers and fined them $5,000. The lesson is not just "AI makes things up" but also "asking the AI to confirm its own answer is not verification."
When the risk is highest
Be most careful with:
- Citations and references. Paper titles, authors, case names, URLs, page numbers and quotes are classic hallucination territory.
- Specific numbers. Statistics, prices, dates, dosages, measurements and percentages. A number that is slightly off still looks right.
- Niche facts. Small companies, local regulations, less-famous people, specialised technical details, anything rarely written about.
- Recent events. A model's built-in knowledge stops at its training cutoff, the date its training data ends. Without a search tool it may not know about anything after that, and may confidently describe an outdated situation as current.
- Long chains of reasoning. An early mistake in a calculation or argument gets carried forward.
- Questions with a false premise. Ask "Why did the 2019 law ban X?" and a model may explain a law that never existed instead of correcting you.
Grounding: give it something real to work from
Grounding means giving the model trustworthy source material and asking it to answer from that material rather than from memory. Two common ways:
- Documents. Paste or upload the contract, report or manual and say: "Answer only using the document below. If the answer is not in it, say so."
- Search. Many AI tools can search the web and show links. This helps a lot with recent events and niche facts, but the model can still misread a page, or rely on a poor-quality one.
Grounding reduces hallucinations; it does not eliminate them. A model can still misquote a document it was given.
How to verify
Worked example. Suppose you ask for statistics for a presentation and get: "According to a 2024 survey by the National Retail Institute, 62% of shoppers..." (an invented example, which is exactly the point). Here is how to check it:
- Find the source yourself. Search for the organisation and survey by name. Does it exist? Is it a real, reputable body?
- Find the exact figure. Open the original report and locate the number. Is it 62%? Is it about the same group of people and the same year?
- Check the context. Does the source say what the AI claimed, or something narrower?
- If you cannot find it in two or three minutes, drop it or replace it with a figure you have confirmed.
Other useful habits:
- Ask for sources, then open them. A link that is real but does not support the claim is as bad as no link.
- Ask the model to flag uncertainty: "Mark anything you are not sure about." This helps, but treat the result as a hint, not proof.
- Cross-check important answers against an authoritative source: an official website, the original document, a professional.
- Match effort to stakes. Brainstorming dinner ideas needs no checking. Medical, legal, financial and safety decisions always do.
Going deeper
Probabilities, not look-ups
At every step a language model assigns a probability to each possible next token and then picks one. For a widely repeated fact ("Paris is the capital of France") almost all the probability sits on the right answer. For a fact the model saw once or never, such as an obscure person's birthday, the probability is spread across many plausible candidates. The model still has to emit something, and whichever date it picks will be written just as fluently. Kalai, Nachum, Vempala and Zhang (2025) make this precise: they argue that for arbitrary facts with no learnable pattern, a base model's error rate is at least roughly the fraction of such facts that appeared only once in its training data. Rare facts are where hallucinations concentrate, and this is a statistical consequence of the training objective, not a bug that one patch can remove.
Calibration is the property that stated confidence matches real accuracy: among answers given with 80% confidence, about 80% should be right. Guo et al. (2017) showed that modern neural networks are often overconfident, and you should assume a chatbot's verbal confidence ("I'm certain") is a weak signal at best.
Why guessing pays under binary grading
Suppose a test awards 1 point for a correct answer and 0 for a wrong answer or "I don't know". If a model's chance of being right is , guessing earns points on average and abstaining earns 0, so guessing always wins, however small is. Kalai and colleagues argue that most widely used benchmarks grade this way, so training and evaluation keep rewarding confident guesses.
Their proposed fix is an explicit confidence target : tell the model to answer only if it is more than confident, and deduct points for a wrong answer. The expected score of answering is then
which is positive exactly when (multiply through by : ). So the best strategy becomes "answer when your real confidence exceeds , otherwise abstain".
Worked example. With , a wrong answer costs points. A model that is 60% sure: , so it should abstain. A model that is 90% sure: , so it should answer. You can apply the same logic to yourself: the higher the cost of acting on a wrong answer, the higher your confidence bar before you rely on it.
Errors compound
Small error rates become large across many claims. If each citation in a list is independently correct with probability 0.95, the chance that all 20 are correct is
so about two times in three at least one is wrong, and on average one is fake (). The same arithmetic applies to reasoning: ten steps that are each 98% reliable give , so nearly one chain in five contains an error somewhere. This is why long, citation-heavy outputs need checking item by item.
Consistency checks
Asking the same model "are you sure?" is weak, but asking the same question several times independently is informative. Wang et al. (2022) showed that sampling several reasoning paths and taking the majority answer ("self-consistency") improves accuracy on reasoning tasks. Used as a check, the logic is: if five fresh attempts give five different birth dates, none of them should be trusted. Agreement is not proof, because a model can repeat the same mistake consistently, but disagreement is a cheap, useful warning sign.
Grounding, and checking the grounding
Retrieval-augmented generation (RAG), introduced by Lewis et al. (2020), retrieves relevant passages and puts them in the prompt so the model answers from them. It reduces hallucination on knowledge questions, but the model can still misquote or over-generalise what it retrieved. When you ask for quotes from a document, you can check them mechanically:
import re
def normalise(s):
return re.sub(r"\s+", " ", s.lower()).strip()
def check_quotes(answer, source, min_len=10):
"""List each quoted passage in `answer` and whether it appears in `source`."""
src = normalise(source)
quotes = re.findall(r'"([^"]{%d,})"' % min_len, answer)
return [(q, normalise(q) in src) for q in quotes]
source = "The tenant must give 60 days written notice before leaving the property."
answer = ('The lease says "the tenant must give 60 days written notice" and '
'"the landlord pays all repair costs".')
for quote, found in check_quotes(answer, source):
print("OK " if found else "MISSING", quote)
The first quote is found; the second is flagged as missing because it is not in the source at all. Normalising case and whitespace avoids false alarms from line breaks. The check catches invented quotes, but not a real quote used to support the wrong conclusion; that still needs a human reader.
Common pitfalls
- Asking the model to verify itself in the same conversation, as in Mata v. Avianca. Verify against an independent source.
- Treating a real link as support. Open it and find the claim; many hallucinated citations point to real pages that say something else.
- Assuming search or RAG makes answers correct. Grounding lowers the error rate; it does not remove the need to check what matters.
- Trusting precise-looking numbers. False precision ("62.4%") is not evidence of a source.
- Uniform effort. Checking everything equally wastes time on low-stakes text and leaves too little for high-stakes claims; triage by consequence.
- Leading questions. A question with a false premise invites an answer that goes along with it; ask neutrally ("Did a 2019 law ban X?").
In practice
- Treat AI output as a first draft from a fast, well-read assistant who sometimes makes things up.
- Never paste an AI-generated citation, quote or statistic into anything important without opening the original source.
- Give the model the documents you want it to rely on, and tell it to say when the answer is not there.
- Use a search-enabled tool for anything recent, and still check the links.
- Do not ask the model to verify itself; verify against an independent source.
Key takeaways
- Models predict plausible text rather than looking up facts, so they can produce fluent answers that are false.
- A confident tone is not evidence of accuracy; made-up citations look just like real ones.
- Risk is highest for citations, specific numbers, niche facts, recent events and false-premise questions.
- Grounding the model in documents or search results reduces errors but does not eliminate them.
- Verify important claims against an independent original source, never by asking the model to confirm itself.
Terms in this lesson
- Hallucination
- An AI output that sounds plausible but is false or invented.
- Training cutoff
- The date after which a model's training data ends, so it has no built-in knowledge of later events.
- Grounding
- Giving a model trusted source material and asking it to answer from that material rather than from memory.
- False premise
- A question that assumes something untrue, which a model may go along with instead of correcting.
- Calibration
- The match between a model's stated confidence and how often it is actually right.
- Confidence target
- An instruction to answer only above a stated confidence t, with wrong answers penalised t/(1-t) points so that abstaining is the better choice below t.
- Self-consistency check
- Asking the same question several times independently and treating disagreement among the answers as a warning sign.
Check your understanding
- 1.
Why can a model state a made-up fact in a confident tone?
- 2.
Which request carries the highest hallucination risk?
- 3.
An AI gave you a statistic with a source name. What is the best way to verify it?
- 4.
An AI lists 10 facts, and each is independently correct with probability 0.9. What is the chance that all 10 are correct?
- 5.
A benchmark gives 1 point for a correct answer and 0 for a wrong answer or "I don't know". A model is 30% confident. Which choice maximises its expected score?
Exercises
Work each problem before opening the solution.
- Exercise 1Core
An AI-generated reading list has 12 references, each independently real and correctly described with probability 0.9. What is the probability that all 12 are fine, and how many bad references should you expect?
Show solution
All correct: , about 28%. So roughly 72% of such lists contain at least one bad reference.
Expected bad references: . In practice you should expect at least one problem and check every reference.
- Exercise 2Core
A grading scheme uses a confidence target . (a) What is the penalty for a wrong answer? (b) Should a model answer when it is 85% confident? (c) When it is 95% confident? Show the expected scores.
Show solution
(a) Penalty points.
(b) , negative, so abstain.
(c) , positive, so answer.
This matches the rule that answering pays exactly when confidence exceeds .
- Exercise 3Core
Extend the quote checker into
check_numbers(answer, source)that lists every number in the answer (such as60,3.5,1,200) and whether it appears anywhere in the source.Show solution
import re def numbers_in(text): found = re.findall(r"\d[\d,]*(?:\.\d+)?", text) return [n.replace(",", "") for n in found] def check_numbers(answer, source): src = set(numbers_in(source)) return [(n, n in src) for n in numbers_in(answer)] source = "Notice period: 60 days. Deposit: 1,200 dollars." answer = "You need 60 days notice and the deposit is 1,500." print(check_numbers(answer, source)) # [('60', True), ('1500', False)]Removing thousands separators lets
1,200and1200match. A number that is present can still be attached to the wrong thing, so this is a screen, not a proof. - Exercise 4Challenge
You have 45 minutes to check a 2,000-word AI-drafted briefing for your board. It contains 15 factual claims (8 numbers, 4 descriptions of regulations, 3 statements about competitors) and 6 citations. Describe a verification plan that fits the time and explain how you prioritise.
Show solution
Triage by consequence and risk. First list all 21 items (15 claims plus 6 citations). Rate each on impact (would a board decision change if it were wrong?) and hallucination risk (numbers, citations, niche or recent facts are high risk).
Suggested allocation.
- 5 minutes: extract and rate the items.
- 20 minutes: open every citation and confirm the source exists and says what is claimed (about 3 minutes each). Citations are both high risk and easy to check.
- 15 minutes: verify the high-impact numbers and the regulation descriptions against primary sources (official sites, the original reports). Where a figure cannot be found within 2 to 3 minutes, mark it for removal.
- 5 minutes: competitor statements: check the ones that drive recommendations; soften or remove the rest ("reportedly", or cut).
Outputs. A marked-up copy with each claim tagged verified, corrected or removed, and a note to the board of anything unverified. Do not ask the drafting model to confirm its own claims; if you use AI to help, use a search-enabled tool to find sources, then read them yourself. Compounding (for example that everything is right) justifies checking every high-impact item rather than sampling.
Further reading
- paperAdam Tauman Kalai, Ofir Nachum, Santosh S. Vempala & Edwin Zhang, Why Language Models Hallucinate (2025)
- paperPatrick Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (2020)
- paperChuan Guo, Geoff Pleiss, Yu Sun & Kilian Q. Weinberger, On Calibration of Modern Neural Networks (ICML 2017)
- paperXuezhi Wang et al., Self-Consistency Improves Chain of Thought Reasoning in Language Models (2022)
Go further
Sources
- Why language models hallucinate (OpenAI, September 2025)
- Mata v. Avianca, Inc. (Wikipedia)
- ChatGPT cited bogus cases for a New York federal court filing (CNBC)
- Kalai, Nachum, Vempala & Zhang, Why Language Models Hallucinate (arXiv 2509.04664)
- GIGAZINE: OpenAI research team publishes paper explaining why large-scale language models hallucinate (Sep 2025; describes the t/(1-t) penalty)
- Guo et al., On Calibration of Modern Neural Networks (arXiv 1706.04599)
- Wang et al., Self-Consistency Improves Chain of Thought Reasoning in Language Models (arXiv 2203.11171)
- Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (arXiv 2005.11401)
Fact-checked and last reviewed 2026-11-05