AI hallucination: what it is, why it happens, and how to reduce it

Learn what an AI hallucination is, why language models produce false outputs, and practical techniques to detect and reduce hallucinations.

Aron Schuhmann

Written by

Aron Schuhmann

Sam Bhagwat

Reviewed by

Sam Bhagwat

Aug 1, 2026

·

17 min read

You ask your LLM a straightforward question and get a confident, well-structured answer that is completely wrong. Maybe it invents a citation that does not exist or fabricates a statistic that sounds plausible but has no basis in reality.

This is an AI hallucination, and if you are building production AI systems, it is a failure mode your systems need to handle.

Artificial intelligence hallucinations are not edge cases. AMay 2026 Retraction Watch analysis found that fabricated references in biomedical papers increased twelvefold in three years, from 1 in 2,828 papers in 2023 to 1 in 277 papers in the first seven weeks of 2026. As generative AI adoption accelerates, the question of why does AI hallucinate has become a core engineering concern.

This guide covers the AI hallucination definition researchers use, real-world examples, and the detection and reduction strategies you can apply today.

What is an AI hallucination?

An AI hallucination is a response generated by an AI system that contains false or misleading information presented as fact. When you send a prompt, the model produces output that is fluent and confident but is not grounded in your provided context, its source material, or reality.

You will run into this failure mode regardless of which model or provider you use, since it comes from how these systems generate text rather than from a bug in any one product. The sections below cover where the term comes from and the distinct forms hallucination takes, before getting into why it happens and what you can do about it.

How the term originated and what it means

Your first encounter with the term probably came through the LLM boom of 2022 and 2023, but the concept is older. The word “hallucination” appeared in computer vision research as early as 1986, where it described the process of adding detail to low-resolution images. Google researchers applied it to neural machine translation failures in 2017.

The meaning shifted with the rise of ChatGPT and similar tools. By 2023, Cambridge Dictionary updated its definition of “hallucination” to include the AI-specific sense.

Some researchers prefer alternatives like “confabulation” or “fabrication,” arguing that “hallucination” anthropomorphizes the model. Regardless of terminology, the core problem is the same: your model generates fabricated information with no mechanism to signal uncertainty.

Types of hallucination

You will encounter several distinct failure modes when working with LLM outputs.

TypeDescriptionExample
Factual errorsThe model states something verifiably wrongAssigning the wrong date to a historical event or misattributing a quote
FabricationsThe model invents entities entirelyNon-existent research papers, fake legal cases, or fictional people with plausible-sounding credentials
InconsistenciesThe model contradicts itself within the same response, or contradicts the source material it was givenStating two different dates for the same event in one output
Source-reference divergenceThe model cites a real source but extracts incorrect information from itA citation that lends false credibility because the source exists but the claim does not

Why language models hallucinate

Your LLM does not “know” anything in the way a database does. It predicts tokens. Understanding this mechanism is the first step toward building systems that account for hallucination risk.

Three distinct factors combine to produce hallucinated output: the fundamental way the model generates text, gaps or errors in the data it learned from, and the specific settings you use to run it. Each contributes independently, so fixing one does not eliminate the other two.

How next-word prediction creates plausible-but-false output

Your model generates each token based on the probability distribution over its vocabulary, conditioned on the preceding tokens. It is optimized to produce fluent, plausible text, not to produce true text. When the model encounters a prompt about a topic where its training corpus is sparse, it fills the gap with statistically likely continuations rather than declining to answer.

OpenAI researchers have noted that training and evaluation reward guessing over acknowledging uncertainty. The model has no internal representation of “I don’t know.” It has probability distributions, and it picks the most likely next token even when every candidate is wrong.

Data quality and coverage gaps

Your model’s knowledge comes entirely from the datasets it was trained on. Gaps, biases, and errors in those datasets propagate directly into outputs.

  • Insufficient training data on niche topics means the model interpolates, generating plausible but fabricated information

  • Stale corpora mean the model cannot reflect events or changes after its knowledge cutoff

  • Overfitting to narrow distributions also contributes: a model that has memorized specific phrasings rather than underlying concepts is more likely to hallucinate when queries stray from familiar patterns

  • Source-reference divergence in pretraining material teaches the model that generating ungrounded text is acceptable behavior

  • OCR and formatting artifacts from PDF-to-text conversion can introduce errors that the model treats as fact

