n4nAI

Hallucination vs confabulation: is there a difference

A precise technical distinction between hallucination and confabulation in LLMs, with concrete examples and engineering implications for building reliable systems.

n4n Team6 min read1,354 words

Audio narration

Coming soon — every post will get a voice note here.

Hallucination and confabulation describe the same observable behavior — a model generating plausible but factually incorrect output — but they originate from different analytical frameworks. Hallucination is the dominant industry term, borrowed from perception psychology, describing any model output ungrounded in its training data or provided context. Confabulation comes from neuroscience and more precisely characterizes the mechanism: the model fills gaps in its knowledge with statistically probable continuations, not deliberate fabrication.

The mechanism: probability over retrieval

Large language models do not retrieve facts. They predict the next token conditioned on the preceding context, weighted by parameters learned during training. When the model encounters a query about information it never saw during training — or saw too infrequently to form strong parameter associations — it does not return “I don’t know.” Instead, it continues the most probable token sequence given the prompt’s semantic framing.

This is not a bug. It is the fundamental operation of autoregressive generation. The model has no internal fact database, no truth verification module, and no epistemic state representing “knowledge” versus “uncertainty.” It only has conditional probability distributions over its vocabulary.

# Simplified view: what the model actually computes
def generate_next_token(context, model_params):
    logits = model.forward(context, model_params)
    probs = softmax(logits / temperature)
    return sample(probs)  # or argmax for greedy decoding

# There is no "lookup" step. No "verify" step.
# Only: given this context, what token sequence is most probable?

When the training data contains strong, consistent associations — “The capital of France is Paris” — the probability mass concentrates on the correct completion. When associations are weak, contradictory, or absent, probability mass spreads across plausible-sounding alternatives. The model samples from this distribution. The result looks like a confident answer. It is merely a probable continuation.

Why the distinction matters for engineers

The term you use shapes how you mitigate the problem.

If you treat it as hallucination — a perception error — you reach for perception-style fixes: better prompts, stricter system instructions, output validators, retrieval-augmented generation (RAG) to ground the model in external truth. These are necessary and effective.

If you treat it as confabulation — a gap-filling mechanism — you recognize that the model cannot distinguish between “I know this” and “I am predicting a plausible continuation.” No prompt engineering fully solves this because the mechanism operates at the probability level, not the intent level. You then design systems that assume confabulation will occur and architect around it: citations required, human-in-the-loop for high-stakes domains, deterministic fallback for factual queries, explicit uncertainty calibration.

Both framings are useful. The industry settled on “hallucination” because it is more intuitive to non-specialists. But “confabulation” is more precise for system design.

Concrete example: the phantom API endpoint

Consider a developer asking a coding assistant: “What’s the signature for n4n.ai’s batch_completions endpoint?”

The model has never seen this endpoint in its training data — perhaps it was released after the knowledge cutoff, or it’s a private API. The prompt primes the model with “n4n.ai” and “batch_completions,” creating a strong semantic frame: OpenAI-compatible REST API, batch processing, likely similar to /v1/chat/completions but for batches.

The model generates:

POST https://api.n4n.ai/v1/batch/completions
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

{
  "model": "gpt-4o",
  "requests": [
    {"messages": [{"role": "user", "content": "Hello"}]},
    {"messages": [{"role": "user", "content": "World"}]}
  ]
}

This looks perfectly reasonable. It follows OpenAI batch patterns, uses plausible parameter names, and matches the developer’s mental model. It is also entirely fabricated. The real endpoint might be /v1/batch, accept a input_file_id instead of inline requests, or not exist at all.

The model did not “hallucinate” in the sense of misperceiving reality. It confabulated: faced with a gap, it filled it with the statistically most probable API shape given the context cues. The probability distribution over valid-looking JSON structures peaked at this completion.

How confabulation manifests in practice

Fabricated citations

A model asked for academic references generates plausible titles, authors, DOIs, and venues — all nonexistent. The citation format is correct because the model has seen millions of valid citations. The content is confabulated because the specific paper does not exist in training data.

Invented function signatures

As in the API example above. The model knows the syntax of the language and the conventions of the ecosystem. It combines them probabilistically.

Plausible but wrong numerical results

“Calculate the p-value for this dataset.” The model outputs a number with four decimal places. It has no computational engine. It predicts what a p-value looks like in a results paragraph.

Confident falsehoods in domain-specific language

Medical, legal, or financial terminology used correctly in sentences that assert falsehoods. The model has learned the register separately from the facts.

Common misconceptions

“Larger models hallucinate less”

Larger models confabulate more fluently. They produce more coherent, contextually consistent, and harder-to-detect fabrications. They also have broader training coverage, so they confabulate on fewer topics — but when they do, the output is more convincing. Benchmark results on truthfulness (TruthfulQA, HaluEval) show improvement with scale, but the failure mode persists qualitatively unchanged.

“RAG eliminates hallucination”

RAG reduces confabulation by supplying relevant context, but it introduces new failure modes: retrieval errors (wrong chunks), context window overflow (truncated context), and the model ignoring retrieved context in favor of parametric memory. The model still confabulates within the provided context — e.g., synthesizing a conclusion not supported by the cited passages.

