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.
| Type | Description | Example |
|---|---|---|
| Factual errors | The model states something verifiably wrong | Assigning the wrong date to a historical event or misattributing a quote |
| Fabrications | The model invents entities entirely | Non-existent research papers, fake legal cases, or fictional people with plausible-sounding credentials |
| Inconsistencies | The model contradicts itself within the same response, or contradicts the source material it was given | Stating two different dates for the same event in one output |
| Source-reference divergence | The model cites a real source but extracts incorrect information from it | A 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
Modeling-related causes: temperature, decoding, and overconfidence
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.
Fabricated legal citations in court filings
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.
Legal and regulatory exposure
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.0Build 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:
| Technique | When to use | Effectiveness | Implementation complexity |
|---|---|---|---|
| High-quality training data | Model fine-tuning or pre-training | High for in-domain accuracy | High (data curation, cleaning) |
| RAG | Domain-specific Q&A, knowledge-intensive tasks | High when knowledge base is authoritative | Medium (vector store, retrieval pipeline) |
| Prompt engineering | Any model integration | Moderate, varies by task | Low (no infrastructure changes) |
| Temperature and output constraints | All inference calls | Moderate for factual tasks | Low (configuration change) |
| Continuous testing and red-teaming | Pre-deployment and ongoing | High for catching regressions | Medium (eval pipeline, labeled data) |
| Human-in-the-loop review | High-stakes outputs | Very high for individual outputs | High (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.

