NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Interpreting Key Mechanisms of Factual Recall in Transformer-Based Language Models

Ang Lv, Kaiyi Zhang, Yuhan Chen, Yulong Wang, Lifeng Liu, Ji-Rong Wen, Jian Xie, Rui YanarXiv 2024 · DOI

Introduction

Large Language Models (LLMs) demonstrate remarkable factual knowledge, yet the internal mechanisms by which they retrieve and process this information remain largely opaque. While previous theories suggested a two-phase process of "Argument Formation" and "Function Application," the precise roles of specific architectural components—Attention heads and Multi-Layer Perceptrons (MLPs)—have been unclear. This paper presents a detailed "reverse-engineering" of the factual recall circuit across several model families, including GPT-2, OPT, and Llama-2.

Methodology

To map these internal circuits, the researchers utilized three primary mechanistic interpretability techniques:

  1. Activation Patching: Swapping activations between "clean" and "corrupted" prompts to isolate causal components.
  2. Logit Lens: Decoding intermediate layer states to observe the model's "internal predictions" at each step.
  3. MLP Decomposition: A novel approach using multivariable linear regression to separate an MLP's output into a filtered version of its inputs (attention head signals) and its own unique "transformation" vector.

The Three-Step Factual Recall Pipeline

The core finding is a universal three-step pipeline that governs how a model recalls a fact like "The capital of France is Paris."

The three-step pipeline for factual recall: (1) Extraction of the topic entity, (2) Activation/filtering by MLP, and (3) Transformation to the target answer.
  1. Extraction: Specific "mover" attention heads identify the subject (e.g., "France") and move its representation to the final sequence position.
  2. Activation: An intermediate MLP layer acts as a gate, amplifying the signal from these mover heads while suppressing irrelevant noise from other heads.
  3. Transformation: A deeper MLP layer applies the "function" (e.g., get_capital). It adds a vector that shifts the internal representation from the subject ("France") toward the answer ("Paris").

Empirical Results and the "Final Layer Saboteur"

Quantitative analysis confirms that factual recall is concentrated in specific layers and heads. As shown in Figure 5, the probability of the correct answer typically spikes in the middle-to-late layers before being refined.

Quantitative analysis of factual recall, showing probability distributions across layers and head-specific contributions.

A surprising discovery was the "anti-overconfidence" mechanism in the final layer. The researchers found that the final MLP often suppresses the correct answer in favor of "safer," more frequent tokens (like punctuation or common words). This is likely a defensive behavior learned during training to avoid high-penalty errors. By identifying and bypassing these suppression vectors, the researchers were able to increase GPT-2's zero-shot recall probability from 5.53% to 25.93%.

Conclusion

This work provides a mechanistic map of factual recall, revealing that LLMs use a structured pipeline to move and transform information. The discovery of the final-layer suppression mechanism suggests that models may "know" more than they initially reveal, and that targeted interventions can significantly unlock this latent knowledge. Future work will focus on how these circuits are initially formed and how in-context learning primes these mechanisms.

Summary updated

BibTeX
@misc{lv2024interpreting,
  author = {Ang Lv and Kaiyi Zhang and Yuhan Chen and Yulong Wang and Lifeng Liu and Ji-Rong Wen and Jian Xie and Rui Yan},
  title = {{Interpreting Key Mechanisms of Factual Recall in Transformer-Based Language Models}},
  year = {2024},
  eprint = {2403.19521},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.19521},
}
Figure