Skip to content
LearnAI

9.1Hallucination: why models make things up

Why fluent language models state falsehoods with confidence, how training and grading reward guessing, and what actually reduces it.

⏱ 16 minIntermediate

Confidently, fluently wrong

Ask a chatbot for the birthday of a moderately obscure researcher, or for three academic papers on a niche topic, and you may get a crisp, specific, well-formatted answer that is simply made up: a plausible date, real-sounding titles with real-sounding co-authors, a DOI that leads nowhere. This is a hallucinationHallucinationWhen a model produces fluent but false or unsupported content.. The word is a little misleading (the model isn’t perceiving anything), but it has stuck. Researchers also say confabulation, or more plainly, confident errors.

Hallucinations come in a few flavors:

  • Factual fabrication: invented facts, quotes, citations, legal cases or API functions.
  • Unfaithfulness to the input: a summary that adds a claim the source never made, or a RAG answer that contradicts the retrieved document.
  • Reasoning slips: a wrong intermediate step stated as confidently as a right one.

The important observation is that the style of a hallucination is indistinguishable from the style of a correct answer. The model doesn’t switch into a hesitant voice when it’s on thin ice, and that is exactly what makes hallucinations dangerous. To see why this happens, we need to look at what a language model is actually trained to do, and at how we grade it.

ANALOGY· The student who never leaves a blank

Picture a multiple-choice exam that awards 1 point for a correct answer and 0 for a wrong one or a blank. A savvy student facing a question they don’t know never leaves it blank: a guess might score, and a blank never will. Over a whole semester of such exams, the student learns a habit: always write something, and write it confidently.

The exam is the benchmark, the scoring rule is binary grading, and the student is the language model being optimized to score well. The habit of confident guessing is hallucination. Change the rules so a wrong answer costs a point while a blank costs nothing, and the best strategy flips: answer only when you’re fairly sure.

Root cause 1: the objective is plausibility, not truth

A large language modelLarge language model (LLM)A very large neural network, usually a Transformer, trained to predict the next token of text. Chat assistants are post-trained LLMs. is pretrained on next-token predictionNext-token predictionThe training objective of LLMs: given the text so far, output a probability distribution over the next token.: given some text, assign high probability to whatever came next in the training data. Nothing in this objective labels statements as true or false. The model learns the statistical shape of text, which includes a great deal of factual knowledge (because true statements are common in text), but the training signal is “sounds like the data”, not “is correct”.

For many patterns that’s enough. Spelling, grammar and very common facts (“Paris is the capital of France”) appear so often and so consistently that the model nails them. The trouble is with facts that are arbitrary and rare. There is no pattern from which you could infer an obscure person’s birthday; you either memorized it or you didn’t. If a fact appeared once or twice in the training corpus, the model may have only a faint trace of it, yet generation still has to produce some date, and a plausible-looking date is always available.

Kalai, Nachum, Vempala and Zhang make this precise in Why Language Models Hallucinate (2025). They connect generating valid text to a simpler classification problem: telling valid from invalid outputs. Generation errors, they argue, are at least as common as classification errors on that problem, so whatever makes classification hard (like arbitrary facts with no learnable pattern) forces some generation errors, even if the training data contained no errors at all. For arbitrary facts they relate the error rate to the “singleton rate”, the fraction of facts that appear exactly once in training. Roughly: if 20% of birthday facts appear only once in the pretraining data, expect a base model to get on the order of 20% of birthday questions wrong. Their bounds come with technical conditions; the intuition is that rarely seen facts are where pretrained models are most likely to fabricate.

Root cause 2: we grade them like exam-takers

If pretraining explains why errors exist, what explains why models state them so confidently instead of saying “I’m not sure”? Here the same paper points at the evaluations themselves.

Most popular benchmarksBenchmarkA standardized test set used to compare models, such as MMLU, GPQA or SWE-bench. use binary grading: an answer is right (1 point) or wrong (0 points), and “I don’t know” also scores 0. Under that rule, a model that abstains whenever it’s unsure will always score lower than an otherwise identical model that guesses, because a guess has some chance of being right. Post-training, including RLHFRLHFReinforcement learning from human feedback: train a reward model on human preference comparisons, then optimize the LLM against it. and other reinforcement learning, optimizes models to do well on exactly this kind of evaluation, and leaderboards reward the top accuracy number. The result is a system-wide incentive to guess. In the paper’s framing, models are being trained to be good test-takers.

The proposed fix is socio-technical rather than architectural: change mainstream evaluations so that confident errors are penalized more than abstentions, and state the confidence target in the instructions (“answer only if you are more than 75% confident; mistakes cost 3 points, correct answers earn 1, ‘I don’t know’ earns 0”). Then a model that knows its own uncertainty has a reason to use it.

Try it: thresholds, calibration and scoring rules

