AI Dictionary of Terms

Hallucination

A phenomenon where a large language model generates output that is confident, fluent, and grammatically correct, but factually incorrect, nonsensical, or entirely fabricated, with no basis in the input prompt or its training data.

The Simple Version

Imagine a student taking a test who doesn’t know the answer. Instead of writing “I don’t know,” they confidently write a detailed, plausible-sounding essay full of made-up facts, fake historical dates, and invented quotes, hoping the teacher will be impressed by the writing style and not notice the content is completely false.

That’s an AI hallucination. The model isn’t “lying” intentionally; it’s just doing what it was trained to do: predict the next most likely word. Sometimes, the most likely-sounding sequence of words is a complete fabrication.

Detailed Explanation

Hallucinations are a fundamental challenge in generative AI, stemming from the autoregressive nature of LLMs.

Types of Hallucinations:

  1. Intrinsic Hallucination: The output contradicts the provided input context. (e.g., The prompt says “The sky is green,” and the model summarizes it as “The sky is blue.”)
  2. Extrinsic Hallucination: The output adds information that is not present in the input and cannot be verified, often inventing facts, citations, or URLs. (e.g., “According to a 2023 Harvard study…” when no such study exists).

Root Causes:

Mitigation Strategies:

Key Characteristics

Business Context

Hallucinations represent the primary risk to enterprise AI adoption:

Real-World Analogy

A confident but misinformed tour guide. They speak beautifully and with great authority, but they confidently point to a modern building and claim it was the site of a famous 18th-century battle. The delivery is perfect; the facts are entirely wrong.

Code Example

# Demonstrating hallucination mitigation via strict prompting
from openai import OpenAI

client = OpenAI()

# A prompt designed to reduce hallucination
def get_safe_answer(question: str, context: str) -> str:
    system_prompt = """
    You are a factual assistant. Answer the question based ONLY on the provided context.
    If the context does not contain the answer, you MUST reply exactly with: 
    "I do not have enough information to answer that based on the provided context."
    Do not make up facts, dates, or names.
    """
    
    response = client.chat.completions.create(
        model="gpt-4",
        messages=[
            {"role": "system", "content": system_prompt},
            {"role": "user", "content": f"Context: {context}\n\nQuestion: {question}"}
        ],
        temperature=0.0 # Low temperature reduces creative/random generation
    )
    
    return response.choices[0].message.content

# Test case
context = "The company was founded in 2010 by Jane Doe."
question = "Who was the CEO in 2015?"

print(get_safe_answer(question, context))
# Output: "I do not have enough information to answer that based on the provided context."
# (Prevents the model from hallucinating a name)

Common Misconceptions

Sources & Further Reading