LLM Internal States Reveal Hallucination Risk Faced With a Query

Ziwei Ji, Delong Chen, Etsuko Ishii, Samuel Cahyawijaya, Yejin Bang, Bryan Wilie, Pascale Fung

Abstract

The hallucination problem of Large Language Models (LLMs) significantly limits their reliability and trustworthiness. Humans have a self-awareness process that allows us to recognize what we don't know when faced with queries. Inspired by this, our paper investigates whether LLMs can estimate their own hallucination risk before response generation. We analyze the internal mechanisms of LLMs broadly both in terms of training data sources and across 15 diverse Natural Language Generation (NLG) tasks, spanning over 700 datasets. Our empirical analysis reveals two key insights: (1) LLM internal states indicate whether they have seen the query in training data or not; and (2) LLM internal states show they are likely to hallucinate or not regarding the query. Our study explores particular neurons, activation layers, and tokens that play a crucial role in the LLM perception of uncertainty and hallucination risk. By a probing estimator, we leverage LLM self-assessment, achieving an average hallucination estimation accuracy of 84.32% at run time.

Introduction

Large Language Models (LLMs) are notorious for "hallucinating" with confidence, often providing plausible-sounding but factually incorrect answers. This "black box" nature makes them prone to overconfidence, as they lack the explicit metacognition humans use to recognize the limits of their own knowledge. While existing hallucination detection methods are typically "post-hoc"—analyzing text after generation—this approach is computationally expensive and reactive.

This research explores a proactive alternative: Can we detect the risk of hallucination by looking at the model's internal "brain" states while it is still processing a query?

Conceptual comparison between human self-awareness and LLM internal state analysis for hallucination risk estimation.

Methodology: Probing the Internal State

The researchers employed a technique called probing to extract the internal activations of an LLM (primarily Llama-2-7B and Mistral-7B) at the moment it finishes processing an input query.

  1. Feature Extraction: The focus was on the activations of the last token of the input query across all model layers.
  2. The Probing Estimator: A lightweight Multi-Layer Perceptron (MLP) was trained to map these activations to binary labels: "likely to hallucinate" or "likely to be faithful."
  3. Ground Truth Labeling: To train the probe, hallucinations were identified using a composite of ROUGE-L (textual similarity), Natural Language Inference (NLI), and QuestEval (faithfulness).

The study utilized over 700 datasets across 15 diverse NLG tasks from the Super-Natural Instructions benchmark. To specifically test knowledge boundaries, they curated a "Seen/Unseen" dataset using BBC news from 2020 (pre-cutoff) and 2024 (post-cutoff).

Key Insights and Ideas

The study reveals that hallucination risk is geometrically encoded within the model's internal states. The activations triggered by a query look fundamentally different when the model encounters a concept it has not memorized or "seen" during training.

t-SNE visualizations of LLM internal states for known (blue) and unknown (pink) queries across Dialogue, QA, and Translation tasks.
  • Layer Depth: Early layers handle syntax, while the "truthfulness" signal resides in deeper layers associated with high-level semantic processing.
  • Uncertainty Sensors: Mutual Information analysis identified specific neurons that act as "uncertainty sensors," showing distinct activation patterns for unknown queries.
  • Trigger Entities: Visualization via Grad-CAM showed that unfamiliar named entities (e.g., rare proper nouns or technical terms) are primary drivers of the hallucination signal.

Results and Performance

The probing estimator demonstrated high effectiveness and efficiency:

  • Accuracy: It achieved an average accuracy of 84.32% in predicting hallucinations across 15 tasks and 80.28% in distinguishing between seen and unseen queries.
  • Efficiency: Probing is extremely fast, taking only 0.05 seconds per sample. This is significantly faster than likelihood-based methods (1.36s) or external metrics like QuestEval (10.25s), making it suitable for real-time applications.
  • Task Specificity: While internal features are shared within a task, hallucination patterns do not generalize perfectly across different task types (e.g., QA vs. Translation).

Limitations and Future Work

While the results are consistent across Llama-2 and Mistral, future research is needed to evaluate larger or proprietary models where internal states are less accessible. Additionally, the reliance on automated metrics for ground truth labeling introduces some noise. Future work aims to refine these probes for better cross-task generalization and to incorporate human-in-the-loop evaluations for higher-quality data construction.

Summary updated

BibTeX
@inproceedings{ji2024llm,
  author = {Ziwei Ji and Delong Chen and Etsuko Ishii and Samuel Cahyawijaya and Yejin Bang and Bryan Wilie and Pascale Fung},
  title = {{LLM Internal States Reveal Hallucination Risk Faced With a Query}},
  booktitle = {BlackBoxNLP @ EMNLP},
  year = {2024},
  url = {https://openreview.net/forum?id=vNoXjWNh2G},
}
Figure