atlas

Research map / Large language models / Retrieval and knowledge

The Atlas of In-Context Learning: How Attention Heads Shape In-Context Retrieval Augmentation

NeurIPS 2025 · Large language models › Retrieval and knowledge · approach: Retrieval-augmented reasoning · 1 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Uses AttnLRP-based relevance attribution to identify in-context and parametric attention heads in instruction-tuned LLMs, separates task and retrieval heads, and shows that patching their function vectors or attention weights steers QA behavior and enables a probe for knowledge provenance.

Problem

The mechanism by which LLMs use in-context retrieval augmentation (choosing between parametric and contextual knowledge) for question answering is not well understood, and attention-weight analyses are unreliable.

Approach

Apply AttnLRP relevance propagation to attention heads to score each head's contribution in open-book (counterfactual) versus closed-book settings, yielding in-context and parametric heads; further split in-context heads by relevance to question tokens (task heads) versus answer tokens (retrieval heads), then use their outputs as function vectors or reweight their attention to steer generation, an

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Ablate identified in-context heads (ablation)Llama 3.1 · Open-book QA across configurationsrecall: 13.86%-63.84%Hurt
Ablate identified parametric heads (ablation)Llama 3.1 · Closed-book QA across configurationsrecall: 44.26%-68.66%Hurt
Ablate randomly selected heads (ablation)Llama 3.1 · QArecallNo clear effect
Ablate parametric heads (ablation)Llama 3.1 · NQ-Swap counterfactual open-book QArecallHelped
Ablate parametric heads (ablation)Llama 3.1 · NQ-Swap counterfactual open-book QArecall for counterfactual answersHelped
Ablate in-context heads (ablation)Llama 3.1 · NQ-Swap counterfactual QArecall for original answersHelped
Use 20 identified in-context heads instead of 100 AWR heads (ablation)Llama 3.1 · Open-book QArecall reduction after ablationMixed
Extract and patch task-head function vectors rather than random-head vectorsBiography QA · Biography QArecall: +78.75 pointsHelped
Extract and patch parametric-head function vectors rather than random-head vectorsBiography QA · Biography QArecall: 30.41 pointsHelped
Increase retrieval-head attention weights on needle tokens rather than use random headsBiography NIAH · Needle-in-a-haystack retrievalrecall: 83.15 pointsHelped
Select only task heads that are also strong in-context heads, instead of the top 40 task heads (ablation)Biography QA · At which date was he born? (Gemma 2)recall: 99% -> 22%Hurt
Select only task heads that are also strong in-context heads, instead of the top 40 task heads (ablation)Biography QA · At which institution was he educated? (Llama 3.1)recall: 98% -> 96%No clear effect

Surprising findings

Limitations

Experimental setup

Datasets: NQ-Swap TriviaQA DPR Wikipedia dump (Dec 2018) Wikidata biography dataset

Benchmarks: NQ-Swap TriviaQA

Metrics: recall exact match BERT matching (BEM) K-Precision ROC AUC top-1 localization accuracy

Baselines: random heads Attention Weight Recall (AWR) heads

Builds on: AttnLRP function vectors retrieval heads logit lens

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy