Glossary · AI Engineering

What is an AI hallucination?

Short answer

An AI hallucination is a confident but false or unsupported output from a generative AI model, such as an invented fact, quote, statistic, API method or citation. It happens because language models generate likely-sounding text rather than looking facts up, so they can fill gaps with plausible fiction.

Why models hallucinate

An LLM predicts the most plausible next words. When the answer is not in its training data or in the prompt, “plausible” and “true” can diverge, and the model has no built-in signal that it is guessing. Questions about niche facts, recent events, exact numbers and specific references are most at risk.

How to reduce hallucinations

  • Supply the facts with RAG and instruct the model to answer only from them.
  • Ask for sources and check that cited passages actually say what is claimed.
  • Allow “I don’t know”: tell the model that an honest gap is better than a guess.
  • Use tools for things models are bad at: calculators, database lookups, live APIs.
  • Test with a set of questions whose answers you know, before and after every change.

In software development

AI coding assistants sometimes call functions or packages that don’t exist. Tests, type checking and static analysis catch most of these before they reach production.

Published · Updated · By · All terms

Go deeper