Hallucination

On this page 7

A hallucination is output from an AI model, most often from large language models, that is fluent and confident but factually false, unsupported by the provided sources or inconsistent with the input. Typical examples are invented citations, fabricated statistics, nonexistent software functions, wrong dates and summaries that add details the source document never contained.

Hallucination is not a rare malfunction but a structural property of how language models generate text: they produce the most plausible continuation of a prompt, and plausibility is not the same as truth. Rates vary widely by model, task and domain, and they can be reduced substantially but not eliminated with grounding, prompting, training and verification techniques.

Why language models hallucinate

An LLM predicts the next token from a probability distribution learned during training. It stores knowledge only implicitly in its weights, compressed from vast text, and has no built-in mechanism to look facts up or to know which of its beliefs are reliable. When the prompt asks about something rare, ambiguous or absent from training data, the model still produces a statistically plausible answer rather than a refusal.

Several factors make this worse. Training objectives and evaluation practices that reward a guess over admitting uncertainty encourage confident fabrication. Sampling with a higher temperature increases the chance of selecting unlikely tokens. Long generations can compound early errors, because each token is conditioned on the previous ones, including wrong ones.

CauseMechanismTypical symptom
Knowledge gapsFact rare or absent in training dataInvented details about obscure entities
Knowledge cutoffTraining data ends at a fixed dateOutdated or fabricated recent events
Pressure to answerGuessing rewarded over abstainingConfident answer instead of uncertainty
Sampling randomnessHigher temperature selects unlikely tokensInconsistent answers across runs
Weak groundingModel ignores or misreads supplied contextSummary adds facts not in the source
Ambiguous promptModel fills in missing assumptionsAnswer to a different question
Main causes of hallucination

Types of hallucination

Researchers distinguish hallucinations by what the output contradicts. Intrinsic hallucinations contradict the source or input the model was given, while extrinsic hallucinations add claims that cannot be verified from the source at all. A related distinction separates factuality errors, which contradict world knowledge, from faithfulness errors, which deviate from the provided context.

FormDescriptionRisk area
Fabricated referencesCitations, cases or papers that do not existLegal, academic and medical writing
Invented numbersPlausible statistics with no basisReports, analysis, finance
Entity confusionMerging facts about similarly named people or productsBiographies, customer support
Unfaithful summaryDetails added or meaning reversedDocument summarization
Nonexistent code elementsInvented functions, parameters or packagesSoftware development
Reasoning errorsWrong intermediate step presented as validMath, planning, multi-step analysis
Common forms of hallucination

Hallucinated package names in generated code are a recognized security risk: if an attacker registers a package under a name that models frequently invent, developers who install it without checking may run malicious code.

Not every wrong answer is a hallucination. Separating the categories helps choose the right fix, because a retrieval failure needs a different remedy from a reasoning failure or a biased output.

Failure typeWhat goes wrongPrimary fix
HallucinationUnsupported content generated as factGrounding, abstention, verification
Outdated knowledgeAnswer was once correctRetrieval of current sources
Retrieval errorWrong or irrelevant documents suppliedBetter search, reranking, chunking
Instruction misreadingCorrect facts for the wrong questionClearer prompts and system prompt
BiasSystematically skewed contentData curation, evaluation, guardrails
Hallucination and neighboring failure types

Reducing hallucinations in practice

Mitigation works in layers, and no single technique is sufficient. The most effective step for factual applications is retrieval-augmented generation (RAG), which supplies relevant documents in the context window and instructs the model to answer only from them and to cite the passages it used.

TechniqueHow it helpsLimitation
Retrieval and groundingAnswers drawn from supplied sourcesFails if retrieval returns wrong documents
Permission to abstainModel may say it does not knowCan increase unhelpful refusals
Low temperatureReduces random token choicesDoes not fix missing knowledge
Structured output and toolsCalculators, databases and APIs supply exact valuesRequires integration work
Self-consistency checksCompares several sampled answersHigher cost and latency
Automated verificationSecond model or rules check claims against sourcesVerifier can also err
Human reviewExpert checks high-stakes outputSlow and expensive at scale
Mitigation techniques and their effect

Prompt engineering also matters. Asking for quotes from the source before the answer, requiring citations, splitting complex tasks with prompt chaining and giving explicit instructions such as answering only from the provided documents all reduce unfaithful output. Reasoning models and chain-of-thought can improve multi-step accuracy, although their intermediate reasoning can itself contain errors.

Measuring hallucination and common misconceptions

Hallucination rates are measured with task-specific evaluations: question-answering sets with known answers, summarization benchmarks scored for faithfulness to the source, and citation checks that verify every reference exists and supports its claim. Published rates are not comparable across benchmarks, because they depend heavily on task difficulty and scoring rules.

  • A confident tone signals nothing: fluency and correctness are independent.
  • Larger models still hallucinate, often less on common facts but persuasively on rare ones.
  • Retrieval does not guarantee truth, since the model can still misread or ignore sources.
  • Zero hallucination is not a realistic target; risk management through verification is.

In everyday language

An AI hallucination is when a chatbot makes something up and says it with full confidence. It might name a book that was never written or quote a law that does not exist.

This happens because the system is built to produce text that sounds right. It is a bit like a student who never leaves an exam answer blank and writes something convincing instead. Important facts from AI should always be checked against a reliable source.

Seen in the real world

A law firm uses a language model to draft research memos. In an early trial, the model produced a well-written memo citing several court decisions, two of which did not exist; the case names and quotations looked entirely authentic. The error was caught only because an associate checked every citation in the firm’s legal database.

The firm then rebuilt the workflow. The model now receives retrieved decisions from the database as context, must quote the passage supporting each statement, and is instructed to state when no supporting decision was found. A script verifies that every cited case exists in the database. Fabricated citations stopped reaching reviewers, and attorneys still read every cited passage before filing.