Concepts / Evaluating and Detecting Hallucinations

Evaluating and Detecting Hallucinations

One explanation for hallucination is that the model cannot clearly separate the data it was given from the data it generated itself.

  • Programming

A Haiku Scored Twice

Anyone who has used a chatbot for a while has probably noticed that asking the same question twice does not always produce the same answer. The wording may differ a little, the level of detail may shift, or the conclusion itself may change. In a casual conversation this may be harmless. In a task such as scoring work, summarizing a document, or answering a factual question, it becomes a real problem.

What do you think happens?

You give a model a haiku and ask it to rate the haiku from 1 to 5. You run the identical prompt twice. Do you expect the two scores to match?

  • Yes, the same input always gives the same output

  • No, not necessarily, even though the input did not change

  • Only if the haiku is long

Reveal answer
Answer:

No, not necessarily, even though the input did not change

In the example from the source, the first run returns a score of 2 and the second returns a score of 4. Nothing about the input changed, yet the output did. This is the first form of model inconsistency.

This article explains the two main forms of unreliable behavior in language models, inconsistency and hallucination, and walks through the mechanisms that produce them. We will trace how a single prompt can produce different answers, how a small change in wording can change an answer a great deal, and how a model's own generated text can feed its later errors.

Inconsistency and Hallucination Are Different Problems

Definition

Inconsistency is about variation: the model may give different answers to the same question, or different answers to nearly the same question.

Definition

Hallucination means generating information not based on actual data or facts. It is about the content of an answer: the model may give a confident answer that is simply wrong. It is especially dangerous in tasks that depend on factuality.

The two problems are easy to confuse because both make an answer unreliable, but they are independent. The table below compares them.

PropertyInconsistencyHallucination
What goes wrongAnswers vary across runs or across similar promptsThe content of an answer is not based on actual data or facts
Where the problem liesIn variation between answersIn the substance of a single confident answer
Can it occur alone?Yes, an inconsistent model can still produce a correct answer on one runYes, a perfectly consistent model can hallucinate every time it is asked

Inconsistency concerns variation between answers, while hallucination concerns whether the content is grounded in fact.

Key point

A model can be perfectly consistent and still hallucinate every time. Consistency therefore does not show that an answer is correct.

Inconsistency also damages trust. In human communication we expect a reasonable level of consistency: a colleague who gave you a different name every time you met would be confusing and hard to rely on. Users bring the same expectation to AI systems, so an answer that shifts from run to run feels unreliable even when each individual answer looks plausible.

Tracing One Prompt Across Runs

Consider the first scenario, in which the same input produces different outputs. Follow one identical prompt through two separate runs. The prompt goes in unchanged both times, but each run produces its own output. The diagram shows the two runs side by side, using the haiku example from the source. Each run is a separate generation, so each can end with a different score.

Identical haikupromptunchanged inputRun onescore 2Run twoscore 4runrun again
How does the same input lead to different outputs across runs, and what differs between those runs?

The source describes the variation in two ways that show up across runs. The wording may differ a little, the level of detail may shift, or the conclusion itself may change. For a scoring task, a change in the conclusion is the most serious of these, because the score is the result the workflow depends on. A workflow that expects a stable result cannot treat these two runs as equivalent.

When Small Input Changes Shift the Answer

The second scenario is subtler. Here slightly different inputs produce drastically different outputs. Imagine two prompts that differ by only a few words: Summarize this report, and Summarize this report in one line. The wording change is small, but the request asks for a very different shape of answer, so the output changes sharply. This example is made up for illustration; it is not from the source.

Prompt wording ASummarize this reportAnswer Aseveral paragraphsPrompt wording BSummarize this report inone lineAnswer Ba single linegeneratesgenerates
What is the difference between two nearly identical prompts, and how does a small change in input produce a large change in output?