Your inference configuration directly affects how often a model hallucinates. Higher temperature values increase randomness in token selection, which can improve creativity but also increases the likelihood of factual inaccuracies. Decoding strategies that promote diversity, like top-k sampling, are positively correlated with increased hallucination.

Foundation models also memorize knowledge in their parameters during pre-training, which creates overconfidence. Anthropic’s 2025 interpretability research on Claude identified internal circuits that decide whether the model has enough information to answer. Hallucinations occurred when these circuits were incorrectly inhibited, causing the model to generate plausible but untrue responses about topics it recognized but did not actually know.

Real-world AI hallucination examples

Your understanding of how hallucinations in AI play out becomes concrete when you see them in high-stakes contexts. These are not hypothetical scenarios.

You have likely heard about the Mata v. Avianca case. In May 2023, attorney Steven Schwartz submitted six fake case precedents generated by ChatGPT to the Southern District of New York. The judge described one of the fabricated opinions as “bordering on nonsensical” and issued a $5,000 fine.

This was not an isolated incident. Adatabase maintained by a researcher at HEC Paris tracked more than 1,300 court and tribunal decisions involving hallucinated citations worldwide as of April 2026.

In April 2026,Sullivan & Cromwell submitted an apology to a U.S. Bankruptcy Court after opposing counsel discovered hallucinated legal citations in their filing. The same month, a former assistant U.S. attorney was fired after submitting a brief containing fabricated quotes and false citations.

Wrong answers in high-stakes professional contexts

Your organization faces real liability when AI outputs are treated as authoritative. In February 2024,Air Canada was ordered to pay damages and honor a bereavement fare policy hallucinated by its support chatbot. The tribunal rejected the airline’s argument that the chatbot was a “separate legal entity.”

Deloitte submitted reports containing fabricated academic sources to both the Australian government and the Government of Newfoundland and Labrador in 2025, resulting in partial refunds and public scrutiny. These examples show that even sophisticated organizations can be caught off guard.

Hallucinations in scientific and medical literature

Your research workflows are not immune. Astudy analyzing 115 references provided by ChatGPT-3.5 found that 47% were entirely fabricated, while another 46% cited real references but extracted incorrect information. Only 7% were both real and accurate.

Meta’s Galactica, designed to reason about scientific knowledge, was pulled after just three days in 2022 when it generated fabricated citations attributed to real researchers.

Researchers at Mississippi State University documented cases where ChatGPT invented DOIs and author names for papers about tick-borne diseases. This failure mode is especially dangerous in medical contexts where clinicians might act on fabricated information.

Consumer-facing failures: product recommendations and support chatbots

You have probably seen the more widely publicized examples. Google’s Bardincorrectly claimed that the James Webb Space Telescope captured the first images of an exoplanet. ChatGPT fabricated financial numbers when asked to write a news article about Tesla’s quarterly results. When asked for song lyrics, it invented entirely new ones rather than admitting it did not have the text.

If your product surfaces AI-generated content to consumers, these failures directly erode user trust. In the case of AI overviews in search results, they can spread misinformation at a scale that is hard to contain.

Implications and risks

Your exposure to hallucination risk scales with the stakes of your application. Understanding these categories of risk helps you prioritize your mitigation efforts.

You face two distinct legal risks:

  • Your AI system might generate defamatory or misleading content that exposes you to litigation

  • The regulatory landscape is tightening, and courts have repeatedly held that organizations are responsible for the outputs of their AI tools, not the AI vendors

Adversarial attacks add another dimension. Bad actors can manipulate model inputs to produce specific hallucinated outputs, creating security vulnerabilities in systems that depend on AI-generated content for decision-making.

Reputational and financial consequences

Your brand is associated with the outputs your AI system produces publicly. The Air Canada case cost the airline not just the tribunal judgment but significant reputational harm. Deloitte’s AI-generated report failures made international headlines. For startups and smaller companies, a single high-profile hallucination incident can set back months of trust-building.

