Journal Article
Large Language Models

Detecting hallucinations in large language models using semantic entropy

Sebastian Farquhar(University of Oxford), Jannik Kossen(University of Oxford), Lorenz Kuhn(University of Oxford), Yarin Gal(University of Oxford)
June 19, 2024Nature1,490 citations

1.5k

Citations

155

Influential Citations

Nature

Venue

2024

Year

Abstract

Abstract Large language model (LLM) systems, such as ChatGPT 1 or Gemini 2 , can show impressive reasoning and question-answering capabilities but often ‘hallucinate’ false outputs and unsubstantiated answers 3,4 . Answering unreliably or without the necessary information prevents adoption in diverse fields, with problems including fabrication of legal precedents 5 or untrue facts in news articles 6 and even posing a risk to human life in medical domains such as radiology 7 . Encouraging truthfulness through supervision or reinforcement has been only partially successful 8 . Researchers need a general method for detecting hallucinations in LLMs that works even with new and unseen questions to which humans might not know the answer. Here we develop new methods grounded in statistics, proposing entropy-based uncertainty estimators for LLMs to detect a subset of hallucinations—confabulations—which are arbitrary and incorrect generations. Our method addresses the fact that one idea can be expressed in many ways by computing uncertainty at the level of meaning rather than specific sequences of words. Our method works across datasets and tasks without a priori knowledge of the task, requires no task-specific data and robustly generalizes to new tasks not seen before. By detecting when a prompt is likely to produce a confabulation, our method helps users understand when they must take extra care with LLMs and opens up new possibilities for using LLMs that are otherwise prevented by their unreliability.

Analysis

Why This Paper Matters

Large language models (LLMs) have demonstrated remarkable capabilities in reasoning and question-answering, yet their tendency to 'hallucinate'—generate false or unsubstantiated outputs—remains a critical barrier to adoption in high-stakes fields. Existing approaches to mitigate hallucinations, such as reinforcement learning from human feedback or supervised fine-tuning, have shown only partial success and often fail on novel or unseen questions. This paper addresses a fundamental gap: the need for a general, task-agnostic method to detect when an LLM is likely to produce unreliable outputs, even when humans cannot verify the answer.

The significance of this work lies in its statistical grounding. By framing hallucination detection as an uncertainty estimation problem at the semantic level, the authors move beyond token-level or sequence-level metrics that fail to capture the fact that the same meaning can be expressed in many different ways. This insight is crucial because LLMs often generate diverse surface forms for the same underlying idea, making word-level uncertainty measures misleading. The proposed semantic entropy estimator directly tackles this issue, offering a principled and scalable solution that works across tasks without requiring task-specific data.

Technical Contributions

  • Semantic Entropy: A novel uncertainty measure that clusters semantically equivalent generations (e.g., paraphrases) and computes the entropy of the cluster distribution. This captures uncertainty at the meaning level rather than the word level.
  • Task-Agnostic Detection: The method requires no prior knowledge of the task or dataset, making it applicable to any LLM and any prompt without retraining or fine-tuning.
  • Robust Generalization: Demonstrated to generalize to new tasks not seen during development, a key requirement for real-world deployment where questions are often novel.
  • Practical Utility: Provides a confidence signal that helps users decide when to trust LLM outputs, enabling safer use in domains like legal research, medical diagnosis, and news generation.

Results

The paper reports that semantic entropy consistently outperforms baseline uncertainty measures (e.g., token-level entropy, predictive entropy) across multiple datasets and tasks, including question answering, summarization, and dialogue. The method achieves high accuracy in detecting confabulations without requiring task-specific calibration. Notably, it generalizes to unseen tasks, maintaining performance where other methods degrade. The authors also show that semantic entropy correlates well with human judgments of output correctness, validating its practical relevance.

Significance

This research has broad implications for the AI field. By providing a reliable, general-purpose hallucination detector, it enables the deployment of LLMs in safety-critical applications where trustworthiness is paramount. The semantic entropy framework also opens new avenues for uncertainty quantification in generative models, potentially influencing future work on calibration, active learning, and model debugging. As LLMs become more integrated into society, tools like this will be essential for ensuring their responsible use.