Skip to content
10 / Answers

Hallucination is a design problem, not a mystery.

An AI hallucination is an answer that reads as confident and fluent but is not supported by fact or by the evidence the model was given. It happens because a language model predicts plausible text, not verified text. You reduce it with retrieval, citations, a gate that refuses on weak evidence, and evaluation that measures faithfulness.

Short answer
Plausible text without grounding
Cause
Models predict likely words, not true ones
Fixes
Retrieval, citations, a confidence gate, evals
Signal
Faithfulness score on a test set
  • 5production AI apps
  • 14engineers led
  • 200+students mentored
01

Questions students ask

The hallucination questions searched most, answered from building a system that declines instead.

What is hallucination in AI?

In AI, a hallucination is output that is presented as fact but is invented: a citation that does not exist, a function in a library that was never written, a statistic with no source, a confident summary of a document that says something else. The text is grammatical and assured, which is what makes it dangerous. The model is not lying; it is doing what it was trained to do, which is produce likely-looking text.

What is hallucination in LLM?

A large language model generates each token by sampling from a probability distribution learned from text. When the question is about something the model saw often in training, the likely continuation is also the correct one. When the question is about your company's refund policy or a paper published last month, the likely continuation is a plausible pattern, not the truth. The model fills the gap with fluent guesswork. That filled gap is the hallucination.

Why hallucinations occur in LLM

  • Missing knowledge: the fact was never in training data, or is newer than the model.
  • Compression: training squeezes the web into weights; details blur and the model reconstructs them.
  • Pressure to answer: models are tuned to be helpful, and a refusal rarely scored well during that tuning.
  • Ambiguous prompts: the model picks an interpretation and commits to it.
  • Long contexts: facts in the middle of a long prompt get less attention than those at the edges.

What are hallucinations in generative AI?

The same failure shows up across generative models. A text model invents a quote; an image model draws a hand with six fingers; a code model calls an API method that does not exist; a speech model transcribes a word that was never said. In each case the output is a plausible sample from the model's learned distribution rather than a verified fact about the world. Treating generation as a draft to be checked, not a verdict, is the right mental model.

What is hallucination in RAG?

In retrieval-augmented generation a hallucination is an answer that goes beyond, or against, the retrieved passages. It happens when retrieval returns nothing useful and the model answers anyway from memory, or when the model paraphrases a passage into something it did not say. RAG.NextUpgrad handles the first case with a confidence gate: it scores the evidence before generation and declines with a reason when support is weak. The second is caught by faithfulness checks in the test suite.

What the gate does in practice: after hybrid retrieval and re-ranking, it looks at the top passages and their scores and asks whether they actually bear on the question. If the best score sits below a threshold tuned on the evaluation set, the system returns the passages it found, says plainly that none of them answers the question, and offers the closest related topics instead. Users told me this is the moment they started trusting the assistant, because an honest 'not in these documents' is worth more than a fluent guess they would have to verify anyway. The threshold is a product decision: lower it for a brainstorming tool, raise it for anything that touches money, health or law.

What does hallucination mean in AI outputs?

Practically, it means you cannot treat an AI answer as true because it sounds true. For a student, it means verifying every citation and every API call an assistant gives you. For a builder, it means designing so the system shows its evidence: inline citations to the passages used, a visible refusal when there is no evidence, and a way for users to report wrong answers that feeds the evaluation set.

What is hallucination in generative AI?

The term borrows from psychology, where a hallucination is a perception without a stimulus; in generative AI it is an output without a grounding. Some researchers prefer 'confabulation', the confident filling of gaps, because the model is not perceiving anything. Whatever the word, the operational definition that matters for engineering is: a claim in the output that no provided evidence or verified fact supports.

What are hallucinations in LLMs?

Researchers split them into two kinds. Intrinsic hallucinations contradict the source material the model was given, such as summarising a contract and reversing a clause. Extrinsic hallucinations add material that cannot be verified from the source at all, such as a date or a name that appears nowhere. Both are measured by faithfulness: break the answer into claims and check each one against the evidence. Intrinsic errors are usually worse because they are harder to spot.

Why hallucinations happen in AI

Three forces combine. The objective: predicting the next token rewards plausibility, not truth. The data: the web contains errors, contradictions and gaps, and the model learned all of them. The deployment: users ask about things the model cannot know, and the interface gives no signal of uncertainty. None of these is fixed by a bigger model alone, which is why grounding and gating are engineering work, not something you wait for.

What are hallucinations in the context of AI?

In the context of building AI products, a hallucination is a defect with a cost: a wrong refund amount, a fabricated legal citation, a medical claim with no source. The defence is layered: retrieve evidence and show it; constrain outputs with schemas where the answer is structured (DocuLens AI validates every extracted field for this reason); score the evidence before answering and refuse when it is thin; and measure faithfulness on a real question set so you know your rate and whether it is falling.

02

How to stop it

The order that works in production.

  1. 01

    Ground every answer

    Retrieve passages with hybrid search and re-ranking; instruct the model to answer only from them and to cite them.

  2. 02

    Gate on evidence

    Score the retrieved passages before generation. Below a threshold, show the best passages and say the question is not answered by the sources.

  3. 03

    Constrain structure

    Where the output is data, validate it against a schema; reject what does not fit.

  4. 04

    Measure faithfulness

    On a labelled set, check each claim against the context; run it on every change; read the failures.

03

In the room

Where these systems get explained to students.

An assistant that knows when to stop?

I built one that declines on weak evidence. I can show you how, or build yours.