Fixing the generation settings is still useful, but it does not force the model to give the same answer to different inputs. The source is explicit on this point. Settings address variation from the sampling process, while different inputs are different requests. To steer responses toward what you want, the source points to carefully crafted prompts and a memory system. Those tools are covered in later chapters.

How Generated Text Becomes Context

A language model produces its output one piece at a time. Each generated token is added to the text the model is working from, and the model then conditions its next choices on that text. One explanation for hallucination is that the model cannot clearly separate the data it was given from the data it generated itself. When it produces a sentence, that sentence becomes part of the context for the next token.

Contextprompt plus generated textNext token chosenconditioned on contextToken joins contexterrors includedconditionsappendedrepeats, conditioning later choices
How does each generated token become part of the context that conditions the next output, so the model's own errors get reinforced?

The model then conditions its next choices on that sentence exactly as it would on a fact supplied by the user. If the first generated sentence is slightly wrong, the model can build on it and produce increasingly false claims. Researchers in this area called this pattern self-delusion. Self-delusion describes how a generated claim gets expanded: the model treats its own output as if it were given fact.

Key point

Self-delusion happens because generated text re-enters the context. The model's own sentence is later read as if it were a trustworthy input.

Snowballing From One Wrong Assumption

Snowballing hallucinations describe a related pattern. After making an incorrect assumption, the model keeps hallucinating in order to justify that original assumption. Each new error supports the earlier one, so the mistake grows larger over the course of the response or conversation. The flowchart shows how each later step is built on the first.

Early wrongassumptiongenerated in the firstsentenceNext claim built onittreated as given factFurther claim defendsitnew error supports thefirstResponse rests on thechainerrors grow largerconditionsconditionsaccumulates
How does one early wrong assumption propagate and compound through each subsequent generated step?
Worked example

Following One Wrong Premise

A model is asked to write a short report about a project. Its first sentence wrongly states that the project began in 2019, when the request concerned a project that began in 2021. Trace how the error can grow through the rest of the response.

  1. 1
    Step 1: the early assumption

    The first sentence states the wrong start year. This sentence is now part of the context for everything that follows.

  2. 2
    Step 2: a dependent claim

    The model writes that the project has run for a certain number of years. It computes this from the 2019 start year it generated itself, so the wrong premise is treated as given.

  3. 3
    Step 3: a defending claim

    When the model later explains a milestone, it invents details that fit the 2019 timeline. Each new detail supports the first error rather than checking it.

  4. 4
    Step 4: the compounded response

    By the end, the response contains several claims that agree with one another but all rest on the original wrong start year. The errors are consistent with each other, which makes them harder to spot.

Result

One unverified early assumption, treated as fact, produced a chain of errors that each reinforced the first. This illustrates snowballing hallucination. The scenario is a made-up illustration, not an example from the source.

Why Sampling Alone Does Not Explain Hallucination

Inconsistency can be traced to randomness in sampling, but the cause of hallucination is more subtle, and sampling alone does not explain it. A model samples from the options it considers probable, so the question becomes how something never seen before can become probable at all.

Training data is far too large to search for every idea, so it is not possible to verify that a generated claim never appeared in training. Researchers therefore rely on hypotheses about why models hallucinate. Two are commonly discussed. The self-delusion view explains how self-supervision can produce hallucinations. The mismatched knowledge view explains how supervision can produce them. Together they suggest that hallucination has several sources, and that a single fix is unlikely to address all of them.

Hallucination is also not a new problem. It was a recognized problem in text generation well before large language models became prominent, and detecting and measuring it has been an established task in natural language generation for years.

It might seem that adding reinforcement learning from human feedback would simply reduce hallucinations. The source reports a more complicated picture. One team found that reinforcement learning helped reduce hallucinations, but a later study found that a model trained with both reinforcement learning and supervised fine-tuning hallucinated more than the same model trained with supervised fine-tuning alone. Human labelers nevertheless preferred the reinforcement-learning model overall, because it improved other qualities.

