TL;DR
Hallucinations = when AI confidently states false information it created, not retrieved Semantic entropy method detects uncertainty patterns (79% effective in production) Build multi-layer detection: cross-reference validation, grounding checks, citation verification Circuit breakers automatically reject high-hallucination-risk outputs before users see them Real cost: one hallucination in healthcare can be a patient's life
In March 2025, a healthcare AI startup shut down after their system recommended a drug interaction that didn't exist. The AI had hallucinated it, invented it with absolute confidence, and a nurse followed the recommendation. The patient survived, but barely. The company didn't.
Hallucinations aren't a theoretical problem anymore. They're a liability crisis. And your QA team needs to own detecting them before production.
What Is a Hallucination, Anyway?
A hallucination is when an LLM generates text that sounds plausible but is factually false, often with absolute confidence.
Key distinction: hallucinations are not typos. They're not stuttering. They're confident fabrications.
USER: "What drug interactions exist between Warfarin and Aspirin?"
CORRECT RESPONSE:
"Warfarin and Aspirin both increase bleeding risk.
This is a documented interaction. Coadministration requires
monitoring of INR levels and patient education."
HALLUCINATED RESPONSE:
"Warfarin and Aspirin interact to form a compound called
Warfaraspirin-7, which is found in 0.02% of patients
and causes temporary vision loss. There is no documented
treatment protocol."
RISK: This sounds plausible. A clinician might believe it.
The interaction doesn't exist. The compound doesn't exist.
The side effect was invented.
In healthcare, finance, law, or compliance contexts, hallucinations are catastrophic. In casual chatbots, they're annoying. Your job: measure the risk and build guards.
Why Hallucinations Happen
LLMs predict the next token based on patterns in training data. When the model has never seen data about a specific topic, it doesn't say "I don't know." Instead, it makes plausible-sounding text that matches the statistical patterns it learned.
This is actually the core strength of LLMs, they're excellent at pattern completion. But pattern completion isn't the same as fact retrieval.
Hallucination risk is highest when:
- The topic is recent (not in training data)
- The query is highly specific (requires exact recall)
- The context window is exhausted (model loses access to source material)
- The model is running hot (high temperature = more creativity = more hallucination)
"Hallucinations aren't bugs. They're features of how neural networks work. Your job is to build detection and guardrails around them, not wait for models to be perfect."
Semantic Entropy: The 79% Solution
Semantic entropy is a technique that measures uncertainty by generating multiple responses to the same prompt and analyzing how different they are semantically.
The idea: if the model is hallucinating, its responses will be inconsistent. If it's retrieving known facts, responses will be consistent (semantically similar), even if worded differently.
PROMPT: "What is the capital of France?"
RUN 1: "Paris is the capital city of France."
RUN 2: "The capital of France is Paris."
RUN 3: "France's capital is Paris."
SEMANTIC ENTROPY: Very low
(All responses are semantically identical)
CONFIDENCE: Fact is reliably true
---
PROMPT: "How many hairs does a human have at age 50?"
RUN 1: "The average 50-year-old has 100,000 scalp hairs."
RUN 2: "Most people at 50 have around 85,000-120,000 hairs."
RUN 3: "Hair count at 50 varies greatly, but typically
ranges from 80,000 to 150,000 depending on genetics."
SEMANTIC ENTROPY: Low-medium
(Similar answer, different ranges; probably reliable)
---
PROMPT: "What neurotransmitter is responsible for smell?"
RUN 1: "Olfactory receptors use dopamine-7."
RUN 2: "Smell is detected by acetylcholine receptors."
RUN 3: "The neurotransmitter for smell is serotonin."
SEMANTIC ENTROPY: Very high
(Completely different answers; likely hallucination)
CONFIDENCE: This answer cannot be trusted
This technique is about 79% effective at detecting hallucinations in production according to recent research. Not perfect, but far better than hoping the model is honest.
Building a Hallucination Detection Pipeline
Layer 1: Semantic Entropy Check
def detect_hallucination_entropy(prompt, model, runs=5, threshold=0.65): """ Generate multiple responses and compute semantic entropy. threshold = confidence that this is a hallucination (0-1 scale) """ responses = [] for _ in range(runs): response = model.generate(prompt, temperature=0.7) responses.append(response) # Convert responses to embeddings embeddings = [embed(r) for r in responses] # Compute pairwise similarities similarities = [] for i in range(len(embeddings)): for j in range(i+1, len(embeddings)): sim = cosine_similarity(embeddings[i], embeddings[j]) similarities.append(sim) # Average similarity = entropy indicator avg_similarity = mean(similarities) entropy_score = 1 - avg_similarity # High entropy = low similarity if entropy_score > threshold: return { "hallucination_risk": "HIGH", "entropy_score": entropy_score, "action": "BLOCK - Do not show user" } else: return { "hallucination_risk": "LOW", "entropy_score": entropy_score, "action": "ALLOW" }Stop Hallucinations Before Users See Them
alt.qa provides real-time hallucination detection, semantic entropy monitoring, and automated grounding checks for production AI systems.
Try alt.qa Free →Sarah Chen Sarah Chen writes about AI quality engineering at alt.qa, built by TheWorkCompany.