Extending sparse feature circuit findings to in-context learningScaling sparse feature circuit finding for in-context learning
The authors use TVC and the adapted SFC on Gemma 1 2B to decompose simple ICL into detection and execution features, and state the two are causally connected.
- In simple ICL, task vectors can induce zero-shot behavior, but feeding them directly into SAE mixes in irrelevant features. The authors aim to identify causally effective interpretable components on Gemma 1 2B.
- Use Task Vector Cleaning to optimize SAE weights on the zero-shot loss with an L1 penalty, collapsing the task vector into execution features. Then adapt SFC: aggregate by token type, change the loss, use zero ablation, and find earlier detection features in intermediate layers.
- On Gemma 1 2B, the average faithfulness of the 500-node circuit is 0.6. Execution features are mainly on arrow (Table 1), detection features mainly on output (Table 2). The authors state that ablating detection directions reduces execution activations; cross-task decreases largely stay within the original task.
- The authors state the analysis is limited to the simple task vector setting, which is only a subset of ICL in practice, and SFC is centered on Gemma 1 2B. TVC also covers Phi-3, Gemma 2 2B and 9B. The paper does not report the number of repetitions or statistical tests.
- Evaluated models
- Gemma-1 2BGemma-2 2BGemma-2 9BPhi-3 3B
- Benchmarks
- Todd et al. (2024) function vector tasksalgo_firstalgo_secondalgo_lastFineWeb
- Metrics
- faithfulnessIndirect Effectrelative loss decreaseactivation massaccuracy
The paper uses sparse autoencoders (SAEs) to study the mechanism of in-context learning (ICL) in large language models, identifying abstract SAE features that encode task knowledge; their latent vectors can causally induce the model to perform tasks zero-shot, consistent with the existing conclusion that ICL is mediated by task vectors. The authors adapt the sparse feature circuit method of Marks et al. (2024) to Gemma-1 2B, which is 30 times larger in parameters, and more complex ICL tasks, finding that task vectors can be well approximated by a sparse sum of SAE latent variables. The study also finds task-detection features that activate at earlier positions in the prompt and detect whether the task is complete; these features are causally connected to task-execution features through attention and MLP sublayers.
Paper analysis
What problem does this paper attempt to solve?
The authors use SAE and an adapted SFC to decompose detection and execution features of ICL on Gemma 1 2B.
Can SAE explain ICL on larger models, not just at the level of single features or high-level interventions.
- Scenario: ICL allows models to adapt to new tasks without fine-tuning. The authors state that compared to IOI, subject-verb agreement, and Bias-in-Bios, ICL is more complex and more important.
- Existing gaps: The authors state that most recent SAE work either explains only single SAEs or performs high-level interventions without explaining downstream computation. Task vectors can induce zero-shot behavior, but feeding them directly into SAE mixes in irrelevant features.
- Approach: The authors propose TVC to extract task-execution features; and adapt SFC from Marks et al. (2024) to ICL on Gemma 1 2B to find earlier task-detection features.
- Claimed connection: Detection features connect via attention and MLP sublayers to execution features; turning off detection directions also turns off execution directions. The authors state this facilitates future control or monitoring of ICL to improve safety or capability.
- Scale claim: Abstract says Gemma-1 2B parameter count is 30 times that of models commonly used in previous end-to-end circuit studies; contribution 1 says 10–35× (Section 1).
What related research exists?
Related work follows three lines: circuits, ICL task vectors, and SAEs; the authors state this paper decomposes task vectors into SAE circuits.
Mechanistic Interpretability
- Features and circuits: Olah et al. (2020) frame this direction with features and circuits; vision models can be inspected by hand (Cammarata et al., 2020).
- Finding circuits: Manual patching is seen in Wang et al. (2022) et al.; automatic discovery in Conmy et al. (2023), Syed et al. (2023), Bhaskar et al. (2024). The text directs readers also to Miller et al. (2024).
- SFC: Marks et al. (2024) do attribution on an SAE basis and propose Sparse Feature Circuits. The authors adapt this method.
ICL and Task Vectors
- ICL research: Brown et al. (2020) propose ICL. Dong et al. (2024), Min et al. (2022), and Peng et al. (2023) discuss applications, high-level mechanisms, and limitations, respectively.
- Induction heads: Elhage et al. (2021) and Olsson et al. (2022) find they partly account for ICL. The authors state they do more than induction (Goldowsky-Dill et al., 2023) and are not sufficient alone to explain complex task following.
- Task vectors: Hendel et al. (2023) and Todd et al. (2024) provide residual directions that can induce tasks in zero-shot. The authors state they do not explain how the direction forms or which interpretable components compose it.
Sparse Autoencoders
- Dictionary learning: SAEs are seen in Ng (2011) and Bricken et al. (2023), used to address superposition (Elhage et al., 2022). Training improvements include Rajamanoharan et al. (2024b), Bussmann et al. (2024), and Braun et al. (2024).
- Circuit tools: Cunningham et al. (2023) apply automatic circuit discovery to small language models. Dunefsky et al. (2024) propose transcoders, which the authors include in the Gemma 1 SAE suite.
Baselines and Data
- Comparisons: TVC is compared against the original task vector, direct SAE reconstruction, and ITO (Smith, 2024) at target L0 values of 5 and 20. Task data derives from Todd et al. (2024), with 3 additional array extraction tasks.
The authors state this paper uses SAEs to analyze the overall computation of ICL, uses TVC to fill in the components task vectors do not explain, and then applies SFC to Gemma 1 2B. The authors also treat Wang et al.'s label words as a similar result and state the regression-style white-box work in Appendix H is not this paper's direction.
How does the paper address this problem?
TVC collapses the task vector into execution features, and the adapted SFC then finds earlier detection features.
First use Task Vector Cleaning (TVC) to extract execution features from the task vector, then use the adapted Sparse Feature Circuits (SFC) on Gemma 1 2B to find detection features. SAEs are trained on the residual stream and attention outputs; MLPs use transcoders; the architecture is Gated SAE, converted to JumpReLU at implementation.
Task Vectors and Direct Decomposition
- Extraction: Follow Hendel et al. (2023) and Todd et al. (2024). At a specified layer, average the residual stream over the "→" in multiple ICL prompts.
- Usage: Adding it to a zero-shot forward pass can induce task behavior. The authors state it encodes the abstract task, not specific input–output pairs.
- Layer selection: In Figure 2, intermediate layers have a stronger effect on task loss than earlier and later layers. Gemma 1 2B uses layer 12 as the target layer.
- Failed decomposition: On Gemma 1 2B target layers, direct SAE reconstruction averages over 10 nonzero features, and the effect on task loss drops. The authors attribute this to out-of-distribution. ITO also cannot maintain the effect with few features.
Task Vector Cleaning
- Objective: Optimize SAE weights for the task vector. The loss is the negative log-likelihood after zero-shot steering plus an L1 penalty: L = LNLL(θ) + λ‖θ‖1.
- Steps: Initialize with the SAE decomposition of the task vector, reconstruct, then steer and minimize the loss. Figure 4 presents the cleaning result as 2–4 interpretable features, compared with 10–20 noisy features.
- Implementation: Appendix D collects residuals from 16 16-shot prompts; training and evaluation each use 24 zero-shot pairs. Gemma 1 uses a learning rate of 0.15, up to 1000 steps, stopping when L0 is unchanged for 50 consecutive steps, around 100–200 steps.
- Execution features: The authors call them task-execution features. They activate on task-relevant examples in natural text, peaking one token before task completion.
Adapted SFC
- Nodes: A node is an "SAE feature × token type," aggregating effects across tokens of the same type. Types are Prompt, Input, Arrow, Output, Newline, Extra.
- Loss: The original SFC uses log p(y|x) on the last pair. The authors state this often gives task features high negative IE on other examples. They change it to include all pairs except the first, to amplify the task circuit's effect relative to the copying circuit.
- Metrics: IE is approximated with attribution patching. Faithfulness is Faithfulness(C)=(m(C)−m(∅))/(m(M)−m(∅)). The authors switch to zero ablation, stating it better matches SAE sparsity.
- Search range: Only layers 10–17 are searched (18 total). The authors state earlier layers mainly handle token-level information and have worse IE approximation (Appendix E.2). Edges are not fully ablated, same as Marks et al. (2024).
Detection Features
- Definition: The authors call them task-detection features. They activate when the task is completed in the training data, located at the output token, unlike execution features which peak before completion.
- Connection: Both feature classes have high IE in the circuit and connect through attention output and transcoder nodes. Detection features also use TVC. Steering selects layer 11, execution features at layer 12; Appendix G states layers 10 and 11 are both suitable.
- Causal test: Match the strongest detection and execution features per task by steering effect, fix attention patterns, ablate the detection direction, and measure whether execution activation drops.
What experiments did the paper conduct?
On Gemma 1 2B, the average faithfulness of the 500-node circuit is 0.6; execution features are biased toward arrow, detection features toward output.
Experimental Setup
- Models: SFC and main steering on Gemma 1 2B. TVC scans also include Phi-3 3B, Gemma 2 2B, Gemma 2 9B. Gemma 2 uses Gemma Scope SAE, others use the authors' self-trained SAE.
- Tasks: Derived from Todd et al. (2024), plus algo_first, algo_second, algo_last. Appendix A has task table. The paper does not give total samples per task.
- SAE Training: FineWeb, learning rate 1e-3, Adam betas 0.0 and 0.99, 150M (±100) tokens. Per-layer residual SAE, attention output SAE, and transcoder, 18 layers total.
- TVC Baselines: Original task vector, direct SAE reconstruction, ITO with target L0 of 5 and 20. Metric is relative log-likelihood improvement over zero-shot, averaged across tasks.
- SFC Protocol: IE approximated on a batch of few-shot examples, ablation evaluated on held-out batch of same task. Metrics: faithfulness, zero ablation, layers 10–17. Paper does not report batch size or number of repetitions.
- Steering: Gemma 1 2B positive uses 32 pairs of zero-shot, scale 15. Detection steering added on output of fake pairs (Appendix G). Negative uses 16 prompts, each with 32 ICL examples.
Main Results
Result Value Source Average faithfulness of 500-node circuit C 0.6 Section 4.1.3, Figure 7; Gemma 1 2B Number of nodes with faithfulness 0.6 after ablation of layers 11–12 around 10-60 Section 4.1.3 Mass of execution features on arrow 89.80% Table 1, averaged across tasks; table note does not specify model Mass of detection features on output 96.76% Table 2, averaged across tasks; table note does not specify model - The authors state this faithfulness aligns with the complex scenarios in the original SFC paper; to reduce complement task performance to a similar degree, hundreds of features need to be turned off, whereas the original needed only dozens.
- The authors state execution features mainly fall on arrow, detection features almost exclusively on output, consistent with their two roles. Table 1 also lists output 6.46%, input 3.2%, newline 0.54%, prompt 0.00%; Table 2 also lists input 3.22%, newline 0.01%, arrow 0.0%, prompt 0.0%.
- Figure 8: Main text says ablating high-IE nodes reduces faithfulness to 0.3, figure caption says reduces by 0.7. The authors state the decrease largely stays within the target task; exceptions are similar tasks, such as different translations, and person language vs. location language.
Task Vector Cleaning
- Layer-wise comparison: On Figure 2, the authors state cleaning before layer 14 is similar to original task vector. Direct SAE reconstruction and ITO are baselines; main text does not give per-layer values.
- Sparsity: Main text says active SAE features reduce by 70% (Figure 3, Gemma 1 2B and other models), while maintaining or improving impact on loss. Appendix D.1 says across multiple scales, architectures, and SAE configurations, reduction is 50–80%, maintaining impact on loss; higher target L0 is better.
- Relative to ITO: The authors state TVC often improves task vector loss, active features can reduce to one-third; ITO rarely improves, and almost always worse than TVC. Solid lines in Figure 3 are means across model and SAE combinations; main text does not give per-point readings.
Steering and Task Specificity
- Positive heatmap: Figure 6 is normalized and truncated, values below 0.2 set to 0 (Appendix F). The authors state most high-effect features have little impact on unrelated tasks; similar tasks like translation affect at least partially within-group tasks. Translation-to-English tasks share an English-to-foreign execution feature, requiring additional language encoding features.
- Unnormalized figure: On Figure 24, the authors state that in task vectors, usually only a few execution features can individually boost that task; others have weaker, less specific effects.
- Negative and Gemma 2: In Appendix F.1, negative steering task specificity is lower than positive; the authors state non-task-specific features also have significant impact, so steering alone is insufficient. In Appendix F.2, the authors state Gemma 2 2B execution feature specificity is relatively close to Gemma 1; 65k cleaned task vectors seem to contain more strong-effect features, possibly due to too low l1 coefficient.
Detection Features to Execution Features
- Detection steering: On Figure 10, the authors state detection features are usually task-specific, except for similar tasks. Appendix G says layers 10 and 11 are more suitable, declining afterward.
- Causal heatmap: On Figure 11, the authors state ablating detection features reduces activation of corresponding execution features; translation tasks are particularly interconnected. Connections for person profession and present simple gerund are weak, the authors think further investigation is needed. Main text does not give reduction percentages.
- Example circuit: Figure 12 shows a high-IE subcircuit: detection features on output connect via an attention feature to transcoder and residual execution features on arrow. Max activation examples come from SAE training distribution.
Other Ablations and Analyses
- With L1 coefficient between 0.001 and 0.025, the authors state performance relatively maintained while active features reduce (Appendix D.1; no per-point values).
- Optimal task vector layer: Gemma 1 is 12, main text says Gemma 2 is 16, Phi-3 is 18, Gemma 2 9B is 20.
- Gemma 2 2B scans 16k and 65k and multiple target L0. Learning rates: Gemma 1 2B, Phi-3, Gemma 2 2B 65k are 0.15; Gemma 2 2B 16k is 0.3; Gemma 2 9B is 0.05, early stopping at 200 steps.
- Negative steering: among scales 1 to 30, choose scale that reduces accuracy of at least one task by at least 0.1; Gemma 2 2B positive scales selected per feature between 30 and 300.
- Appendix E.2: Before layer 6, correlation between IE approximation and true effect is low; non-residual SAE only sufficient in the latter third of the model. Main text does not give correlation coefficients. Analysis mainly focuses on layers 10–15.
- Dead feature criterion: 1000-batch buffer density below 5e-6, or not triggered in 2000 steps (Appendix B).
What are some points that can be further explored?
The authors state the task vector setting covers only part of ICL, and SFC is mainly done on Gemma 1 2B.
Limitations and Future Directions Noted by the Authors
- Task scope: The analysis focuses on the simple task vector setting, which the authors state represents only a subset of ICL applications in practice (Limitations).
- SFC model: The SFC analysis centers on Gemma-1 2B. The same paragraph states execution features are found across multiple architectures and scales, consistent with the cross-model task vectors reported by Todd et al. (2024) (Limitations).
- Competing features: Multiple competing execution and detection features are common in the analysis. The authors state they remain highly task-specific and relate this to the regeneration ability commonly seen in LLM interpretability (Limitations).
- Future tasks: The conclusion states these advances lay the groundwork for analyzing more complex tasks and larger models (Conclusion).
- Code plans: The authors plan to release the JAX training code and the full suite of Gemma 1 2B SAEs after paper acceptance (Conclusion; Appendix B says the same).
Experimental Coverage
- SFC, faithfulness, and cross-task ablations are done on Gemma 1 2B, with circuit search restricted to layers 10–17 out of 18 total (Section 4.1.3).
- TVC and the L1 sweep cover Gemma 1 2B, Phi-3, Gemma 2 2B, and Gemma 2 9B; Gemma 2 uses Gemma Scope, with widths including 16k and 65k (Appendix D.1).
- The main positive steering figure is Gemma 1 2B layer 12 (Figure 6). The appendix has negative steering for that model, and positive steering for Gemma 2 2B 16k and 65k (Appendix F).
- Tasks are the Todd et al. (2024) derived set plus 3 array extraction tasks; Appendix A gives the task table. Appendix H states over 20 token-to-token tasks were considered.
- Faithfulness uses zero ablation; IE is approximated on few-shot batches and evaluated on held-out batches. The paper does not report the batch size, number of repetitions, random seeds, or statistical tests.
Summarize the main content of the paper
Use SAEs, TVC, and the adapted SFC to decompose simple ICL in Gemma 1 2B into detection and execution features.
- Positioning: Use SAE circuit analysis on simple in-context learning with Gemma 1 2B.
- Problem: Task vectors can induce tasks in zero-shot, but feeding them directly into an SAE yields a messy decomposition. The authors want to find components with causal roles and how they connect along the prompt.
- Method: TVC optimizes SAE weights on the zero-shot task loss with an L1 penalty, yielding execution features active before completion. The adapted SFC aggregates nodes by token type, rewrites the loss, and finds detection features on the output in intermediate layers; attention patterns are fixed during causal tests.
- Results: On Gemma 1 2B, the average faithfulness of a 500-node circuit is 0.6; if only layers 11–12 are ablated, the authors write that around 10–60 nodes suffice to reach the same faithfulness (Section 4.1.3). Execution features have a Mass of 89.80% on the arrow (Table 1), and detection features 96.76% on the output (Table 2); neither table caption states the model. The authors state that ablating the detection direction lowers the corresponding execution activation, and cross-task decreases largely stay within the original task, except for similar tasks such as translation.
- Cleaning: Appendix D.1 states that across multiple models and SAEs, TVC reduces active features by 50–80% while maintaining the task vector's effect on loss; the main text also writes a 70% reduction (Figure 3). The authors state that ITO rarely improves the task vector loss.
- Authors' conclusion: The authors state that SAEs can serve as a circuit analysis tool on larger models, and detection and execution are two causally relevant feature classes in ICL. The authors state this prepares for more complex tasks and larger models, and plan to release the Gemma 1 2B SAEs and training code upon acceptance.