Risks in education and research

Your team might not think of education as a primary concern, but hallucinated content in research pipelines has downstream effects on everything you build. A 2024 University of Mississippi study found that 47% of AI-generated student citations had incorrect titles, dates, or authors. Some nonexistent phrases like “vegetative electron microscopy” have appeared in published research papers after becoming embedded in model corpora, creating a feedback loop where hallucinated content trains the next generation of models.

Detecting and reducing hallucinations with Mastra

Your hallucination mitigation stack needs to span evals, tracing, and observability. Stitching together separate tools for each function creates integration overhead and blind spots.

Mastra is an open-source TypeScript framework that provides evals, tracing, and observability for AI agents in a single integrated layer. Every agent run produces a trace: a tree of spans showing which model was called, what tokens flowed in and out, how long each step took, and where failures occurred.

You inspect these traces in the Studio during development and export them to OpenTelemetry-compatible backends in production.

The eval and observability interface, showing how agent runs are scored against configurable metrics for factuality, faithfulness, and custom rubrics.

For hallucination detection specifically, the framework supports LLM-as-a-judge scoring with custom rubrics that let you define domain-specific factuality criteria. You can run classification evals, tool-calling evals, and multi-turn conversation evals that grade entire agent trajectories. Model routing across 90+ providers through one interface means you can switch judge models or agent models without rewriting your evaluation pipeline.

import { Agent } from "@mastra/core/agent";
import { FaithfulnessMetric } from "@mastra/evals/llm";
const faithfulness = new FaithfulnessMetric(judgeModel);
const result = await faithfulness.measure({
  input: "What year was the Eiffel Tower built?",
  output: agent.response,
  context: retrievedDocuments,
});
console.log(result.score); // 0.0 – 1.0

Build your first hallucination-resistant agent with Mastra.

Hallucination in modalities beyond text

Your hallucination concerns should not stop at text generation. Every modality that uses generative AI has its own hallucination failure modes.

Text-to-image models and object hallucination

You will notice that image generation models like Stable Diffusion and Midjourney routinely generate objects, features, and spatial relationships that were not requested and do not make sense. A well-documented example is OpenAI’s Sora generating video of the Glenfinnan Viaduct with an extra rail track, a second chimney on the train, and carriages that bend unnaturally.

Google’s Gemini generated historically inaccurate images depicting Nazi-era soldiers as people of color, which led Google to pause image generation involving people entirely. For you as a developer, these are not just cosmetic mistakes. They are structural hallucinations in visual output that can undermine any application relying on generated imagery.

Transcription and speech models

Your audio transcription pipeline is also susceptible. Text-to-speech and speech-to-text systems can introduce words, phrases, or entire sentences that are not present in the source audio. These errors are particularly dangerous in:

  • Medical dictation: a hallucinated drug name could affect patient care

  • Legal transcription: fabricated phrases could alter the record

  • Accessibility contexts: downstream consumers trust the transcript as faithful to the original

Multimodal models: seeing things that are not there

You should expect multimodal models to combine the hallucination risks of every modality they span. A model processing both image and text inputs can hallucinate by misidentifying objects in an image, generating text descriptions of features that do not exist, or fabricating relationships between visual elements and textual queries. Object detection systems have been shown to produce false positives when adversarial noise is introduced into images.

How to reduce hallucinations

Your mitigation strategy should layer multiple techniques. No single approach eliminates artificial intelligence hallucinations, but combining them significantly reduces their frequency and impact.

The table below compares the most widely used approaches:

TechniqueWhen to useEffectivenessImplementation complexity
High-quality training dataModel fine-tuning or pre-trainingHigh for in-domain accuracyHigh (data curation, cleaning)
RAGDomain-specific Q&A, knowledge-intensive tasksHigh when knowledge base is authoritativeMedium (vector store, retrieval pipeline)
Prompt engineeringAny model integrationModerate, varies by taskLow (no infrastructure changes)
Temperature and output constraintsAll inference callsModerate for factual tasksLow (configuration change)
Continuous testing and red-teamingPre-deployment and ongoingHigh for catching regressionsMedium (eval pipeline, labeled data)
Human-in-the-loop reviewHigh-stakes outputsVery high for individual outputsHigh (reviewer time, routing logic)

