From Interpretability to Performance: Optimizing Retrieval Heads for Long-Context Language Models
Youmi Ma, Naoaki Okazaki
TL;DR
The paper investigates whether mechanistically identified retrieval heads can be leveraged to enhance long-context processing in large language models. It introduces RetMask, a retrieval-head masking approach that generates contrastive supervision by comparing outputs from the full model and an ablated variant, trained with Direct Preference Optimization. Results show strong gains for models with concentrated retrieval heads (notably Llama-3.1), modest improvements for models with distributed retrieval (Olmo-3), and robust improvements on long-context tasks such as generation with citations and passage re-ranking, while preserving general capabilities. The work provides mechanistic insights into when retrieval-head optimization is effective and demonstrates how interpretability findings can translate into practical performance gains, offering a diagnostic for model developers and a path toward better long-context LLMs.
Abstract
Advances in mechanistic interpretability have identified special attention heads, known as retrieval heads, that are responsible for retrieving information from the context. However, the role of these retrieval heads in improving model performance remains unexplored. This work investigates whether retrieval heads can be leveraged to enhance the long-context capabilities of LLMs. Specifically, we propose RetMask, a method that generates training signals by contrasting normal model outputs with those from an ablated variant in which the retrieval heads are masked. This mechanism-based approach achieves substantial improvements: +2.28 points on HELMET at 128K for Llama-3.1, with +70% gains on generation with citation and +32% on passage re-ranking, while preserving performance on general tasks. Experiments across three model families reveal that the effectiveness depends on retrieval head organization: models with concentrated patterns of retrieval heads respond strongly, while those with distributed patterns show limited gains. This mechanistic relationship validates the function of retrieval heads and demonstrates that mechanistic insights can be transformed into performance enhancements.
