StackLift
All terms

Glossary

Hallucination

When an AI model states something false or invented with the same confidence as something true.

A hallucination is an AI model output that sounds confident but is false, unsupported or invented, such as a fake citation, a wrong figure or a function that does not exist. It happens because language models generate likely text, not verified facts.

You cannot remove hallucinations entirely, but you can reduce them. Ground answers in your own sources with RAG, require citations, let the model say it does not know, constrain outputs to a schema, and check results with code or a human reviewer.

Test for them with real questions before launch and keep testing after. High-stakes steps, such as payments or medical or legal decisions, should keep a person in the loop.

Start in 60 seconds

Put this to work on your project.

Get an AI-assisted, architect-reviewed scope, cost range, and timeline. Free, no login.

The complete guide

Hallucination: the complete guide

Updated November 18, 2026 ยท Published by , Founder, StackLift AI. Written with AI assistance; how we make content.

Short answer

An AI hallucination is an output that sounds confident but is false, unsupported or invented, such as a fake citation, a wrong figure or a function that does not exist. Language models generate likely text, not verified facts. You cannot remove hallucinations entirely, but grounding, checks and human review reduce them.

What is an AI hallucination?

A hallucination is what happens when a language model produces something that reads like a fact but is not one. It might cite a court case that was never decided, quote a policy your company does not have, or call a software library function that does not exist. The tone is the same as when the model is right, which is what makes it hard to spot.

The word is a metaphor. The model is not seeing things. It is doing exactly what it was built to do, which is to predict plausible next words. When the true answer is missing, unclear or not in its training, plausible and true come apart.

Why do language models hallucinate?

A large language model learns patterns in text. It does not look facts up in a database, and it has no built-in sense of what it does not know. Several things push it toward confident errors.

Common causes
CauseWhat goes wrong
Gaps in training dataRare, recent or private facts are missing, so the model fills in a plausible guess
Pressure to answerModels are tuned to be helpful, and a direct answer can be favored over saying I do not know
Ambiguous or leading promptsA question that assumes something false invites an answer that accepts it
Weak or noisy contextRetrieved passages that are off-topic or contradictory lead to blended answers
Long or crowded contextImportant details get lost in a very long context window
Sampling randomnessHigher temperature makes less likely, and sometimes wrong, wording more probable

Newer models hallucinate less on many tasks, but the behavior has not disappeared, and you should design as if it can happen.

What kinds of hallucination are there?

Types of hallucination
TypeExampleWhy it matters
Fabricated factsA wrong date, figure or name stated confidentlyDecisions made on false data
Fabricated sourcesA citation or link that does not existBreaks trust, and can cause legal problems
Contradicting the sourceA summary that says the opposite of the documentLooks grounded but is not
Invented capabilitiesA made-up product feature or API callCustomers and developers act on it
Reasoning errorsA calculation or logic step that does not followHard to see without checking the steps
Agent action errorsAn agent calls a tool with invented parametersThe mistake has side effects, not only words

Researchers often split these into two groups: answers that contradict the provided source, and answers that are unsupported by it. The fixes differ, so it helps to know which one you are seeing.

Why do hallucinations matter for a business?

A chatbot that invents a refund policy creates a customer dispute. A summary that misstates a contract clause creates legal risk. A coding assistant that invents a function wastes developer time. The cost depends on what the output is used for and whether anyone checks it.

  • Customer-facing answers: wrong promises, brand damage and support load.
  • Regulated work: healthcare, finance and legal output may need documented review.
  • Internal decisions: bad numbers in a report travel far before anyone notices.
  • Automation: an agent acting on an invented value can change real records.

The right response is not to avoid AI, but to match the safeguards to the stakes.

How do you reduce hallucinations, step by step?

  1. Define what the system should and should not answer, and what it does when it is unsure.
  2. Ground answers in your own approved sources with RAG, and instruct the model to answer only from them.
  3. Require citations to specific passages, and check that the cited text supports the claim.
  4. Allow and reward I do not know, and route those cases to a person.
  5. Constrain outputs: a fixed schema, a list of allowed values, validated by code.
  6. Use tools for facts and math instead of asking the model to remember or calculate.
  7. Lower temperature for factual tasks, and keep prompts clear and specific.
  8. Add automated checks and, for high-stakes steps, a human in the loop.
  9. Test with real and adversarial questions before launch, and keep testing after.

No single step is enough. The reliable approach stacks several, so one layer catches what another misses.

Which techniques help most, and what are their limits?

Mitigation techniques compared
TechniqueHelps withLimit
RAGMissing or private factsBad retrieval still leads to bad answers; the model can ignore the sources
Hybrid search and rerankingFinding the right passageDoes not check the final wording
Citations with verificationUnsupported claimsNeeds a check that the quote supports the claim
Structured outputs and validatorsFormat and value errorsA valid value can still be wrong
Tool calls for lookups and mathFigures, dates, status checksThe model can still pick the wrong tool or argument
GuardrailsPolicy and topic limitsCannot detect every subtle error
Human reviewHigh-stakes decisionsSlower; reviewers need good tooling and time
Fine-tuningConsistent behavior on a narrow taskDoes not reliably add facts

Prompting alone, such as telling the model not to make things up, helps a little but should never be your only control.