Monitoring loop showing how continuous feedback from production outputs can be routed back into model evaluation and retraining to reduce hallucination frequency over time.

Use high-quality, domain-specific data

You get better outputs when your model is trained or fine-tuned on high-quality training data that is relevant to your domain. Clean, well-structured, representative datasets reduce the coverage gaps that force models to interpolate. Remove duplicates, correct errors, and ensure your data reflects the distribution of queries your system will actually handle.

Retrieval-augmented generation to ground outputs in verified sources

You can ground your model’s responses in verified, up-to-date information by implementing retrieval-augmented generation. It retrieves relevant documents from a knowledge base at inference time and provides them as context to the model, reducing its reliance on parametric memory.

This approach is especially effective for domain-specific applications where your curated content is authoritative. The model generates answers conditioned on retrieved evidence rather than its potentially stale or incomplete pretraining corpus.

Prompt engineering: scoping instructions and constraining response format

You reduce hallucination surface area by writing precise prompts that constrain the model’s response space. Chain-of-thought prompting forces the model to show its reasoning, making fabrications easier to detect. Scoping instructions like “answer only based on the provided context” limit the model’s tendency to fill gaps with fabricated information.

Structured output formats, such as JSON schemas or specific templates, further constrain the response and make it easier to validate programmatically.

Limiting model responses and requiring citations

You can reduce hallucinations by setting clear boundaries on what the model should and should not do. Lower temperature values reduce randomness. Requiring the model to cite specific sources from its provided context creates an audit trail you can verify. Filtering tools and probabilistic thresholds limit outputs to high-confidence responses.

If the model cannot support its answer with a citation from the provided context, it should say so rather than fabricate one.

Continuous testing, red-teaming, and human oversight

Your evaluation process should extend well beyond pre-deployment testing. Red-teaming exercises, where you deliberately try to elicit hallucinations, expose failure modes before your users find them. Automated regression testing catches regressions when you update prompts, models, or retrieval pipelines.

Human oversight remains your final backstop. A human reviewer with domain expertise can catch hallucinations that automated checks miss, especially in high-stakes applications where the cost of a false output is severe.

Detecting and monitoring hallucinations in production

Your pre-deployment testing will not catch everything. Production systems need continuous monitoring because an AI hallucination can surface when a model returns 200 OK while silently delivering fabricated information.

Agent trace hierarchy illustrating how each model call, tool invocation, and workflow step is captured as a span, enabling you to pinpoint where hallucinated content was generated.

Automated evaluation metrics for factuality and faithfulness

You measure hallucination frequency by running automated evals that score model outputs against known-good references. Faithfulness metrics check whether the response is supported by the provided context. Factuality metrics compare claims against external reference sources. Tools like SelfCheckGPT sample multiple responses for the same prompt and flag inconsistencies as likely hallucinations.

LLM-as-a-judge approaches use a separate model to evaluate the primary model’s outputs against custom rubrics, giving you scalable scoring that adapts to your domain-specific accuracy requirements. Anthropic’s research on Constitutional AI demonstrates how evaluation models can be trained to catch specific categories of factual error, an approach you can adapt for your own hallucination detection pipeline.

Tracing and logging individual model calls

Every step of your AI pipeline deserves visibility. When an agent calls a model, invokes a tool, retries a failed call, and branches into a sub-workflow, you need a trace that shows exactly what happened. Each model call should log inputs, outputs, latency, and token usage as individual spans in a trace hierarchy.

This level of observability lets you identify which specific call in a multi-step chain produced the hallucinated content, rather than just detecting that something went wrong at the end.

Explainable AI techniques, such as attention visualization and saliency mapping, can help you trace which input tokens most influenced a hallucinated output. A production-grade observability layer gives you this tracing out of the box, with OpenTelemetry-compatible export for production backends.

