LLM-Check: Investigating Detection of Hallucinations in Large Language Models

Gaurang Sriramanan, Siddhant Bharti, Vinu Sankar Sadasivan, Shoumik Saha, Priyatham Kattakinda, Soheil Feizi

Introduction

Large Language Models (LLMs) have achieved remarkable performance across diverse tasks, but they remain notoriously prone to "hallucinations"—generating outputs that sound perfectly plausible but are factually incorrect or entirely fabricated. This unreliability is a major roadblock for deploying LLMs in high-stakes fields like medicine or law.

Current detection methods generally fall into two camps:

  1. Consistency Checks: Prompting the model multiple times to see if the answers match. This is computationally expensive and slow.
  2. Retrieval-Based Methods: Cross-referencing the output against a massive external database. This is hard to scale and depends heavily on the quality of the database.

To address these limitations, researchers introduce LLM-Check, a novel framework designed to detect hallucinations within a single response. By analyzing the internal "signatures" of the model—specifically hidden activations and attention maps—LLM-Check eliminates the overhead of multiple generations or external searches, achieving massive speedups and higher accuracy across diverse real-world scenarios.

The LLM-Check Framework

The core idea behind LLM-Check is to look "under the hood" at the model's internal state during text generation. The researchers propose three main approaches to quantify uncertainty and detect fabrications:

  • Eigenvalue Analysis of Internals: The framework analyzes the "geometry" of the model's latent space. By calculating the log-determinant of the covariance matrix of hidden activations (the Hidden Score) and the diagonal of the attention kernel maps (the Attention Score), LLM-Check identifies structural patterns that strongly correlate with non-factual information.
  • Output Token Uncertainty: LLM-Check refines traditional metrics like perplexity and logit entropy into Windowed Logit Entropy. Instead of averaging scores over a long, mostly correct response, this metric focuses on specific "bursts" of uncertainty within a sentence.
  • White-Box vs. Black-Box Settings: In a "white-box" setting, the framework directly analyzes the model generating the text. In a "black-box" setting (e.g., analyzing outputs from closed APIs like GPT-4), LLM-Check uses an auxiliary open-source model (like Llama-2) to "re-read" the text and provide the necessary internal scores via teacher-forcing.

Key Insights and Results

The authors evaluated LLM-Check across several benchmarks, including FAVA-Annotation (fine-grained human labels), SelfCheckGPT (consistency baselines), and RAGTruth (Retrieval-Augmented Generation scenarios).

The Model "Knows" When It's Lying The most profound insight from the study is that hallucinated tokens leave a distinct trace in the model's internal activations. Truthful information tends to be more "consistent" in the latent space, while fabrications create detectable variations in the attention maps.

Attention is All You Need (for Detection) The Attention Score proved particularly powerful. Because attention matrices in autoregressive models are lower-triangular, their eigenvalues are simply the values on the diagonal. This allows for a mathematically grounded "complexity" score that is incredibly cheap to compute, requiring no heavy matrix decompositions.

Taxonomy of Hallucination Detection Hallucination detection isn't one-size-fits-all. The paper provides a helpful taxonomy to categorize detection settings based on whether ground-truth references are available or if multiple model responses are needed.

Massive Speedups and Superior Accuracy By avoiding the "sampling bottleneck" of generating many responses, LLM-Check achieved speedups of 45x to 450x over baselines like SelfCheckGPT. Furthermore, on the FAVA dataset, LLM-Check's Attention Score significantly outperformed baselines like INSIDE and Self-Prompting, achieving much higher AUROC scores (e.g., 72.34 vs. 50.30 for Llama-2-7B). The method also proved highly effective in cross-model, black-box settings, where a smaller proxy model successfully evaluated outputs from larger, closed models.

Limitations and Future Work

While highly efficient, the black-box setting still requires access to an open-source proxy model, which may not be feasible in strictly resource-constrained environments. Additionally, the performance of internal scores varies across different layers of the LLM; middle-to-late layers (e.g., around layer 20 for a 32-layer model) are generally the most informative, but this can vary by dataset.

Ultimately, this paper focuses on finding hallucinations. The authors note that the next logical step is integrating these lightweight detection scores directly into the training loop (e.g., via Reinforcement Learning from Human Feedback) to actively reduce the frequency of hallucinations at the source.

Summary updated

BibTeX
@inproceedings{sriramanan2024llm,
  author = {Gaurang Sriramanan and Siddhant Bharti and Vinu Sankar Sadasivan and Shoumik Saha and Priyatham Kattakinda and Soheil Feizi},
  title = {{LLM-Check: Investigating Detection of Hallucinations in Large Language Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=LYx4w3CAgy},
}
Figure