The simulator below is a toy quiz of 300 questions. For each one, the model has some true chance pp of being right: high for common facts, low for rare ones. The model also reports a confidence. A threshold decides policy: answer when confidence is at or above the threshold, otherwise say “I don’t know”. Two grading schemes score the result.

INTERACTIVEConfidence and abstention simulator
abstain: "I don’t know"00.250.50.751conf
● would be right✕ would be wrongfaded = abstainedx-axis = model’s stated confidence
Model
Grading
accuracy (all questions)
53%
error rate (confidently wrong)
15%
abstention rate
32%
precision when it answers
77%
-1-0.500.5100.250.50.751threshold →best
━ binary score━ score with −1.00 per wrong answer
score now (penalized)
0.373
best threshold for this grading
0.40 → 0.403
theory (calibrated): k/(1+k)
0.50

With a penalty of 1.00 per wrong answer, answering only pays when confidence exceeds k/(1+k) = 0.50. Below that, "I don’t know" scores better.

Move the threshold and watch accuracy, errors and abstentions trade off. Switch between binary grading and penalizing wrong answers, and see where the best threshold lands. Then make the model overconfident.

Things to try:

  1. Binary grading. Drag the threshold from 1 down to 0. The binary score only ever goes up as the model answers more: the best threshold is 0, “always guess”. The error rate climbs right along with it, and nothing in the score notices.
  2. Penalize wrong, k = 1. Now a wrong answer costs as much as a right answer earns. The score curve has a peak around a threshold of 0.5: answer only if you’re more likely right than wrong.
  3. Raise k to 3. The optimal threshold moves to about 0.75. Stricter penalties call for more caution. The readout “theory: k/(1+k)” predicts where the peak should be.
  4. Raise the share of rare-fact questions. More low-confidence questions appear on the left. Under the penalty rule, the right response is to abstain more; under binary grading, it’s to guess more.
  5. Switch to “Overconfident”. The model’s stated confidence is now inflated, so rare-fact questions drift right, past the threshold. The theoretical threshold misfires and errors leak through. Abstention only works if confidence means something, which is why calibration matters.

Calibration: does 80% mean 80%?

A model is calibratedCalibrationHow well a model's stated confidence matches its actual accuracy: a calibrated model is right about 80% of the time when it says it is 80% confident. if, among all the answers it gives with 80% confidence, about 80% are correct. Calibration is what makes a threshold meaningful. Two findings are worth knowing:

  • Pretrained models can be surprisingly well calibrated on their token probabilities. Kadavath and colleagues (2022) found large models could estimate the probability that their own answer was correct reasonably well on many tasks, and the GPT-4 technical report showed a well-calibrated pretrained model whose calibration got worse after post-training.
  • Token probabilities aren’t the same as statement confidence. A sentence can be phrased many ways, and the probability of one particular phrasing understates confidence in the underlying claim. In practice, confidence is often estimated by sampling several answers and checking whether they agree (self-consistency), or by asking the model to rate itself.

Calibration doesn’t eliminate errors; it lets the system know which answers are risky, so it can abstain, hedge, or go look something up.

Mitigations that work in practice

No single trick eliminates hallucination, but layers of defense reduce it a lot.

Retrieval-augmented generation. Instead of relying on parametric memory, the system first searches a trusted corpus and puts the relevant passages into the prompt, a pattern called RAGRetrieval-augmented generation (RAG)Retrieving relevant documents at query time and placing them in the prompt so the model can answer from them.. Rare facts are exactly where this helps most: the model no longer has to remember the birthday, it only has to read it. RAG introduces its own failure modes (retrieving the wrong document, or ignoring the right one), covered in the RAG lesson.

Abstention and hedging. Train and prompt models so that “I don’t know” or “I’m not certain, but…” is an acceptable, rewarded answer. AbstentionAbstentionDeclining to answer (saying "I don't know") when confidence is too low. Worth it when a wrong answer costs more than no answer. trades coverage for reliability, which is the right trade in medicine, law and anything automated.

Citations and attribution. Ask the model to quote and link the sources supporting each claim. This doesn’t guarantee truth (models can fabricate citations too), but it makes claims checkable, and a system can automatically verify that a cited passage really exists and supports the sentence.

Verification. A second pass checks the first. Chain-of-Verification (Dhuliawala et al., 2023) has the model draft an answer, generate verification questions about its own claims, answer those independently, then revise. Other variants use a separate checker model, tool callsTool use / function callingA model emits a structured call (name + arguments) that software executes, then the result is fed back to the model. (a calculator, a code interpreter, a search engine) or simple consistency checks across multiple samples.

Decoding choices. Lower temperatureTemperatureA sampling knob that divides logits before softmax. Low values make output more deterministic; high values make it more random. makes outputs more deterministic, which can cut random slips on factual tasks, though it does nothing for a fact the model never learned. See sampling.