What are real-world examples of hallucination risk?

  • A support chatbot invents a warranty term that the company does not offer.
  • A research assistant produces a reference list in which some papers do not exist.
  • A legal drafting tool quotes a case with a plausible name and a made-up holding.
  • A coding assistant imports a package that has never been published.
  • A meeting summarizer assigns an action item to the wrong person.
  • A healthcare scribe adds a symptom that was never mentioned in the visit.
  • A finance assistant states a quarterly figure that is close to, but not, the one in the filing.

In every case, the answer looked fine at a glance. Safeguards need to work without relying on the reader's instinct.

How do you measure and monitor hallucinations?

Start with a test set of real questions, including ones the system should refuse, with known correct answers or source passages. Score answers for factual accuracy, whether each claim is supported by the provided sources, and whether the system declines when it should. Human graders are the reference; model graders can scale the checking once you have verified they agree with people.

After launch, sample live conversations, collect thumbs-down feedback and track escalations. Look for patterns by topic, since hallucinations cluster in areas where your sources are thin. See AI observability, agent evaluation and the AI agent evaluation checklist.

How much does it matter in your use case?

Match safeguards to stakes
Use caseStakesSuggested safeguards
Brainstorming, drafts for editingLowClear labeling that output is a draft
Internal knowledge searchMediumRAG, citations, feedback button
Customer-facing answersMedium to highRAG, citations, refusal rules, monitoring, easy handoff to a person
Regulated or legal outputHighGrounding, validation, mandatory human approval, audit trail
Agents that change records or move moneyHighValidated inputs, limited permissions, approvals before action

Where a regulation applies, the plan should cover what it requires, and your compliance owner should confirm the details.

What are the common mistakes when handling hallucination?

Mistakes and fixes
MistakeWhat happensFix
Relying on the prompt aloneA line saying do not make things up has little effect under pressureAdd retrieval, validation and review, not only wording
Testing on a handful of easy questionsThe demo works, real users find the gapsBuild a test set from real questions, including hard and out-of-scope ones
Showing answers without sourcesUsers cannot check, so they either trust everything or nothingShow citations that open the original passage
No path for I do not knowThe model guesses instead of escalatingDefine a refusal and a handoff to a person
Review that is a rubber stampReviewers approve quickly and miss errorsShow the source beside the output and sample reviewed items for quality
Launching and forgettingDocuments and models change, and quality driftsMonitor live answers and re-run the test set on every change

The review point is easy to overlook. A human in the loop only helps if the human has the time, the context and the authority to say no. Otherwise it is a formality that gives false comfort.

What tools and technologies help?

Teams usually combine a retrieval layer such as PostgreSQL with pgvector, Elasticsearch or Qdrant, a framework to orchestrate calls such as LangGraph or LlamaIndex, schema validation with libraries like Zod or Pydantic, and an evaluation and tracing tool that records every prompt, retrieved passage and answer.

Model providers also offer features that help: structured output modes, citation options and content filters. These are useful building blocks, but none replaces your own test set. Keep prompts and evaluations in version control so you can see what changed when quality moves.

Why are hallucinations worse in agents?

A chatbot's mistake is text a person can read and reject. An agent can act on its mistake. It can call a tool with an invented customer id, repeat a wrong assumption through many steps, or report that a task succeeded when it did not. Errors also compound: a small early error shapes everything after it.

Design agents with narrow permissions, validated tool inputs, confirmation steps before irreversible actions and logs of every step. See tool calling and AI agent development.

What does reducing hallucination mean for cost and timeline?

Safeguards are scope. Retrieval, citation checks, evaluation sets, monitoring and review screens each take build time, and review adds ongoing human time. The more costly the mistake, the more of these you need, and the more evaluation effort goes in before launch.

See LLM pricing for model costs, the AI chatbot cost page and the free estimate, which scopes each feature, including review and evaluation.

How StackLift approaches hallucination risk

StackLift treats it as a design question during discovery: what can the system get wrong, what would that cost, and which safeguards match. An architect-reviewed scope lists the grounding, validation and review steps as deliverables.

AI output is a draft until a person with the right expertise approves it. Engineers own decisions, agents work on feature branches, and observability and rollback are in the plan from sprint one. See AI governance.

Questions people ask

Can hallucinations be eliminated?

Not completely, because language models generate likely text and not verified facts. You can reduce them a great deal with grounding, validation and review, and design the system to catch what remains.

Does RAG stop hallucinations?

It reduces them by giving the model your sources, but it does not stop them. Poor retrieval, ignored context and wrong summaries still occur, so add citations and checks.

Why does AI make up sources?

The model produces text that looks like a citation because citations have a recognizable shape. Without access to a real source list, it can invent one that fits the pattern.

Are newer models less likely to hallucinate?

Often on many tasks, but results vary by task, and no current model is free of the problem. Test with your own questions instead of relying on a general claim.

What is the difference between a hallucination and a mistake?

A hallucination is a mistake with a particular character: invented or unsupported content stated with confidence. Ordinary mistakes, such as a typo or a wrong sum, can come from many causes.

Does lowering temperature stop hallucinations?

It makes output more repeatable and cuts some random errors, but a model can be consistently wrong. Treat it as a small helper, not a fix.

How can I tell if an AI answer is a hallucination?

Check specific claims against a trusted source, look for citations you can open, and be cautious with precise figures, quotes and names. Systems should show their sources so you do not have to guess.

Is hallucination a security risk?

It can be. A model might invent a package name that an attacker then registers, or an agent might act on false data. Validate inputs, limit permissions and review code and actions.

Sources

Sources and further reading

The standards, rules, research and official documentation this page draws on.