| [A][B] … [A] → [B] | the algorithm | [1] Abstract
“Induction heads” are attention heads that implement a simple algorithm to complete token sequences like [A][B] … [A] → [B]. |
| induction heads might be the mechanism for the majority of in-context learning | the paper's hypothesis | [1] Abstract
we present preliminary and indirect evidence for a hypothesis that induction heads might constitute the mechanism for the majority of all |
| the beginnings of evidence | the paper's own verdict on its evidence | [1] Introduction
We emphasize that our results here are only the beginnings of evidence for such a case |
| 1 to 6 layers, 768 wide, 12 heads, 8192 context | the small models | [1] Model Details
They have a context window of 8192 tokens, a 216 token vocabulary, an activation dimension dmodel = 768, and 12 attention heads per layer regardless of total model size. |
| 10,000 steps, about 10 billion tokens, 200 snapshots | training of the small models | [1] Model Details
They were trained for 10,000 steps (~10 billion tokens), saving 200 snapshots at intervals of every 50 steps. |
| 25 random tokens repeated 4 times behind a start token | the prefix-matching evaluator | [1] Methods · Head activation evaluators
Prefix matching: Generate a sequence of 25 random tokens, excluding the most common and the least common tokens. Repeat this sequence 4 times and prepend a “start of sequence” token. |
| prefix matching and copying, on repeated random tokens | the definition of an induction head | [1] Key Concepts · Induction Heads
In other words, induction heads are any heads that empirically increase the likelihood of [B] given [A][B]...[A] when shown a repeated sequence of completely random tokens. |
| global and context-specific bigrams | a synthetic setup like this page | [2] Abstract
We study how transformers balance these two types of knowledge by considering a synthetic setup where tokens are generated from either global or context-specific bigram distributions. |
| global bigrams fast, the induction head slowly | the order of learning | [2] Abstract
we illustrate the fast learning of global bigrams and the slower development of an "induction head" mechanism for the in-context bigrams. |
| Kaplan et al. 2020 | where the loss-by-index definition comes from | [1] Related Work · In-context learning
Kaplan et al. [13] is the origin of our approach for using loss at different token indices as a formalism for studying in-context learning. |
| 500th-token loss minus 50th-token loss | in-context learning score | [1] Key Concepts · In-context Learning
In-context learning score: the loss of the 500th token in the context minus the average loss of the 50th token in the context, averaged over dataset examples. |
| 10,000 examples of 512 tokens | the per-token loss set | [1] Methods · Per-token losses
We run the model snapshot on a set of 10,000 randomly-selected examples from the dataset, each of which is 512 tokens in length |
| chosen "somewhat arbitrarily" | why tokens 50 and 500 | [1] Key Concepts
We chose the 500th and 50th token indices somewhat arbitrarily. |
| 50th minus 500th | the other order of the ICL score | [1] Argument 1
if we measure in-context learning for transformer models over the course of training (defined as the 50th token loss minus the 500th token loss as described in Key Concepts), it develops abruptly |
| < 0.15 nats before, about 0.4 after | in-context learning before and after | [1] Argument 1
Before this window there is less than 0.15 nats of in-context learning, after it there is roughly 0.4 nats, an amount that remains constant for the rest of training and is also constant across many different model sizes |
| a variant of standard positional embeddings, similar to Press et al. | positions in the small models | [1] Model Details
Their positional embeddings are implemented with a variant on the standard positional embeddings (similar to Press et al. [17] ). |
| these models add none | no position in the residual stream | [1] Argument 5
This mechanism isn't available to the models we study here, since they do not add positional information into the residual stream. |
| logits are a sum of head terms | why ablation is principled in attention-only models | [1] Footnote 19
In attention-only models, the logits can be expressed (up to a rescaling due to LayerNorm) as a sum of terms from each attention head, along with a "direct path term" to the the token embedding |
| different circuits, different parameters | attention pattern and output are separable | [1] Footnote 29
the calculation of each attention head’s attention pattern and output vector is separable, that is, implemented by different circuits consisting of different sets of parameters |
| a previous-token head, then the induction head | the circuit | [1] Introduction
Mechanically, induction heads in our models are implemented by a circuit of two attention heads: the first head is a “previous token head” which copies information from the previous token into the next token, while the second head (the actual “induction head”) uses that information to find tokens preceded by the present token. |
| a continuum | induction heads are not exact | [1] Footnote 5
In practice, induction heads don't exhibit these properties perfectly, and our measurements give us a continuum |
| with the previous-token head | prefix matching is K-composition | [1] Argument 5
Prefix matching is implemented with K-composition (and to a lesser extent Q-composition) in the QK ("Query-Key") Circuit. |
| a single head cannot see the token before the one it attends to | why induction needs two layers | [1] Footnote 15
Without using information written by a second earlier attention head, the score from the attended token can’t be a function of the token that precedes it. |
| composition of heads in different layers | induction heads occur in two-layer but not one-layer models | [1] Footnote 2
Note that induction heads don’t occur in 1 layer models, because they require a composition of attention heads in different layers. |
| attends back to previous tokens that were followed by the current and/or recent tokens | prefix matching | [1] Key Concepts · Induction Heads
Prefix matching: The head attends back to previous tokens that were followed by the current and/or recent tokens. |
| the head's output increases the logit of the attended-to token | copying | [1] Key Concepts · Induction Heads
Copying: The head’s output increases the logit corresponding to the attended-to token. |
| 2022-09-20 | the correction to the prefix-matching definition | [1] Change Log
2022-09-20: Corrects the definition of Prefix matching in two places, which incorrectly stated “tokens that were preceded by the current token” instead of “preceded” or “were followed by”. |
| a ratio of boosts | the copying evaluator | [1] Methods · Head activation evaluators
Compute the ratio of the amount it raises the logits of the token being attended to, to that of all tokens in this sample. |
| a score between -1 and 1 | the copying evaluator | [1] Methods · Head activation evaluators
This value ranges from 0 (only raises other tokens) to 0.5 (only raises the present token), so we scale it into the range of -1 to 1. |
| exact previous-token scores recovered 99% of the loss difference | Redwood replication: the previous-token head | [1] Comments & Replications · Adam Scherlis
Replacing the previous-token head’s scores with exact previous-token attention recovered 99% of the loss difference. |
| a simple approximation recovered about 65% | Redwood replication: the induction head | [1] Comments & Replications · Adam Scherlis
Replacing the induction head’s scores with a simple approximation (attending to the first token and to exact [A][B]...[A] matches) recovered about 65% of the loss difference. |
| completing [A*][B*] … [A] → [B] | induction as nearest neighbour | [1] Introduction
the thesis is that there are circuits which have the same or similar mechanism to the 2-layer induction heads and which perform a “fuzzy” or “nearest neighbor” version of pattern completion |
| the first 1.5e9 tokens | warm-up | [1] Model Details
the learning rate warm-up, which ramps up over the first 1.5e9 tokens. |
| the warm-up falls within the range | the warm-up and the phase change | [1] Model Details · Small models
The only other hyperparameter change that occurs within the range of the phase change is the learning rate warm-up |
| at 4,750 steps | weight-decay change | [1] Model Details
Weight decay was reduced at 4750 steps (approximately 5 billion tokens) |
| three nested logits learned in sequence | a model of the abruptness | [9] Abstract
A phenomenological model of induction head formation traces its abrupt emergence to the sequential learning of three nested logits enabled by an intrinsic curriculum. |
| roughly 2.5 to 5 billion tokens | when in-context learning develops | [1] Argument 1
it develops abruptly in a narrow window early in training (roughly 2.5 to 5 billion tokens) and then is constant for the rest of training |
| ICL, induction heads, the bump, the trajectory | what co-occurs in the window | [1] Argument 1
Collectively these results suggest that some important transition is happening during the 2.5e9 to 5e9 token window early in training |
| the only place the loss is not convex | the loss bump | [1] Argument 1
It is in fact the only place in training where the loss is not convex (monotonically decreasing in slope). |
| approximately 1-3 billion tokens | when the phase change appears in the small models | [1] Model Details · Small models
We observe a “phase change” phenomenon that appears at approximately 1-3 billion tokens in the small models. |
| 34 models, more than 50,000 head ablations | models and ablations | [1] Introduction
We then present the 6 arguments one by one, drawing on evidence from analysis of 34 transformers over the course of training, including more than 50,000 attention head ablations |
| strong, causal | strength of the evidence for small attention-only models | [1] Arguments (summary table)
For small, attention-only models, we believe we have strong evidence that attention heads are the mechanism for the majority of in-context learning, as we have evidence supported by ablations and mechanistic reverse engineering. |
| strong and causal for small attention-only models, correlational for larger ones | the abstract's evidence levels | [1] Abstract
For small attention-only models, we present strong, causal evidence; for larger models with MLPs, we present correlational evidence. |
| zero the head, force the recorded patterns | pattern-preserving ablation | [1] Methods · Attention head ablations
Step 2: Run model a second time. Replace the ablated attention head’s result vector with a zero vector, and force all attention patterns to be the version recorded in the first run. |
| almost all in-context learning | what ablation shows in small attention-only models | [1] Argument 3
In fact, almost all the in-context learning in small attention-only models appears to come from these induction heads! |
| multiple heads, none individually necessary | induction heads act additively | [7] §4.2
Furthermore, heads seem to have an additive effect |
| they may hide redundancy | a caution about knock-out ablations | [7] §4.2
Our analysis builds on this work and cautions against the use of purely knock-out ablations in mechanistic analyses, which may overlook redundancies and incorrectly dismiss network pieces as not implementing a certain function. |
| footnote 17 | ablating most heads raises the score | [1] Footnote 17
In fact, ablating most other attention heads appears to increase in-context learning. |
| a 40-layer, 13B model | abstract induction heads | [1] Argument 4
we show some anecdotal examples of induction heads from larger transformers (our 40-layer model with 13 billion parameters) that exhibit exactly such behaviors – namely literal copying, translation, and a specific type of abstract pattern matching. |
| about 65% of its attention on the correct positions | the pattern-matching head | [1] Argument 4
empirically it allocates about 65% of its attention from the colons to the correct positions, when tested on a range of similar problems. |
| the same sharp increase, with the same rough amounts | continuity from small to large | [1] Argument 6
All of them have the same sharp increase in in-context learning, with the same rough amounts before and after the transition. |
| 4 layers, 13M non-embedding parameters, d_model 512 | smallest full-scale model | [1] Model Details · Table of model properties
4 13M 512 8 64 |
| 40 layers, 13B non-embedding parameters, d_model 5120 | largest full-scale model | [1] Model Details · Table of model properties
40 13B 5120 40 128 |
| d_model = 128 × layers | width of the full-scale models | [1] Model Details · Full-scale models
with an activation dimension dmodel = 128 ∗ nlayer |
| few-shot accuracy falls by up to about 32% | ablating induction heads in pretrained models | [10] Abstract
Our results show that even a minimal ablation of induction heads leads to ICL performance decreases of up to ~32% for abstract pattern recognition tasks, bringing the performance close to random. |
| "n-gram heads" | higher-order induction heads | [11] Abstract
we provide evidence that their ability to do so relies on specialized "n-gram heads" (higher-order variants of induction heads) that compute input-conditional next-token distributions. |
| plausibly different because they have no induction heads | one-layer models and scaling laws | [1] Related Work · Scaling laws
It seems quite plausible that the reason why the scaling laws are different for one-layer models is that they don't have induction heads. |
| by mistake | a start token left out of the copying evaluator | [1] Footnote 31
It would’ve been better if we had used a start of sequence token for the copying head evaluator as well, but we omitted it by mistake. |
| one | runs per model | [1] Model Analysis Table
The arguments above are based on analysis of 34 decoder-only Transformer language models, with different snapshots saved over the course of training, for one run of training per model. |
| 15 points in time | time resolution of the large-model data | [1] Argument 1 · Assessing the Evidence
In large models, we have low time resolution on our analysis over training. Co-occurrence when one only has 15 points in time is less surprising and weaker evidence. |
| about the same for every model after the phase change | a curiosity: the constant score | [1] Unexplained Curiosities
is more or less the same for all models after the phase change. |
| the model may be learning to compose layers | the confound the paper names | [1] Argument 1 · Assessing the Evidence
perhaps the phase change is really the point at which the model learns how to compose layers through the residual stream, enabling both induction heads and potentially many other mechanisms that also require composition of multiple heads |
| none appears to | whether a scheduled change explains the phase change | [1] Argument 1 · Looking at the Phase Change More Closely
the window where the phase change happens doesn’t appear to correspond to a scheduled change in learning rate, warmup, or weight decay |
| three | subcircuits of induction head formation | [7] Abstract
By clamping subsets of activations throughout training, we then identify three underlying subcircuits that interact to drive IH formation, yielding the phase change. |
| of an induction head | in-context learning is driven by an abrupt emergence | [9] Abstract
In-context learning (ICL) is driven by the abrupt emergence of an induction head, which subsequently competes with in-weights learning. |
| on a synthetic dataset | induction learned at context length 4 | [1] Comments & Replications · Tom Lieberum
On a synthetic dataset, I have already found induction to be easily learned with a context length of 4. |
| abruptly, in the same window as in-context learning | when induction heads form | [1] Argument 1
we find that induction heads form abruptly during exactly the same window where in-context learning develops |
| induction heads never form | one-layer models | [1] Argument 1
The exception is the one-layer model, where induction heads never form – just as in-context learning never substantially develops for the one-layer model. |
| over 75% | share of final in-context learning formed in the window | [1] Argument 1 · Assessing the Evidence
Since over 75% of final in-context learning forms in this window, one might naively believe this to be the amount of in-context learning that induction heads are responsible for. |
| the phase change moves into one-layer models and earlier in deeper ones | the smear experiment's prediction | [1] Argument 2
The hypothesis that induction heads are the primary mechanism of in-context learning predicts that the phase change will happen in one-layer models with this change, and perhaps might happen earlier in models with more layers. |
| in-context learning forms in one-layer models and earlier in deeper ones | the smear experiment's result | [1] Argument 2
when we use the smeared-key architecture, in-context learning does indeed form for one-layer models (when it didn’t before), and it forms earlier for two-layer and larger models. |
| σ(α) interpolates between the current and the previous key | smeared keys | [1] Argument 2 · Model Details
we introduce a trainable real parameter α used as σ(α) ∈ [0, 1] that interpolates between the key for the current token and previous token |
| unchanged | smeared keys, first token | [1] Footnote 16
The key vector for the first token is unchanged. |