# RAG does not add a "truth check" step
def rag_generate(query, retriever, model):
    chunks = retriever.top_k(query, k=5)
    context = "\n".join(chunks)
    prompt = f"Context:\n{context}\n\nQuestion: {query}\nAnswer:"
    return model.generate(prompt)

# The model still predicts: "What token sequence follows this prompt?"
# It may ignore chunks, contradict chunks, or extrapolate beyond chunks.

“Temperature zero eliminates hallucination”

Greedy decoding (temperature=0) reduces stochastic variation but not systematic confabulation. If the highest-probability continuation is a fabrication — because the training data contains more plausible-sounding wrong answers than correct ones for that query — temperature zero returns the fabrication deterministically.

“The model knows when it’s uncertain”

The model outputs probability distributions. You can inspect token-level entropy or log-probabilities as a proxy for uncertainty. But the model itself has no access to this meta-information during generation. It cannot “choose” to say “I don’t know” unless that phrase is the highest-probability continuation — which requires the training data to associate the specific query pattern with “I don’t know” more strongly than any fabricated answer.

“Fine-tuning on ‘I don’t know’ data solves it”

Supervised fine-tuning (SFT) on refusal examples shifts the probability distribution. The model learns to refuse patterns similar to the training refusals. It does not learn a generalizable uncertainty detector. Out-of-distribution queries still yield confabulations, often with hedging language (“It appears that…”, “Some sources suggest…”) that makes them more dangerous because they sound calibrated.

Detection strategies that work in production

Self-consistency sampling

Generate multiple completions at temperature > 0. If answers diverge on factual claims, flag for review.

def self_consistency_check(prompt, model, n=5, temperature=0.7):
    responses = [model.generate(prompt, temperature=temperature) for _ in range(n)]
    # Extract factual claims (entities, numbers, citations) from each
    claims_per_response = [extract_claims(r) for r in responses]
    # Check intersection
    common_claims = set.intersection(*[set(c) for c in claims_per_response])
    return len(common_claims) / max(len(c) for c in claims_per_response) if claims_per_response else 0.0

Low consistency correlates with confabulation. High consistency does not guarantee truth — the model may consistently confabulate the same plausible error.

Retrieval-backed verification

For every factual claim in the output, require a retrieved source span that entails it. Use a separate, smaller model (or the same model with a strict prompt) to judge entailment.

def verify_claims(response, retriever, verifier_model):
    claims = extract_atomic_claims(response)
    verified = []
    for claim in claims:
        evidence = retriever.search(claim, k=3)
        entailment = verifier_model.judge(claim, evidence)
        verified.append({"claim": claim, "evidence": evidence, "supported": entailment})
    return verified

This moves the trust boundary from “model said it” to “retrieved evidence supports it.”

Uncertainty quantification via log-probabilities

Token-level log-probabilities correlate with factual reliability. Low average log-prob on entity tokens (names, numbers, specific terms) signals confabulation risk.

def factual_uncertainty_score(response, model):
    tokens = model.tokenize(response)
    logprobs = model.logprobs(response)
    entity_tokens = [i for i, t in enumerate(tokens) if is_entity_token(t)]
    if not entity_tokens:
        return 1.0  # no factual content to verify
    entity_logprobs = [logprobs[i] for i in entity_tokens]
    return -sum(entity_logprobs) / len(entity_logprobs)  # higher = more uncertain

Calibrate thresholds per domain. This is a heuristic, not a guarantee.

Deterministic tool use for verifiable facts

Offload computation, lookup, and structured retrieval to tools the model calls, not knowledge the model holds.

{
  "tool": "http_request",
  "arguments": {
    "method": "GET",
    "url": "https://api.n4n.ai/v1/models",
    "headers": {"Authorization": "Bearer {{env.API_KEY}}"}
  }
}

The model learns to invoke the tool. The tool returns ground truth. The model then formats the response. This architecture inverts the responsibility: the model handles language; the system handles facts.

Architectural implications

Design your LLM-powered system assuming every factual claim in the model output is confabulated until verified. This leads to:

  1. Separation of concerns: Language generation separate from fact retrieval and computation.
  2. Citation enforcement: Every user-facing factual claim requires a traceable source.
  3. Graceful degradation: When verification fails, the system refuses or escalates rather than presenting unverified output.
  4. Observability: Log confidence proxies (log-probs, self-consistency scores, verification results) per request for monitoring and alerting.
  5. Human-in-the-loop routing: High-stakes domains (medical, legal, financial) route low-confidence outputs to human reviewers.

Summary

Hallucination and confabulation describe the same phenomenon from different angles. Hallucination is the user-facing symptom: confident, plausible, wrong output. Confabulation is the mechanistic explanation: the model fills knowledge gaps with statistically probable continuations because that is what autoregressive generation does.

For engineers, the confabulation framing is more actionable. It tells you that no prompt, no fine-tuning, and no model scale will eliminate the root cause — only architectural guards (retrieval, tools, verification, human review) can contain it. Build systems that assume the model will confabulate, and you will sleep better when it inevitably does.

Tagshallucinationconfabulationglossary

Written by

n4n Team

The team building n4n — a single OpenAI-compatible API in front of 240+ models, with automatic fallback, load balancing and pay-per-token metering.

More from n4n Team →

All hallucination in llms posts →