Inferensys

Glossary

Hallucination Score

A quantitative metric, often derived from semantic similarity or natural language inference models, that estimates the degree of factual inconsistency in a generated response.
ML engineer managing model versions on laptop, version history visible, technical Git-like workflow.
FACTUALITY METRIC

What is Hallucination Score?

A quantitative metric estimating the degree of factual inconsistency in a generated response, typically derived from semantic similarity or natural language inference models.

A Hallucination Score is a quantitative metric that estimates the degree of factual inconsistency between an AI-generated response and its source material. It operationalizes the detection of fabricated content by applying Natural Language Inference (NLI) models or semantic similarity calculations to measure how well each generated claim is entailed by the provided context.

The score is typically computed by decomposing a generated text into atomic facts, then using a critic model to classify each fact as supported, contradicted, or neutral relative to the grounding documents. The final metric represents the ratio of unsupported claims, enabling automated guardrail systems to trigger rejection or human review when a confidence threshold is breached.

Quantifying Factual Fidelity

Key Characteristics of a Hallucination Score

A hallucination score is not a monolithic metric but a composite signal derived from multiple computational strategies. Understanding its constituent characteristics is essential for engineering reliable guardrails.

01

Semantic Similarity Grounding

Measures the cosine similarity between the embedding of the generated response and the embedding of the source ground-truth text. This technique, often using models like Sentence-BERT or proprietary embedding APIs, quantifies conceptual overlap rather than exact lexical matching.

  • High Score: Indicates strong semantic alignment with the reference.
  • Low Score: Suggests the agent has drifted into unrelated or fabricated territory.
  • Limitation: Fails to detect subtle contradictions where the generated text is topically similar but factually inverted.
02

Natural Language Inference (NLI) Entailment

Utilizes a dedicated NLI classifier to determine if a source document logically entails the generated hypothesis. A hallucination is flagged when the output contradicts the premise or is classified as neutral.

  • Entailment Score: Probability that the generation is strictly supported by the evidence.
  • Contradiction Score: Probability that the generation directly opposes the source.
  • Advantage: Detects factual inversions that semantic similarity misses, such as 'The patient has a fever' vs. 'The patient has no fever.'
03

Self-Consistency Sampling

Leverages the stochastic nature of LLMs by sampling multiple reasoning paths (temperature > 0) for the same prompt. The hallucination score is derived from the entropy or divergence of these outputs.

  • Low Variance: Indicates high confidence and likely factual accuracy.
  • High Variance: Suggests the model is 'guessing' between multiple hallucinated realities.
  • Mechanism: Often uses semantic entropy to cluster equivalent answers before calculating variance, preventing penalization for valid paraphrasing.
04

Retrieval-Augmented Faithfulness

In RAG architectures, the score evaluates if the generated answer is attributable to the specific retrieved chunks. It measures hallucination as the proportion of generated entities or claims that cannot be mapped back to the provided context.

  • Context Precision: Verifies if the model used the right chunk.
  • Context Recall: Verifies if the model missed crucial information.
  • Faithfulness Metric: Calculated as (Number of claims supported by context) / (Total number of claims in response).
05

Uncertainty Quantification (Conformal Prediction)

Applies statistical methods to produce a prediction set with a mathematical guarantee of correctness. Instead of a single output, the agent produces a set of plausible answers.

  • Non-Hallucination Guarantee: The score represents the probability that the true answer lies within the generated set.
  • Abstention Trigger: If the set size exceeds a threshold (e.g., the model must include 50 options to reach 95% confidence), the score is low, and the system abstains from answering.
  • Key Differentiator: Provides a formal, distribution-free risk bound rather than a heuristic score.
06

Chain-of-Verification (CoVe) Self-Correction

An agentic workflow where the LLM generates an initial response, then independently drafts and answers a series of fact-checking questions based on its own output. The hallucination score is the ratio of verification questions that the model fails to answer consistently.

  • Process: 1. Draft response. 2. Plan verifications. 3. Execute verifications. 4. Generate final revised output.
  • Score Derivation: (Failed Verifications) / (Total Verification Questions).
  • Utility: Highly effective for detecting closed-book hallucinations where no external retrieval is available.
HALLUCINATION SCORE

Frequently Asked Questions

A hallucination score is a quantitative metric that estimates the degree of factual inconsistency in a generated response. The following questions address the core mechanisms, calculation methods, and operational integration of this critical evaluation metric for autonomous systems.

A hallucination score is a quantitative metric that estimates the degree of factual inconsistency between a generated response and its source material. It is typically calculated using a Natural Language Inference (NLI) model, such as a fine-tuned DeBERTa or T5 variant, which classifies the relationship between a premise (the source text) and a hypothesis (the generated claim) as entailment, contradiction, or neutral. The score is often expressed as a ratio of contradicted claims to total claims, or as a continuous probability of faithfulness. Alternative methods use semantic similarity via cosine distance between the embeddings of the source and the generated text, where a low similarity score indicates a high probability of hallucination. Advanced implementations decompose long-form text into atomic facts using an LLM, then independently verify each fact against a knowledge base, aggregating the results into a final composite score.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.