Human-in-the-loop review workflows

Your production system benefits most from human review at the edges. This does not mean reviewing every output manually. It means setting confidence thresholds, flagging edge cases, and routing uncertain outputs to a human reviewer before they reach the end user. The review process itself generates labeled data that improves your automated evals over time.

Getting started

AI hallucinations are a structural feature of how large language models work, not a bug that will disappear with the next model release.

Your mitigation strategy should combine grounding techniques with rigorous evaluation, production tracing, and human oversight, treating detection as an ongoing engineering discipline rather than a one-time checklist. If you are building agents, Mastra gives you evals, tracing, and observability in one framework to catch hallucinated outputs before they reach users.

Frequently asked questions

What is an AI hallucination?

A hallucination is a response generated by an AI system that contains false or misleading information presented as fact. The model produces fluent, confident output that is not grounded in its source material or provided context. Common forms include fabricated citations, invented statistics, and factual errors stated with high confidence.

Why do large language models hallucinate in the first place?

Large language models hallucinate because they are optimized to predict the most likely next token, not to verify factual accuracy. When the pretraining corpus is sparse on a topic, the model fills gaps with statistically plausible continuations. Higher temperature settings, diversity-promoting decoding strategies, and overconfident parametric memory all increase hallucination likelihood.

Does AI still hallucinate in 2026?

Yes. While newer models like GPT-4o and Claude 3.5 have lower hallucination rates than their predecessors, no current model has eliminated hallucinations entirely. Research published in 2024 proposed that hallucination is an innate limitation of transformer-based systems, not a solvable engineering problem. Mitigation reduces frequency but does not achieve zero.

Is it possible to stop AI from hallucinating entirely?

No. Researchers have proposed that hallucination is an inherent property of how LLMs generate text from probability distributions. You can reduce how often a model hallucinates through grounding techniques, prompt engineering, lower temperature settings, and continuous evaluation. Complete elimination would require fundamentally different architectures than current transformer models.

Which AI models tend to hallucinate the most?

Smaller and older models generally hallucinate more than larger, newer ones. Meta’s Galactica was pulled after three days due to severe hallucinations. Early ChatGPT versions based on GPT-3.5 showed high fabrication rates in citation tasks. Larger models with RLHF fine-tuning, like GPT-4, hallucinate less frequently but still do so on knowledge gaps and edge cases.

How does RAG reduce hallucinations?

RAG retrieves relevant documents from a verified document store at inference time and provides them as context to the model. This grounds the model’s response in specific, curated evidence rather than relying on potentially stale parametric memory. RAG is most effective when your curated content is authoritative and up-to-date for your domain.

What metrics can developers use to measure hallucination frequency?

You can use faithfulness scores that check whether responses are supported by provided context, factuality metrics that verify claims against external sources, and consistency checks that compare multiple responses for the same prompt. LLM-as-a-judge approaches provide scalable scoring with custom rubrics. SelfCheckGPT flags hallucinations by detecting inconsistencies across sampled outputs.

How should a production AI system be tested for hallucinations before deployment?

Start with automated evaluation suites that score outputs on factuality and faithfulness against known-good datasets. Run red-teaming exercises that deliberately probe edge cases and knowledge gaps. Implement tracing so every model calls logs inputs, outputs, and latency. Set up human-in-the-loop review for high-stakes outputs, and run regression tests on every prompt or model change.

Share:
Aron Schuhmann
Aron SchuhmannHead of Demand Generation

Aron Schuhmann is the Head of Demand Generation at Mastra. A career-long B2B SaaS marketer, he has worked at the intersection of AI and developer tools since 2015, serving as an early growth and demand-generation hire at MightyAI (acquired by Uber), Gatsby (acquired by Netlify), and OctoAI (acquired by NVIDIA).

All articles by Aron Schuhmann
Sam Bhagwat

Sam Bhagwat is the founder and CEO of Mastra. He co-founded Gatsby, which was used by hundreds of thousands of developers. A Stanford graduate and veteran of web development, he authored 'Principles of Building AI Agents' (2025).

All articles by Sam Bhagwat