Introduction
Large Language Models (LLMs) demonstrate a remarkable capacity for retrieving single facts, such as identifying the first president of the United States. However, their performance often degrades significantly when faced with multi-hop reasoning. This occurs when a prompt refers to an entity indirectly (e.g., "The first president of the United States fought in the..."). To answer correctly, the model must first resolve the indirect description to a specific identity ("George Washington") and then link that identity to the target fact ("Revolutionary War").
Research suggests that LLMs often possess the necessary underlying knowledge but fail to successfully retrieve and link it during the forward pass. Traditional solutions like fine-tuning or Reinforcement Learning from Human Feedback (RLHF) are computationally expensive and risk "catastrophic forgetting," where correcting one reasoning path inadvertently damages others. This paper presents a more surgical, interpretability-driven approach to localize and correct these specific reasoning failures using two novel tools: Memory Injections and Attention Lens.
Methodology
1. Memory Injections
Memory Injections are a gradient-free "activation engineering" method. Rather than modifying the model's weights, researchers intervene on the hidden activations—specifically the residual stream—during inference. By identifying a "missing" entity (the memory) required for the reasoning hop, the researchers encode this entity into the model's latent space and add it to the output of specific attention heads.
The study explored three distinct encoding styles for these injections:
- Unembed: Utilizing the transpose of the output unembedding matrix.
- Embed: Utilizing the input embedding matrix.
- Layer-wise: Passing the memory through the first $N$ layers of the model to generate a context-aware representation. While this method is the most accurate, it is computationally intensive ($1.7 \times 10^9$ FLOPs) compared to the lightweight "Embed" and "Unembed" styles ($7.4 \times 10^3$ FLOPs).
2. Attention Lens
Building upon the "Logit Lens" concept, the Attention Lens uses learned transformations to map the high-dimensional outputs of individual attention heads back into human-readable vocabulary tokens. This allows for a granular view of what information a specific head contributes to the final prediction, effectively serving as an auditor for the model's internal reasoning process.
Experimental Setup
The effectiveness of these methods was evaluated across three datasets:
- 2WMH: 1,000 programmatically generated prompt pairs derived from the 2WikiMultiHopQA benchmark.
- Hand: A manually curated dataset of 106 high-quality prompt pairs designed for superior grammatical and factual accuracy.
- Part of Speech (POS) Dataset: A subset of the Corpus of Contemporary American English used to analyze how injecting different word types (nouns, verbs, conjunctions) influences model behavior.
Testing spanned a variety of architectures, including GPT-2 (Small, Large, XL), GPT-Neo (125M to 2.7B), and GPT-J (6B).
Key Insights and Results
Attention Heads as Primary Retrievers
The study confirms that attention heads, rather than Feed-Forward Networks (MLPs), serve as the primary engines for retrieving memories during multi-hop reasoning. Reasoning failures are not distributed globally; they are often localized to specific layers and heads that fail to resolve the implicit subject of a prompt.
Performance and Precision
Targeted memory injections yielded substantial performance gains, increasing the probability of the desired next token by an average of 45% to 424% across various model-dataset combinations. Crucially, this intervention is highly specific. Injecting irrelevant common words (e.g., "apple") generally degraded performance, indicating that the success of the injection depends entirely on the relevance of the memory to the prompt's context.
Bias Localization
Beyond reasoning, the Attention Lens proved capable of pinpointing specific heads responsible for racial bias in GPT-2 Small. This suggests that interpretability tools can be used not only to improve performance but also to audit and mitigate harmful model behaviors.
Discussion and Future Work
While promising, the research identifies several avenues for further development. The current "Hand" dataset is small, necessitating larger, more diverse reasoning benchmarks. Additionally, the Attention Lens currently relies on the model's unembedding matrix, which may not be perfectly tuned for intermediate layers; future iterations may utilize layer-specific learned projections.
Furthermore, the current process of identifying the "memory" for injection is manual. The authors suggest that future systems could automate this by using unsupervised algorithms to connect LLMs to external knowledge bases, creating a dynamic, real-time injection system. Finally, while this study focused on GPT-style transformers, extending these techniques to modern instruction-tuned models like Llama or Mistral remains a priority.
Summary updated