Single-Position Intervention Fails: Distributed Output Templates Drive In-Context Learning
Organizations: William A. Shine Great Neck South High School
Abstract
Understanding how large language models encode task identity from few-shot demonstrations is a central open problem in mechanistic interpretability. Prior work uses linear probing to localize task representations, reporting high classification accuracy at specific layers. We reveal a striking dissociation: probing accuracy completely fails to predict causal importance. Single-position activation intervention achieves 0% task transfer across all 28 layers of Llama-3.2-3B-despite 100% probing accuracy at those same positions. This null result is itself a key finding, demonstrating that task encoding is fundamentally distributed. Multi-position intervention-replacing activations at all demonstration output tokens simultaneously-achieves up to 96% transfer (N=50, 95% CI: [87%, 99%]) at layer 8, pinpointing for the first time the causal locus of ICL task identity. We establish the generality of these findings across four models spanning three architecture families (LLaMA, Qwen, Gemma), discovering a universal intervention window at ~30% network depth. Causal tracing uncovers an asymmetric architecture: the query position is strictly necessary (53-100% disruption) while no individual demonstration position is necessary (0% disruption)-resolving a key ambiguity in prior accounts. Crucially, transfer depends on internal representation compatibility, not surface similarity (r=-0.05 vs r=0.31), ruling out trivial explanations. These results establish the distributed template hypothesis: ICL task identity is encoded as output format templates distributed across demonstration tokens, fundamentally reshaping our understanding of how in-context learning operates.
Figures & tables
| Regime | Tasks | Example |
|---|---|---|
| Procedural | uppercase, first_letter, repeat_word, length | “cat” “CAT” |
| Numeric | linear_2x | “5” “10” |
| Semantic | sentiment, antonym, pattern_completion | “happy” “positive” |
| Position | L4 | L12 | L20 |
|---|---|---|---|
| last_demo_token | 100 | 100 | 100 |
| separator | 100 | 100 | 100 |
| first_query_token | 62.5 | 83.3 | 75.0 |
| Method | Position | Layers | Transfer |
|---|---|---|---|
| Transplant | last_demo_token | 0–27 | 0% |
| Transplant | first_query_token | 0–27 | 0% |
| Zero ablation | last_demo_token | 14 | 0% (100% acc) |
| Random ablation | last_demo_token | 14 | 0% (100% acc) |
| Pair | Condition | Transfer | 95% CI |
|---|---|---|---|
| uppercase repeat_word | output_only (L8) | 94% | [84%, 98%] |
| uppercase repeat_word | all_demo (L8) | 96% | [87%, 99%] |
| uppercase repeat_word | input_only (L8) | 0% | [0%, 7%] |
| sentiment antonym | output_only (L8) | 6% | [2%, 16%] |
| Mean across 56 pairs (output_only, L8) | 16.7% | — | |
| Position | Layers | Disruption |
|---|---|---|
| first_query_token | 0–14 | 53–100% |
| first_query_token | 16+ | 0–7% |
| last_demo_token | 0–27 | 0% |
| Pair | True Source | Random | Noise | Shuffled |
|---|---|---|---|---|
| uppercase repeat_word | 95% | 0% | 0% | 55% |
| uppercase first_letter | 0% | 0% | 0% | 0% |
| sentiment antonym | 10% | 0% | 0% | 0% |
| linear_2x length | 0% | 0% | 0% | 0% |
| Mean | 17.5% | 0% | 0% | 9.2% |
| Source Target | Format Difference | Transfer |
|---|---|---|
| uppercase uppercase_period | “WORD” vs “WORD.” | 0% |
| length length_word | “5” vs “five” | 0% |
| repeat_word repeat_comma | “word word” vs “word, word” | 90% |
| reverse reverse_spaced | “olleh” vs “o l l e h” | 5% |
Appendix figures & tables22 assets
Supplementary material from the paper’s appendix.
Appendix
| Task | Input Domain | Transformation | Output Format |
|---|---|---|---|
| uppercase | 4–8 letter words | Single uppercase word | |
| first_letter | 4–8 letter words | Single lowercase letter | |
| repeat_word | 4–8 letter words | “word word” | |
| length | 3–10 letter words | Single digit | |
| linear_2x | integers 1–50 | Integer | |
| sentiment | sentiment words | “positive”/“negative” |
| upper | first | repeat | length | linear | sent | ant | pattern | |
|---|---|---|---|---|---|---|---|---|
| uppercase | – | 0 | 90 | 80 | 100 | 0 | 0 | 0 |
| first_letter | 0 | – | 0 | 0 | 0 | 20 | 0 | 10 |
| repeat_word | 0 | 0 | – | 100 | 50 | 0 | 0 | 0 |
| length | 100 | 0 | 50 | – | 0 | 0 | 0 | 0 |
| linear_2x | 0 | 0 | 0 | 0 | – | 0 | 0 | 0 |
| sentiment | 0 | 10 | 0 | 20 | 0 | – | 0 | 0 |
| Transfer Rate Range | # Pairs | Percentage |
|---|---|---|
| 50% (high transfer) | 7 | 13% |
| 10–49% (moderate) | 10 | 18% |
| 10% (near-zero) | 40 | 71% |
| Total | 56 | 100% |
| Layer | 0 | 4 | 8 | 10 | 12 | 14 | 16 | 20 | 24 |
| Transfer (%) | 5 | 15 | 96 | 60 | 30 | 18 | 10 | 8 | 5 |
| Demo Count | Task Accuracy | Transfer Rate | Preserve Rate |
|---|---|---|---|
| 1-shot | 64.2% | 33.3% | 45.8% |
| 2-shot | 85.4% | 33.3% | 54.2% |
| 3-shot | 93.8% | 33.3% | 58.3% |
| 5-shot | 97.9% | 33.3% | 62.5% |
| 8-shot | 100.0% | 32.1% | 64.6% |
| Output Positions | 1 | 3 | 5 | 7 | 10 | All ( 19) |
|---|---|---|---|---|---|---|
| Transfer (%) | 0 | 0 | 1 | 1 | 10 | 90 |
| Source Demos | 1-shot | 2-shot | 3-shot | 5-shot |
|---|---|---|---|---|
| Mean Transfer (%) | 0 | 0 | 0 | 93 |
| Source Target | Labels | Transfer (%) |
|---|---|---|
| standard goodbad | positive/negative good/bad | 100 |
| goodbad standard | good/bad positive/negative | 95 |
| standard symbol | positive/negative +/ | 55 |
| symbol standard | +/ positive/negative | 25 |
| sentiment antonym (control) | cross-task | 10 |
| Pair | Transfer (%) | Note |
|---|---|---|
| repeat_word repeat_n (N=2) | 100 | Token count matches |
| repeat_word repeat_n (N=3) | 0 | Token count differs |
| repeat_word repeat_n (N=4) | 0 | Token count differs |
| length spell_out | 13 | Near-zero |
| uppercase | length | sentiment | pattern | |
|---|---|---|---|---|
| uppercase | 1.00 | 0.72 | 0.65 | 0.68 |
| length | 0.72 | 1.00 | 0.70 | 0.75 |
| sentiment | 0.65 | 0.70 | 1.00 | 0.73 |
| pattern | 0.68 | 0.75 | 0.73 | 1.00 |
| Position | Transfer Rate | Preserve Rate | Accuracy |
|---|---|---|---|
| last_demo_token | 0% | 95% | 95% |
| separator | 0% | 97% | 97% |
| first_query_token | 0% | 93% | 93% |
| Layer | 0 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 20 | 24 |
| last_demo | 75.0 | 87.5 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| separator | 62.5 | 75.0 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| first_query | 12.5 | 25.0 | 62.5 | 70.8 | 75.0 | 79.2 | 83.3 | 79.2 | 75.0 | 75.0 | 70.8 |
| Source Position | Demo Inputs | Demo Outputs | Separators | Query Self |
|---|---|---|---|---|
| Attention Weight | 0.12 | 0.38 | 0.08 | 0.42 |
| Error Type | Frequency | Example |
|---|---|---|
| Preserved target task | 45.2% | Input: “cat” “CAT” (target: uppercase) |
| Partial transfer | 28.4% | Input: “cat” “cat cat” (incomplete) |
| Format mismatch | 18.7% | Input: “cat” “Cat Cat” (wrong case) |
| Malformed output | 7.7% | Input: “cat” “cattac” (nonsense) |
| Llama-3B | Llama-1B | Qwen-1.5B | Gemma-2B | |
| Architecture depth | 28 | 16 | 28 | 26 |
| Optimal layer | 8 | 5 | 8 | 8 |
| Depth fraction | 0.29 | 0.31 | 0.29 | 0.31 |
| upper repeat transfer | 0.90 | 0.60 | 0.90 | 0.40 |
| Pair | True Source | Random Source | Noise | Shuffled |
|---|---|---|---|---|
| uppercase repeat_word | 0.95 | 0.00 | 0.00 | 0.55 |
| uppercase first_letter | 0.00 | 0.00 | 0.00 | 0.00 |
| first_letter repeat_word | 0.00 | 0.00 | 0.00 | 0.00 |
| uppercase sentiment | 0.00 | 0.00 | 0.00 | 0.00 |
| linear_2x length | 0.00 | 0.00 | 0.00 | 0.00 |
| sentiment antonym | 0.10 | 0.00 | 0.00 | 0.00 |
| Pair | Src Tokens | Tgt Tokens | Match? | Transfer |
|---|---|---|---|---|
| uppercase repeat_word | 1.8 | 2.0 | No | 90% |
| linear_2x length | 2.0 | 2.0 | Yes | 0% |
| sentiment antonym | 1.0 | 1.0 | Yes | 10% |
| uppercase first_letter | 1.8 | 1.0 | No | 0% |
| Layer Ablated | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 27 |
|---|---|---|---|---|---|---|---|---|
| Accuracy | 0% | 12% | 35% | 58% | 72% | 85% | 92% | 95% |
| Intervention Point | Transfer Rate | Notes |
|---|---|---|
| Before attention (layer 8) | 85% | Best timing |
| After attention, before MLP | 72% | Partial degradation |
| After full layer 8 | 90% | Optimal |
| Persistent (all subsequent layers) | 65% | Overconstrained |
| Parameter | Value |
|---|---|
| Number of demonstrations ( ) | 5 |
| Test samples per experiment | 10 (main), 50 (ablations) |
| Source prompts for averaging | 10 |
| Noise magnitude for causal tracing | |
| Random seed | 42 |
| Decoding temperature | 0 (greedy) |
| Metric | Value | 95% CI |
|---|---|---|
| Single-position transfer (layer 14) | 0% | [0%, 7%] |
| Multi-position transfer (layer 8, all_demo) | 96% | [87%, 99%] |
| Near-zero transfer pairs | 2–4% | 13% upper |
In-Context Learning
In-context learning studies how models adapt to new tasks from examples or instructions supplied at inference time, without changing their weights.
See all 404 papers