Better evaluation. Report error rates and abstention rates, not only accuracy, and score confident errors as worse than abstentions. This is the lever the Kalai et al. paper argues matters most, because it changes what models are optimized toward.

MATH CORNER · optionalWhy the best threshold is k/(1+k)

Suppose a correct answer scores +1+1, a wrong answer scores −k-k, and “I don’t know” scores 00. If the model’s true probability of being right on a question is pp, the expected score of answering is

E[answer]=p⋅1+(1−p)(−k)=p(1+k)−k.\mathbb{E}[\text{answer}] = p\cdot 1 + (1-p)(-k) = p(1+k) - k .

Answering beats abstaining exactly when this is positive:

p(1+k)−k>0  ⟺  p>k1+k.p(1+k) - k > 0 \iff p > \frac{k}{1+k} .

Under binary grading, k=0k = 0, so the threshold is 00: any nonzero chance of being right makes answering worthwhile. That’s the formal version of “guessing always wins”. Kalai et al. phrase it the other way round: to target a confidence threshold tt, penalize mistakes by t/(1−t)t/(1-t) points.

Worked example with 4 questions and a calibrated model:

questionpp (true chance right)binary: answer?k=1k=1: answer? (p>0.5p>0.5)k=3k=3: answer? (p>0.75p>0.75)
A0.95yes (+0.95)yes (+0.90)yes (+0.80)
B0.70yes (+0.70)yes (+0.40)no (0)
C0.40yes (+0.40)no (0)no (0)
D0.10yes (+0.10)no (0)no (0)
expected total2.151.300.80

Under binary grading the guess-everything policy earns 2.15 expected points, yet expects 0.05+0.30+0.60+0.90=1.850.05 + 0.30 + 0.60 + 0.90 = 1.85 wrong answers out of 4. Under k=3k = 3 it answers one question and expects only 0.05 errors. Expected values in each column use that column’s own penalty, e.g. B under k=1k=1: 0.7−0.3=0.40.7 - 0.3 = 0.4.

Calibration in symbols: a model with confidence cc is calibrated if Pr⁡(correct∣c)=c\Pr(\text{correct} \mid c) = c for all cc. If confidence is inflated, c>Pr⁡(correct∣c)c > \Pr(\text{correct} \mid c), and the rule “answer when c>k/(1+k)c > k/(1+k)” answers questions with negative expected score.

In code

A minimal abstention policy around any model that can give multiple samples: estimate confidence by agreement, and answer only above the threshold implied by the penalty.

from collections import Counter

def answer_or_abstain(ask, question, n=8, penalty=3.0):
    """ask(question) -> short answer string, sampled at temperature > 0."""
    samples = [ask(question).strip().lower() for _ in range(n)]
    best, count = Counter(samples).most_common(1)[0]
    confidence = count / n                  # self-consistency as a rough confidence
    threshold = penalty / (1 + penalty)     # answer only if E[score] > 0
    if confidence > threshold:
        return best, confidence
    return "I don't know", confidence

# penalty=3 → threshold 0.75: answer only if at least 7 of 8 samples agree

Agreement among samples is a crude confidence estimate (a model can be consistently wrong), but it is cheap and often useful. Production systems combine it with retrieval and a verification step.

COMMON MISCONCEPTIONS
  • “Hallucinations are a bug that the next model version will fix.” Some causes shrink with better models, but the core pressures (rare arbitrary facts, a plausibility objective and grading that rewards guessing) are structural. Mitigation is ongoing work, not a single patch.
  • “If the model sounds confident, it’s probably right.” The fluency of an answer carries almost no information about its correctness. Confidence has to be measured (probabilities, agreement, verification), not read off the tone.
  • “RAG eliminates hallucinations.” It reduces them for questions the corpus covers, but the model can still misread, ignore or over-extrapolate from retrieved text, and retrieval can return the wrong passage.
  • “A model that says ‘I don’t know’ more often is worse.” Under binary accuracy it scores lower, but it may make far fewer harmful errors. Which model is better depends on the cost of a wrong answer, which is exactly what the scoring rule should encode.
  • “Hallucination only means made-up facts.” Unfaithful summaries, invented citations and confident reasoning errors are all part of the same family.

Check your understanding

0/5 answered
  1. Q1.Under binary grading (right = 1, wrong = 0, "I don't know" = 0), what is the score-maximizing strategy for a model that is unsure?

  2. Q2.Correct answers earn +1, wrong answers cost −1, abstentions score 0. A calibrated model should answer when its confidence exceeds…

  3. Q3.According to Kalai et al. (2025), why do base models hallucinate on arbitrary facts like birthdays even with error-free training data?

  4. Q4.Why does an abstention threshold stop working well when a model becomes overconfident?

  5. Q5.Which mitigation most directly addresses a model's lack of knowledge of a rare fact?

Further reading

Progress is saved in this browser only.
Type to search across all lessons and glossary terms.