Which attention heads are more critical for in-context learning?Which Attention Heads Matter for In-Context Learning?
Across 12 models, the authors state that few-shot ICL depends more on FV heads than on induction heads.
- Few-shot ICL has been attributed both to induction heads, which copy the next token, and to FV heads, which encode task vectors. The authors want to distinguish which type of head causally supports few-shot accuracy, and why the two types of scores are correlated.
- On 12 models, compute induction score using attention on repeated random sequences, and FV score using causal mediation after shuffling labels. Mean-ablating the highest-scoring heads, and excluding the other class's top 2% heads to separate correlation. Also examine how heads transition across 8 checkpoints of 7 Pythia models.
- The authors state that FV ablation reduces few-shot accuracy more than induction ablation, and that above 1B with top 2% FV heads retained, the latter is comparable to random ablation. The token-loss difference is the opposite. Many FV heads have high induction scores early that later decline, and the reverse is not seen.
- The authors state that conjecture C1 does not explain FV heads with low induction scores throughout, and suggest removing induction heads during training to see FV. Training dynamics only include 7 Pythia models with 8 checkpoints each; the paper does not report the number of ablation repetitions.
- Evaluated models
- Pythia 70M (EleutherAI/pythia-70m-deduped)Pythia 160M (EleutherAI/pythia-160m-deduped)Pythia 410M (EleutherAI/pythia-410m-deduped)Pythia 1B (EleutherAI/pythia-1b-deduped)Pythia 1.4B (EleutherAI/pythia-1.4b-deduped)Pythia 2.8B (EleutherAI/pythia-2.8b-deduped)Pythia 6.9B (EleutherAI/pythia-6.9b-deduped)GPT-2 (openai-community/gpt2)GPT-2 Medium (openai-community/gpt2-medium)GPT-2 Large (openai-community/gpt2-large)GPT-2 XL (openai-community/gpt2-xl)Llama 2 7B (meta-llama/Llama-2-7b-hf)
- Benchmarks
- Appendix A.7的45个自然语言ICL任务Todd et al. (2024)的ICL任务Feng & Steinhardt (2024)的binding任务Pile合成的重复随机token序列
- Metrics
- few-shot ICL accuracytoken-loss differenceinduction scoreFV score
An arXiv paper by Kayo Yin and Jacob Steinhardt compares induction heads and function vector (FV) heads across 12 language models, and through ablations finds that few-shot in-context learning (ICL) performance mainly relies on FV heads, with this effect increasing with model scale. The study also finds that the two types of attention heads are related: during training, many FV heads initially behave as induction heads before shifting to the FV mechanism. The authors speculate that the induction mechanism helps learn the more complex FV mechanism that ultimately drives ICL.
Paper analysis
What problem does this paper attempt to solve?
Whether few-shot ICL is mainly driven by induction heads or FV heads.
Is few-shot ICL mainly driven by induction heads or function vector (FV) heads?
- Use case: The authors state that large language models can perform new tasks with only a few examples in the prompt, and this ability has been used to adapt pretrained models. Two mechanisms are: induction heads find the next token after the last occurrence of the current token and copy it; FV heads' activations form a compact encoding of the task, and adding it back to the computation can restore ICL without examples.
- Existing divergence: The authors attribute the view that induction circuits are the key mechanism for few-shot ICL to Olsson et al. (2022), Crosbie and Shutova (2024), and Dong et al. (2022). Todd et al. (2024) and Hendel et al. (2023) instead propose function vectors. The authors argue that the results diverge because the operational definitions, metrics, and model sizes of ICL are not the same.
- Core observation: If the two head types are different mechanisms, their positions and memberships should be separate; if the scores are correlated, not controlling for correlation would attribute FV-like behavior to induction ablation.
- This work: Across 12 decoder-only models (70M to 7B) and 45 natural language ICL tasks in Appendix A.7, compare the positions, overlap, few-shot accuracy after ablation, and the transition during Pythia training.
What related research exists?
The divergence comes from the metrics, the correlation between the two types of heads, and the model sizes in prior work.
The introduction and §2 divide related work into induction circuits, function vectors, and how ICL is defined.
Induction heads
- Elhage et al. (2021) — identified induction heads in transformer circuits: when processing a token, attend to the token after its last occurrence.
- Olsson et al. (2022) — on small models with 1–3 layers and attention only, measured ICL by the loss difference between the 500th and 50th tokens in context, and stated that removing induction heads harms that metric. The authors note that this metric does not closely track few-shot performance.
- Crosbie and Shutova (2024), Bansal et al. (2023) — reported that removing induction heads reduces few-shot accuracy. The authors argue that such ablations (including their own initial ablation without exclusion) do not control for correlation with FV. Singh et al. (2024) and Olsson et al. are classified by the authors as work placing mechanism analysis on small models.
Function vectors
- Todd et al. (2024) — used causal mediation to extract a compact representation of a task from specific attention heads, and adding it back restored ICL without examples. The FV score in this paper follows that framework.
- Hendel et al. (2023) — concurrently proposed that in-context learning forms task vectors. The paper lists it alongside Todd et al. as a source of the FV mechanism, without separately comparing the two.
Definition of ICL
- Brown (2020), Dong et al. (2022), Wei et al. (2023) — cited for the usage of "few-shot learning from prompts without updating parameters." The authors adopt this definition and fix in-context learning to this meaning in the paper.
- Akyürek et al. (2023), Von Oswald et al. (2023) — listed only in the introduction as works studying ICL mechanisms. The paper does not compare methods with them.
Baselines and data
- Ablation controls are clean (no ablation) and random head ablation, plus a setting that excludes the other type's top 2% heads. Tasks come from Todd et al. (2024), plus binding tasks from Feng and Steinhardt (2024); token-loss uses the Pile (Gao et al., 2020).
The authors attribute the divergence from prior conclusions mainly to three points: few-shot accuracy and token-loss difference are not the same phenomenon, the correlation between the two head types is not controlled, and prior mechanism studies lean toward small models. The authors consider metric choice to have the largest impact (§2.3).
How does the paper address this problem?
Use two scores to label heads, then use mean ablation with exclusion to compare causal contributions.
The authors use induction score and FV score to identify two classes of heads, compare causal contributions to few-shot accuracy via mean ablation, and use Pythia checkpoints to see how heads transition.
Identifying induction heads
- Uses TransformerLens. Sequences are 50 random tokens uniformly sampled, then repeated exactly once.
- The score is the sum of attention weights to the next token in the original sequence when processing the repeated segment; averaged over 1,000 sequences, then divided by total attention quality, giving 0 to 1.
- Defined as SI(a,r)=∑i=150 ar′i → ri+1, i.e., head a's attention at repeated-segment position i to the next token in the original sequence.
Identifying FV heads
- Follows Todd et al.'s causal mediation. For task t, first compute the head's average activation on that task's prompts; then randomly shuffle output labels, keeping inputs unchanged.
- Replace the head's activation with the task-conditional average activation, and see how much the model's quantity on the correct output y rises relative to the shuffled prompt. Each prompt is 10 example pairs plus 1 test example.
- Defined as SFV(a|p̃)=f(p̃|a:=āt)[y]−f(p̃)[y], i.e., the difference in the quantity the model assigns to the correct output before and after replacing the activation.
- §2.2 says averaging over 37 tasks, 100 examples per task. §4.1, to avoid leakage between identification and evaluation, splits these 37 tasks into 26 for measuring FV score and 11 for evaluation. The two task counts differ; the paper does not explain this.
Representative sets and ablations
- Take the top 2% by score in each class as the representative set, following Todd et al. (2024). Direct overlap is defined textually as 100×|IH∩ FV|/|IH|, i.e., the intersection of the two top-2% sets as a percentage of the induction representative set.
- Mean ablation replaces a head's output with its average output on task data. The authors say this avoids the out-of-distribution effects of zero ablation. Appendix A.3 additionally does random head-output replacement and zero-vector replacement.
- Exclusion ablation: when ablating n FV heads, take only the n heads with the highest FV score that are not in the induction-score top 2%; the reverse likewise. Ablation proportions are 1%–20%.
Two evaluation measures
- Few-shot accuracy: 10 example pairs plus a query, checking whether the model gives the correct output. Evaluation uses 19 tasks (the above 11 plus 8 new tasks), 100 examples per task. Of the 8 new tasks, 4 are variants of Todd et al. tasks and 4 are binding tasks from Feng and Steinhardt (2024).
- Token-loss difference: loss at token 50 minus loss at token 500 on Pile, averaged over 10,000. The authors reverse the sign relative to Olsson et al.'s difference so that higher is better, and suggest not calling this difference the ICL score anymore.
Training process
- On 8 intermediate checkpoints of 7 Pythia models, record the average scores of the top 2% heads, both scores for individual heads, and checkpoint few-shot accuracy. The paper states total training steps as 143,000.
What experiments did the paper conduct?
The authors state that few-shot accuracy depends more on FV heads, while token-loss difference is more affected by induction ablation.
Experimental setup
- Models: All 12 in Table 2 are analyzed objects. Pythia 70M, 160M, 410M, 1B, 1.4B, 2.8B, 6.9B (all deduped); GPT-2 (117M), GPT-2 medium (345M), GPT-2 large (774M), GPT-2 XL (1.6B); Llama 2 (7B, Hugging Face name Llama-2-7b). Layers, heads, and head dimensions are in Table 2.
- Tasks: Appendix A.7 lists 45 natural-language ICL tasks. Few-shot evaluation uses 19 tasks, 100 examples per task, 10 examples. Number of tasks for FV score: §2.2 says 37, §4.1 says 26. Induction score uses 1,000 synthetic sequences; token-loss uses 10,000 from Pile.
- Controls: clean; random head ablation. Exclusion setup keeps the top 2% of the other class.
- Metrics: few-shot accuracy; token-loss difference; induction score; FV score. The paper does not use a separate LLM judge model, nor does it state whether accuracy is strict string matching or some other criterion.
- Ablation scope: heads in the top 1%–20% of scores. The paper does not report random seeds or number of repetitions.
- Training: 7 Pythia models, 8 checkpoints each. Representative models in Figure 4 are Pythia 160M, Pythia 1B, Pythia 6.9B.
Main results
The main text does not list accuracy readings for each ablation proportion. Figure 1a, Figure 4, and Appendix Figures 8–9 are curves; the converted text has no per-point values, so the table below only includes comparisons stated in the main text.
Condition Few-shot accuracy Token-loss difference Direct ablation, 12 models The introduction says FV ablation hurts accuracy more, and this is consistent across the 12 models and more pronounced in larger models. §4.2 says induction ablation is still greater than random and moves toward FV ablation as the proportion increases Not a main conclusion for this group Exclusion ablation, parameters above 1B The authors say that when keeping the top 2% FV, induction ablation is comparable to random; the reverse still lowers accuracy, and the gap grows with scale (Figure 4, upper row) Not reported separately for above 1B 70M; token-loss below 160M §2.3 and Appendix A.2 say the two types of causal effect are similar at 70M The authors say that below 160M, neither type shows a larger effect than random Token-loss above 345M Not reported separately at this threshold The authors say induction ablation has a larger effect than FV, and the gap shrinks with scale (Figure 4, lower row) - The authors believe that in direct ablation, induction's effect mainly comes from heads that also have high FV score; as long as the top 2% FV heads are kept, ICL can still be done after ablating induction heads. The Figure 1a caption, for Pythia 6.9B, says induction ablation has only a small additional effect relative to random. This is not the same statement as the §4.2 summary of direct ablation.
- The authors believe few-shot accuracy and token-loss difference measure different phenomena, and use this to reconcile the apparent contradiction with Olsson et al.
- The authors say the importance of FV relative to induction increases with scale, and claim this challenges strong versions of universality assumptions in interpretability.
Transitions during training
- Measures the average induction score, FV score, and few-shot accuracy of the top 2% heads across 7 Pythia models and 8 checkpoints (Figure 5, Appendix A.11).
- The authors say induction heads appear around step 1,000, with scores rising steeply and then plateauing or slightly declining; FV heads appear around step 16,000 and then keep rising. Few-shot accuracy starts rising around when induction heads appear and then continues to increase gradually.
- Individual heads (Figure 6): The authors say many heads with high final FV score also had high induction score early, after which the former rises and the latter falls. The authors say they did not see induction heads develop high FV score during training. Figure 1b uses Head 8.17 of Pythia 6.9B as an example; the figure does not mark per-point scores.
Adding FV back to hidden states
- Appendix A.6: Take the top 2% heads by FV score, sum their average outputs on task prompts to get the task's FV, and add it to layer |L|/3. 40 tasks, 1,000 previously unseen examples per task. Controls are shuffled labels and outputs of random heads.
- The authors say that on most models, adding FV restores performance on unshuffled prompts; the exception is Pythia 2.8B. The Figure 14 caption says "recovers most of the model accuracy" and names this exception. The main text does not give per-model accuracy.
- The authors suggest one possible reason is head dimension: in Table 2, Pythia 2.8B has 80, while models with similar parameter counts have head dimension 128. This is the authors' possible explanation.
Other ablations and analyses
- Overlap: 7 of the 12 models have direct overlap of 0 in the top 2%, the rest are 5%–15%; the authors say that in most models, FV heads' induction score is around the 90th–95th percentile, and vice versa (Figure 3). The left panel's gray is overlap with random heads; the main text does not give values for that series.
- Layer position: The authors say induction heads are mostly in the middle-front layers, FV heads slightly deeper (Figure 2, Appendix Figure 19), and say "therefore more abstract" is still speculation. Appendix Figure 19 captions include t-stat and p-value, e.g., GPT-2 is -2.83, 0.05; Llama 2 7B is 0.22, 0.83; Pythia 70M is nan. The main text does not state what was tested.
- Appendix A.5: Induction score is broadly similar across scales; Pythia 1B and 1.4B have higher maximum FV score, with head dimensions 256 and 128 respectively. Pythia 70M and Llama 2 have very low FV scores. The authors flag high head dimension relative to parameter count as a predictor of FV strength (hypothesis H6 in the paper), and say Llama 2's low score may relate to architecture, requiring more experiments to confirm.
- Appendix A.3: The authors say conclusions still hold under random replacement and zero ablation; the main text does not give accuracy for these two ablation types.
- Appendix A.10: The overlap between the two ablated sets increases with the number of ablated heads. The authors use this to argue that exclusion ablation is necessary.
- Appendix Figures 15–18 plot ablation curves by task; the red line is a random baseline on outputs seen in training; the main text does not summarize per-task numbers.
What are some points that can be further explored?
The authors state that conjecture C1 does not explain FV heads with low induction, and suggest interventions during training.
Limitations and future directions noted by the authors
- §6: Conjecture C1 (induction heads are an early form of FV heads) does not explain FV heads whose induction score is low throughout training.
- §6: To further verify C1, future work could remove induction heads during training and see whether FV heads still develop.
- §6: Conjecture C2 (FV heads are a combination of induction and another mechanism) faces a difficulty the authors state: removing FV heads that do not have high induction scores still harms ICL, which is hard to reconcile with the idea that the key function depends on a combined mechanism.
- §7: If induction heads are precursors to FV heads, what makes this step necessary.
- §7: What role do induction heads that remain after training serve.
- §7: Whether other mechanisms could explain ICL more completely.
Experimental coverage
- The analyzed models are the 12 decoder-only models in Table 2: 7 Pythia (70M–6.9B), 4 GPT-2 (117M–1.6B), and Llama 2 7B.
- Few-shot accuracy uses 19 tasks, 100 examples per task, and 10 demonstrations; ablation proportions are 1%–20%, including mean ablation, plus random replacement and zero ablation in Appendix A.3.
- Training curves are only on the 7 Pythia models, with 8 checkpoints each (§5).
- Induction score uses 1,000 synthetic sequences of length 50+50; token-loss uses 10,000 sequences from the Pile; the add-back FV experiment uses 40 tasks with 1,000 examples per task (Appendix A.6).
- The paper does not report the number of ablation repetitions, nor does it list the accuracy for each point in Figure 4 in the main text.
Summarize the main content of the paper
The authors state that few-shot ICL varies more with FV heads, and some FV heads are converted from induction heads.
This work compares two types of attention heads used to explain ICL across 12 decoder-only models.
- Question: Few-shot ICL has been linked both to induction heads, which copy the next token after the last occurrence, and to FV heads, which carry task vectors. The authors ask which type causally supports few-shot accuracy.
- Method: Define induction score using attention on repeated random sequences, and FV score using causal mediation after label shuffling. Perform mean ablation on the highest-scoring heads, and separate correlation by excluding the other type's top 2%. Then examine both scores for individual heads across Pythia checkpoints.
- Two head types: Direct overlap of top 2% is 0 in 7 of 12 models, and 5%–15% in the rest; the authors state that in most models, one type's other score is around the 90th–95th percentile (Figure 3). Induction heads are slightly earlier in layer position, FV heads slightly deeper.
- Ablation: The authors state that with direct ablation, FV heads affect few-shot accuracy more than induction heads, and this is more pronounced in larger models; after exclusion, on models over 1B, induction ablation is comparable to random ablation, while FV ablation still reduces accuracy (§4.2). On 70M, the authors state the two effects are similar.
- Another metric and training: Above 345M, token-loss difference is more affected by induction ablation. The authors state that induction heads appear around step 1,000 and FV heads around step 16,000; many FV heads transition from high induction score to high FV score, and the reverse is not observed.
- Authors' conclusion: The authors argue that few-shot ICL is mainly driven by FV heads, and speculate that the simpler induction mechanism provides a precursor for the later FV mechanism. They also argue that metric definitions and mechanism overlap change interpretability conclusions, and the results challenge strong versions of cross-scale universality.