Abstract
Large Language Models (LLMs) frequently generate fluent but factually incorrect text, a phenomenon known as hallucination. This research investigates whether LLMs possess internal signals that distinguish truth from fiction. We identify "In-Context Sharpness" as a key mechanistic signal: correct factual generations exhibit sharp activations across relevant input prompt tokens, whereas hallucinations show blurry, high-entropy activations. Based on this, we introduce Activation Decoding, a real-time steering method that penalizes high-entropy candidate tokens. Our results demonstrate significant improvements in factuality across benchmarks like TruthfulQA and HotpotQA, with an 8.6-point increase in TruthfulQA scores for Llama-2-70B.
Introduction
Despite the impressive capabilities of LLMs, their tendency to hallucinate remains a significant barrier to reliable deployment. Current mitigation strategies often involve external knowledge retrieval (RAG) or iterative self-correction, which can be computationally expensive. This paper explores a more fundamental question: does the model's internal state provide a signal of impending hallucination? By analyzing hidden states, we seek a mechanistic indicator of factuality that requires no external tools or additional training.
Methods: In-Context Sharpness and Activation Decoding
The core finding of this study is the concept of In-Context Sharpness. When a model generates a correct token, its internal representation is strongly anchored to specific tokens in the prompt. Conversely, hallucinations are characterized by "blurry" activations across the prompt tokens.
Contextual Entropy
We quantify this sharpness using Contextual Entropy. Low entropy indicates a sharp connection to the context, signaling a likely factual generation. High entropy suggests a disconnection, acting as an alert for potential hallucination.
Activation Decoding
We propose Activation Decoding, a constrained decoding algorithm that incorporates this signal. During generation, the model calculates contextual entropy for candidate tokens and applies a penalty to those with high entropy. This effectively "mutes" hallucinations and boosts tokens grounded in the context. To maintain efficiency, entropy values for the vocabulary are pre-computed against the static prompt prefix.
Results
The proposed method was evaluated on TruthfulQA, TriviaQA, HotpotQA, and Natural Questions.
Performance and Efficiency
Activation Decoding consistently outperformed standard greedy decoding and baselines like DoLa and ITI:
- TruthfulQA: Llama-2-70B saw an 8.6-point increase in the "Truth*Info" score.
- HotpotQA: F1 scores increased by an average of 16.1% across model sizes.
- Efficiency: The method introduces a ~23% latency increase over greedy decoding but remains ~7% faster than DoLa, making it practical for real-time use.
The Informative Layer
Analysis revealed that intermediate layers (e.g., layer 26 in Llama-2-7B) are the most "informative" for factuality. These layers act as a bridge where the model extracts knowledge from the context to form predictions. As shown in the performance metrics, the entropy signal in these layers provides a strong discriminative power for factuality.
Discussion and Limitations
While Activation Decoding significantly mitigates hallucinations, it has limitations. It primarily addresses "retrieval-style" hallucinations where the model possesses the knowledge but fails to anchor it. It cannot correct errors where the model lacks the underlying factual knowledge (out-of-distribution). Additionally, the choice of the "informative layer" and penalty strength currently requires some tuning, though these parameters show good generalization across tasks.
Conclusion
In-context sharpness provides a robust internal signal for LLM factuality. By leveraging this signal through Activation Decoding, we can steer models toward more grounded and truthful generations without the need for external knowledge bases or expensive self-correction loops.
Summary updated