AI basics › How LLMs work
What is AI hallucination? Why AI confidently makes things up
AI hallucination is when a model states something untrue as if it were fact. Why it happens, the main kinds, a real court case, and ways to reduce it.
If you’ve asked ChatGPT or another AI chatbot a question, perhaps you’ve received an answer that read smoothly and later turned out to be wrong. It might have been a book that doesn’t exist, a paper no one wrote, or a number that was slightly off. People usually call this hallucination. Cambridge Dictionary even named “hallucinate” its Word of the Year for 2023, adding a new sense: when an AI hallucinates, it produces false information.
Put in one sentence, AI hallucination is when a language model produces something that sounds plausible but isn’t true, and says it with confidence. A paper OpenAI published in September 2025 calls these “overconfident, plausible falsehoods” and notes that they differ fundamentally from what people experience as hallucinations. The model is simply filling a gap in what it knows with the words most likely to come next. You hear the term more often these days because more people use these models for search, writing, and code, so more confident mistakes make it out into the world. Some have even reached a courtroom.
Asking a small model about books that don’t exist
To see it for myself, I ran a small public model on my own computer. Qwen2.5-0.5B-Instruct is a chat model with 0.49 billion parameters, released by the Qwen team under the Apache 2.0 license, and its weights come to about 1 GB. I asked it who wrote three novels. Mary Shelley’s Frankenstein and Project Hail Mary, which Andy Weir published in 2021, are real. The third title I made up, and Open Library has no book by that name. I asked each question twice, the second time with one sentence added: if you do not know, say “I don’t know.”
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
name = "Qwen/Qwen2.5-0.5B-Instruct"
tok = AutoTokenizer.from_pretrained(name)
model = AutoModelForCausalLM.from_pretrained(name, dtype=torch.float32)
def ask(question):
messages = [{"role": "user", "content": question}]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True,
return_tensors="pt", return_dict=True)
# Greedy decoding: always take the most likely next token
out = model.generate(**inputs, max_new_tokens=60, do_sample=False,
repetition_penalty=1.0)
return tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True)
titles = ["Frankenstein", "Project Hail Mary", # real novels
"The Glass Orchard of Velmora"] # made up
idk = ' If you do not know, say "I don\'t know."'
for title in titles:
q = f'Who wrote the novel "{title}"? Answer in one sentence.'
print(title)
print(" plain:", ask(q))
print(" +idk: ", ask(q + idk))
do_sample=False and repetition_penalty=1.0 switch off the sampling and the repetition penalty that this model turns on by default. What’s left is greedy decoding, which picks the most likely next token at every step (generation strategies), so every run gives the same output.
Frankenstein
plain: The novel "Frankenstein" was written by Mary Shelley, an English novelist and poet.
+idk: I don't know.
Project Hail Mary
plain: The novel "Project Hail Mary" was written by American author Truman Capote.
+idk: I don't know.
The Glass Orchard of Velmora
plain: The novel "The Glass Orchard of Velmora" was written by the renowned British author, Virginia Woolf. Woolf, who was born in 1882, is best known for her works such as "Mrs. Dalloway" and "Pride and Prejudice."
+idk: I don't know.
Look at the plain answers first. The model credited the made-up book to Virginia Woolf and listed Mrs. Dalloway and Pride and Prejudice as her best-known works. The first is hers, but the second is Jane Austen’s. For Project Hail Mary it named Truman Capote. Because right and wrong come out mixed together in the same confident tone, hallucination is hard to catch.
With the added sentence, both wrong answers turned into “I don’t know,” but so did Frankenstein, which the model had gotten right. When I widened the test to five made-up titles and five real novels, the instruction again turned every made-up title into “I don’t know,” but the model also gave up on three real ones. One of them was Moby-Dick, which it had answered correctly. Fewer wrong answers came at the cost of some right ones.
A model this small knows little, so it’s quick to invent, but bigger models invent too, and the difference is one of degree. On SimpleQA, a set of fact questions OpenAI collected in 2024 to be hard for GPT-4, GPT-4o got 60.8% wrong and the smaller GPT-4o-mini got 90.5% wrong. And in the 2025 paper, DeepSeek-V3, with 600 billion parameters, was asked to answer only if it knew, yet gave three different wrong birthdays for one of the authors.
Where the confident guess comes from
A language model writes by choosing the next token again and again, where a token is a small piece of text such as a word or part of one. Pretraining, the first stage of training, is mostly practice at exactly this. Continuing the code above, I looked at the probabilities of the first word after “The novel … was written by.”
def top_next_words(title, k=3):
q = f'Who wrote the novel "{title}"? Answer in one sentence.'
text = tok.apply_chat_template([{"role": "user", "content": q}],
add_generation_prompt=True, tokenize=False)
text += f'The novel "{title}" was written by' # start the answer for the model
inputs = tok(text, return_tensors="pt")
with torch.no_grad():
probs = torch.softmax(model(**inputs).logits[0, -1], dim=-1)
top = torch.topk(probs, k)
return " ".join(f"{tok.decode(int(i)).strip()} {p:.2f}"
for p, i in zip(top.values, top.indices))
for title in titles:
print(f"{title:30}{top_next_words(title)}")
Frankenstein Mary 0.63 the 0.15 Victor 0.01
Project Hail Mary American 0.08 British 0.07 the 0.05
The Glass Orchard of Velmora the 0.13 British 0.04 J 0.03
For Frankenstein, Mary gets 0.63, but for the other two the top candidate is a word like American or the, at only 0.08 and 0.13. The model’s own numbers show that it doesn’t know. Greedy decoding takes the top word anyway, so a few steps later you have “the renowned British author, Virginia Woolf,” and the hesitation in the numbers is gone.
The paper explains this in more general terms. Pretraining text doesn’t come labeled true or false, and the authors show that even with error-free data, the statistical goal of pretraining would still produce errors. Models learn things with consistent patterns, like spelling, but a fact like someone’s birthday has no pattern, and if it appears only once in the data there’s nothing to generalize from. So the paper expects that if 20% of birthday facts appear exactly once in the pretraining data, base models will hallucinate on at least 20% of birthday facts.
Tests that reward guessing
Post-training, which refines a pretrained model, also tries to reduce hallucination, but the paper traces why it persists to the way models are graded. Most benchmarks give 1 point for a correct answer and nothing for a blank or “I don’t know.” That’s why, like a student guessing on a multiple-choice exam, a model that guesses when unsure scores higher. The paper points out that widely used benchmarks such as GPQA, MMLU-Pro, and SWE-bench grade this way, and says models are “always in ‘test-taking’ mode.”
OpenAI’s GPT-5 system card from August 2025 puts numbers on the trade-off. On SimpleQA without web access, gpt-5-thinking-mini had 22% accuracy and a 26% hallucination rate, while OpenAI o4-mini had 24% accuracy and a 75% hallucination rate. By accuracy alone o4-mini comes out slightly ahead, yet it was wrong almost three times as often, while gpt-5-thinking-mini declined about half the questions. So the paper’s authors propose changing how existing benchmarks are scored, so that a confident wrong answer costs more than “I don’t know.”
The kinds of hallucination
Hallucinations are often sorted by what the answer is wrong against. A 2023 survey splits them into factuality hallucinations, which conflict with real-world facts, and faithfulness hallucinations, which drift from the user’s input or contradict themselves. In practice, you’ll mostly meet these three.
| Kind | What it looks like | Example |
|---|---|---|
| Factual error | A wrong fact stated as true | Truman Capote as the author of Project Hail Mary |
| Made-up source | A book, paper, quote, or ruling that doesn’t exist | The fake court opinions in the case below |
| Unfaithful to the input | Contradicts your document, your instructions, or itself | Saying DEEPSEEK has 2 or 3 Ds |
The last example is what DeepSeek-V3 answered across ten trials in the same OpenAI paper, though the word has only one D. Of course, not every wrong answer is a hallucination, and the paper keeps the word for plausible falsehoods. Saying “I don’t know” doesn’t count. And since the model isn’t trying to deceive anyone, a hallucination isn’t a lie either. Cambridge Dictionary also mentions confabulation as another name for it.
When it ended up in court
The best-known case is Mata v. Avianca, a passenger’s lawsuit against an airline over a knee injury on a flight, heard in US federal court. In it, the plaintiff’s lawyers filed a brief on March 1, 2023 that cited court decisions that didn’t exist. The court’s opinion of June 22, 2023 found that the fake opinions, quotes, and citations had been created by ChatGPT. When a lawyer asked ChatGPT whether one of them, Varghese v. China Southern Airlines, was real, it even replied that the cases were real and could be found on Westlaw and LexisNexis.
Judge P. Kevin Castel wrote that there is nothing inherently improper about using a reliable AI tool for assistance, but that lawyers have a gatekeeping role in making sure their filings are accurate. These lawyers kept standing by the fake opinions after the court questioned whether they existed. In the end, they and their firm were ordered to pay a $5,000 penalty, and to write to the judges falsely named as authors of the fake opinions.
Where it matters, and how to reduce it
When you’re brainstorming names or writing a draft you’ll rewrite anyway, an invented detail doesn’t cost much. When the output is a fact, a number, a citation, or a claim about law, medicine, or recent events, it’s a different story, because that’s where a model guesses and a reader tends not to check. These are the common ways to reduce it.
- Give the model the material. Retrieval-augmented generation (RAG) searches documents first and hands the relevant passages to the model, which answers from them. The 2020 paper that introduced RAG reported that it produced more specific, diverse, and factual language than a model without retrieval.
- Let it say it doesn’t know. Anthropic’s guide to reducing hallucinations says that explicitly allowing the model to admit uncertainty can drastically reduce false information.
- Ask for quotes and sources, then check them. The same guide suggests having the model back each claim with a direct quote and withdraw any claim it can’t support.
- Ask the same question several times and compare. The guide treats answers that disagree as a possible sign of hallucination, and DeepSeek-V3’s three birthdays are exactly that.
- Have a person check anything that matters before it goes out.
Why it’s hard to remove completely
None of these remove hallucination entirely, which is why Anthropic’s guide advises that critical information always be validated. According to the paper, search and RAG help, but when a search finds no confident answer, right-or-wrong grading still rewards a guess. The authors argue that a model that answers only what it’s sure of and otherwise says “I don’t know” wouldn’t hallucinate. But as the small test above showed, a model that says “I don’t know” more often also gives up answers it knew, and as long as leaderboards mostly reward accuracy, the pull is toward guessing.
Where to start
If you’d like to see this yourself, run the two code blocks above in order. You only need Python with PyTorch and Transformers, and the model downloads automatically on the first run. Add a book you know well or a title you just made up and watch where the probabilities spread out, or ask a chatbot you use for sources and open every link it gives you. For the reasoning, the paper itself is worth reading. I ran these examples on October 27, 2026 on a Mac’s CPU with Python 3.13.12, PyTorch 2.14.1, and Transformers 5.20.2.
AI tools helped with the research for this post.