Common Misreadings of Inconsistency and Hallucination

  • Common mistake

    Treating a consistent answer as a correct answer

    What it looks like

    A model gives the same wrong date on every run, and the repeated answer is taken as proof that it is right.

    Why it fails

    A model can be perfectly consistent and still hallucinate every time. Consistency measures variation, not truth.

    Do this instead

    Check consistency and factual accuracy as separate properties.

  • Common mistake

    Expecting fixed settings to make different questions get the same answer

    What it looks like

    A user sets the generation options once and assumes two different requests will now produce matching responses.

    Why it fails

    Fixing the generation settings helps with variation for the same input, but it does not force the model to give the same answer to different inputs.

    Do this instead

    Use carefully crafted prompts and a memory system to steer responses toward what you want.

  • Common mistake

    Reading the model's earlier sentences as neutral background

    Why it fails

    Generated text re-enters the context and conditions later choices exactly as a supplied fact would, so an early error can be expanded.

    Do this instead

    Verify early claims in a long response, because later text may be built on them.

  • Common mistake

    Expecting one fix to remove all hallucination

    Why it fails

    The source describes several sources of hallucination, and a single fix is unlikely to address all of them.

    Do this instead

    Combine several practical measures and still plan for residual risk.

Mitigation Approaches and Their Residual Risk

The source describes several practical measures for reducing inconsistency and hallucination. Fixing sampling settings, caching, prompting, and memory systems all reduce these problems. None of them guarantees perfect consistency or complete prevention of hallucination. The concept map shows how each approach targets the problem and where residual risk remains.

Inconsistency andhallucinationthe problemSampling settingsvariation between runsResidual riskno approach guarantees aperfect resultCachinglisted as a reducingmeasurePromptingsteers wording and honestyMemory systemssupplies stored contextConcise responsesfewer tokens to invent inreducesreducesreducesreducesmay reduceremains after mitigation
How do the different mitigation approaches relate to the causes of inconsistency and hallucination, and where does each one still leave residual risk?

Prompting is one family of approaches. Some users ask the model to answer as truthfully as possible and to say it does not know when it is unsure. This assumes the model has some internal sense of what it knows, which is itself a contested claim, so the instruction helps but cannot be relied on completely. Prompting and context construction techniques covered in later chapters can also help.

Another practical observation is that concise responses may help. The fewer tokens a model must generate, the fewer opportunities it has to invent something. This is a reduction in opportunity, not a guarantee, because a short answer can still be wrong.

Detection is the natural next question. If hallucinations cannot all be prevented, can they at least be detected before users see them? The source notes that detection is not straightforward, because it is hard even for people to detect when another person is lying or making things up. Methods for detecting and measuring hallucinations are covered in a later chapter.

Diagnosing a Failure

MEDIUM

A user asks a model the same factual question three times and receives three different dates. On a fourth run, the model gives one clearly wrong date and states it confidently. Classify each symptom as inconsistency, hallucination, or both. For the confident wrong date, explain which mechanism from this article could have produced it, and name one practical measure that would reduce the risk without guaranteeing a fix.

Hints
  • Separate variation across runs from the substance of a single answer.
  • Ask whether the wrong date could have been built on an earlier generated sentence.
  • Remember that no single measure guarantees a perfect result.

Key Takeaways

  • Model inconsistency appears in two forms: the same input can produce different outputs, and slightly different inputs can produce drastically different outputs.
  • Inconsistency concerns variation between answers, while hallucination concerns whether an answer's content is based on actual data or facts. A model can be consistent and still hallucinate, and an inconsistent model can still be correct on one run.
  • Generated text re-enters the context and conditions later choices as if it were given fact. This self-delusion can let a wrong early assumption grow into snowballing hallucinations.
  • Fixing sampling settings, caching, prompting, and memory systems reduce these problems, but none guarantees perfect consistency or complete prevention of hallucination.
  • Detecting hallucination is not straightforward, and methods for detecting and measuring it are covered in a later chapter.

Related concepts

More concepts starting with E