TL;DR
Large language models (LLMs) frequently hallucinate with high self-reported confidence, making confidence estimation and context evaluation in retrieval-augmented generation (RAG) difficult. This paper shows that an LLM’s internal activations—specifically from the very first generated token—can predict answer correctness with ~75% accuracy, enabling early generation auditing. Furthermore, a lightweight metric combining context attention and parametric knowledge scores distinguishes between helpful and misleading retrieved contexts far better than asking the model directly.
What Problem Does This Paper Address?
Retrieval-Augmented Generation (RAG) reduces factual errors by injecting external knowledge into prompts. However, RAG pipelines face two major failure modes:
- Confidence Estimation: LLMs are poorly calibrated—they generate incorrect statements with unwarranted confidence, making it hard to decide when retrieval is necessary.
- Context Efficacy: LLMs can be easily misled by irrelevant or factually incorrect retrieved snippets ("polluted context"), and asking models to self-assess the quality of their context via prompting is fragile.
The authors investigate whether mechanistic interpretability tools can solve both problems by peering directly into model internals.
Methods
The authors frame their investigation around two core research questions:
-
RQ1: Estimating Correctness via Model Internals
The authors train lightweight classifiers (Random Forests and MLPs) on internal model representations to predict a binary label: whether the generated answer is correct. They evaluate several internal feature sets: -
Logit Lens and Tuned Lens Features: Decoding intermediate layer activations into vocabulary space to measure entropy, the rank of the chosen token, nucleus top-$p$ membership, and cross-entropy across layers.
- Hidden States: Direct raw activations ($h \in \mathbb{R}^d$) extracted from the first generated token across layers (with per-dimension z-score normalization).
- Parametric Knowledge Score (PKS): The Jensen-Shannon divergence between probability distributions before and after feed-forward (FFN) layers, measuring how much FFN layers shift token probabilities.
- RQ2: Estimating Context Efficacy
To evaluate whether external context helps or hurts, they compare a context's log-likelihood gain against an internal-state metric: $$\Psi(Q, C) = \text{ECS}(Q, C) - \lambda \cdot \text{PKS}(Q, C)$$ Here, External Context Score (ECS) measures the cosine similarity between the final token hidden state and the representations of the most attended context tokens, while PKS tracks reliance on internal weights. Relative context utility $\Delta \Psi$ tests whether the model's internals can tell apart correct ($C_{\text{correct}}$), incorrect/misleading ($C_{\text{incorrect}}$), and topically irrelevant ($C_{\text{irrelevant}}$) passages.
Datasets
Experiments were conducted on six open-weight LLMs (LLaMA-3-8B-Instruct, LLaMA-2-7B/13B-Chat, Qwen-2.5-3B/7B-Chat, and Gemma-2-9B-It) across two benchmarks:
- TriviaQA: Used for open-domain short-answer QA (6,557 filtered validation examples split 80/20 for training/testing classifiers). For RQ2, gold evidence documents were used as correct context, and GPT-4o was used to synthetically construct structurally similar incorrect contexts (entity swapping) and low-similarity irrelevant contexts. GPT-4o served as the answer-correctness judge.
- MMLU: Used for multiple-choice QA (14,042 train examples, 1,531 validation test examples) to assess generalizability across formats (without context evaluation).
Key Insights and Ideas
- LLMs "know" before they finish speaking: A classifier trained solely on the hidden states of the first output token performs almost as well as classifiers observing all tokens. This enables real-time, low-latency auditing to abort or correct hallucinated generations early.
- Internal layers carry more predictive signal than the final layer: Classifiers trained on representations from intermediate layers consistently achieved higher AUC-ROC scores than those trained on final-layer features alone.
- Vanilla hidden states rival complex lens transformations: Despite Logit and Tuned Lens projecting representations back to vocabulary space, raw z-score normalized activations performed comparably, demonstrating that correctness signals are natively encoded within the latent geometry.
- Prompting fails where internals succeed: While asking the LLM to output numerical confidence yields severe overconfidence and barely beats random guessing, internal activations clearly separate correct from incorrect contexts.
Key Results
- Answer Correctness (RQ1):
- Prompting baselines hovered close to majority-class accuracy (often achieving AUC-ROC scores between 0.50 and 0.60, especially on LLaMA-2).
- Classifiers trained on Logit Lens features reached 75%–85% AUC-ROC on TriviaQA and up to 94% AUC-ROC on MMLU (Qwen-2.5-7B).
- Classifiers trained on first-token hidden states achieved ~75% accuracy and 0.62–0.78 AUC-ROC across models.
- Context Efficacy (RQ2):
- In distinguishing correct from incorrect contexts ($C_{\text{correct}} > C_{\text{incorrect}}$), the internal metric $\Delta \Psi$ succeeded in 79.2% of cases on average, dramatically outperforming verbalized prompt-based estimation (19.9% with answers, 21.4% without answers).
- For distinguishing correct from irrelevant contexts ($C_{\text{correct}} > C_{\text{irrelevant}}$), $\Delta \Psi$ succeeded in 84.3% of cases on average (vs. 65.9% and 78.6% for prompting baselines).
Limitations and Future Work
- Task Scope: Evaluations are limited to short-answer factual QA; long-form generation, multi-step reasoning, and conversational contexts remain unstudied.
- Model Scale and Architectures: Evaluated models are capped at 13B parameters, and all are instruction-tuned. Gemma-2's alternating sliding-window attention broke the standard ECS implementation, excluding it from RQ2.
- Downstream Intervention: The authors diagnose and audit correctness and context utility post-hoc, but do not integrate these metrics into active decoding or dynamic retrieval interventions during inference.
Summary updated