IC-004Retrieval heads are sparse, universal, and causally responsible for long-context retrieval in LLMs

Wenhao Wu, Yizhong Wang, Guangxuan Xiao, Hao Peng, Yao Fu

SourceRetrieval Head Mechanistically Explains Long-Context Factuality

The paper identifies a small subset of attention heads, termed 'retrieval heads,' which are primarily responsible for retrieving relevant information (copy-paste or paraphrase) from long contexts. Across all tested model families (Llama, Yi, Qwen, Mistral, Mixtral) and variants, only about 5% of attention heads are retrieval heads, and they exist intrinsically in base models. Causal intervention by masking retrieval heads sharply degrades performance on the needle-in-a-haystack task, while masking random non-retrieval heads has little effect. The study further shows that these heads are dynamically activated based on context and that their role extends to extractive QA and chain-of-thought reasoning.

Evidence
interventional
Key metric
Accuracy drops from 94.7% (20 random heads masked) to 63.6% (top 20 retrieval heads masked) on NIAH for Llama-2-7b-80k; retrieval heads are <5% of all heads; performance drops below 50% when masking >50 retrieval heads.
Caveat
The retrieval score threshold of 0.1 and the focus on copy-paste behavior for detection may not capture all retrieval functions; tasks heavily reliant on parametric knowledge (e.g., MMLU without CoT) are less affected.
Model
Llama 2 / Llama 2 base Llama 2 7B, Mistral 7B / Mistral / Mistral 3 7B / Mistral-0.2-7B / Mistral-v0.1 Mistral 7B Instruct v0.2, Mistral 7B v0.2, Mixtral 8x7B / Mistral 8x7B Instruct / Mixtral 46.7B / Mixtral 8x7B Instruct / Mixtral-instruct-8x7b Mixtral 8x7B v0.1, Yi 6B 200K, 6B, 34B 200K, Qwen1.5 14B, 14B Chat, Jamba
Datasets
Needle-in-a-haystack [eval]
Methods
Head masking [primary]
Related work
Induction heads [compared-to], Attention sinks [compared-to]
Extraction
automatic-extraction