The Internal State of an LLM Knows When It's Lying

Amos Azaria, Tom M. Mitchell

Introduction

Large Language Models (LLMs) have become remarkably proficient at generating human-like text, yet they suffer from a persistent and critical flaw: hallucinations. These models frequently generate factually incorrect statements with a tone of high confidence, creating a significant barrier to their reliable use in sensitive applications.

This research investigates a fundamental question: Does an LLM "know" it is lying? While the output text may be false, the authors hypothesize that the model’s internal hidden states contain a representation of truthfulness that is not always reflected in the final token selection. This paper introduces SAPLMA (Statement Accuracy Prediction, based on Language Model Activations), a method that probes these internal states to detect truthfulness with high accuracy.

The "Commitment" Trap

A key insight of this work is the mechanism by which hallucinations occur. Because LLMs are autoregressive—generating text token-by-token—they can fall into a "commitment trap." If a model selects a plausible but incorrect word early in a sentence based on statistical associations, it is often forced to complete the rest of the sentence in a way that is consistent with that initial error, even if its internal state recognizes the factual discrepancy.

The Commitment Trap: How autoregressive generation can force a model into a false completion after an initial incorrect token choice.

As illustrated above, once the model commits to a specific path (e.g., calling Pluto the "smallest"), the subsequent tokens are statistically constrained to follow that logic, leading to a factually incorrect statement despite the model potentially "knowing" the correct facts about other celestial bodies like Eris.

Methodology: SAPLMA

SAPLMA treats the LLM as a feature extractor rather than a simple text generator. The process involves three main steps:

  1. Feature Extraction: Statements are fed into an LLM (such as OPT-6.7b or Llama-2-7b), and the activation values of the hidden layers are recorded.
  2. Classification: A shallow feedforward neural network (MLP) is trained to take these activations as input and predict the probability that the statement is true.
  3. Cross-Topic Generalization: To ensure the classifier learns a general concept of "truth" rather than specific facts, the researchers used a "held-out topic" approach. The model is trained on five topics (e.g., Cities, Inventions, Animals) and tested on a sixth, unseen topic.

To support this, the authors developed a new True-False Dataset containing over 6,000 sentences across six distinct categories, sourced from reliable ground-truth data like Wikipedia and Forbes.

Key Results and Analysis

SAPLMA significantly outperforms standard methods for truth detection. While standard few-shot prompting (asking the LLM if a statement is true) often performs only slightly better than random chance, SAPLMA achieved accuracies between 71% and 83%.

Performance Comparison: SAPLMA significantly outperforms standard prompting (3-shot, 5-shot) and BERT-based baselines across various factual topics.

Layer Sensitivity

The research found that "truthfulness" is a latent feature that is not equally visible in every layer of the model. Middle-to-late layers (such as the 20th or 28th layer in a 32-layer model) typically provide the strongest signal. Interestingly, the very last layer is often less reliable for truth detection, as it is heavily optimized for the specific mechanics of next-token prediction rather than factual representation.

Real-World Hallucinations

Beyond synthetic datasets, the researchers tested SAPLMA on 245 actual LLM-generated statements that were manually fact-checked. SAPLMA achieved an AUC of 0.76 on this set, demonstrating its potential as a real-time monitor for hallucinations in practical applications.

Conclusion and Future Directions

The success of SAPLMA suggests that truthfulness is a distinct, extractable feature within the high-dimensional activation space of an LLM. This opens new avenues for making AI more reliable. Future work will focus on expanding these methods to multi-lingual contexts and developing ways to track truthfulness throughout long, evolving conversations where internal activations change dynamically. While challenges remain—such as ensuring the detector doesn't simply mirror the model's internal biases—this research provides a powerful tool for peering inside the "black box" of LLM cognition.

Summary updated

BibTeX
@inproceedings{azaria2023internal,
  author = {Amos Azaria and Tom M. Mitchell},
  title = {{The Internal State of an LLM Knows When It's Lying}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.68},
}
Figure