Inferensys

Glossary

Induction Heads

A specific attention head circuit that performs in-context copying by attending to a previous token that followed a similar current token, enabling sequence completion.
Engineer optimizing context window usage on laptop, token usage charts visible, technical work session.
MECHANISTIC INTERPRETABILITY

What is Induction Heads?

An induction head is a specialized attention circuit in transformer models that enables in-context copying and sequence completion by attending to a token that followed a similar current token in the past.

An induction head is a specific attention head circuit discovered through mechanistic interpretability that performs in-context pattern matching. It operates by using the current token to search for a previous occurrence of that same token in the sequence, then attending to the token that followed it. This mechanism allows the model to predict that the previously observed continuation will repeat, enabling in-context learning without weight updates.

Formally, an induction head is composed of two cooperating attention heads in successive layers. The first head acts as a previous token head, copying information about the preceding token into the current position's residual stream. The second head uses a K-composition pattern: its query vector attends to the key vector produced by the first head, effectively matching the current token against the copied previous-token information to locate and retrieve the correct continuation.

MECHANISTIC INTERPRETABILITY

Key Characteristics of Induction Heads

Induction heads are a specific, interpretable circuit motif in transformer language models that drive in-context learning by attending to previous occurrences of the current token and copying what followed it.

01

The Core Algorithm: Previous Token Matching

An induction head operates via a two-step mechanism. First, a previous token head attends to the immediately preceding token and copies its embedding into the residual stream. Second, the induction head itself uses a K-composition pattern: its query vector is computed from the current token, but its key vector is computed from the previous token head's output. This causes it to attend to tokens that followed a similar prefix in the past, effectively implementing the rule: 'If I see token A now, look for the last time A appeared and predict what came after it.'

02

K-Composition and the QK Circuit

The defining architectural signature of an induction head is K-composition with a previous token head. The attention score is computed as softmax(Q_current ยท K_previous), where the key vector is derived from the output of an earlier attention head that attended to the prior position. This compositional structure creates a prefix-matching mechanism: the head searches for positions where the key vector (representing the token after a prefix) matches the query vector (representing the current token). This is distinct from simple copying because it generalizes across different occurrences of the same token.

03

In-Context Learning Engine

Induction heads are the primary circuit responsible for in-context learning in transformer models. When a model exhibits the ability to complete a pattern like A B -> A B after seeing a few examples, induction heads are performing the underlying computation. They explain why models can copy novel sequences, repeat patterns, and perform simple algorithmic tasks without weight updates. The strength of induction heads correlates directly with a model's few-shot learning capability, and their formation during training coincides with the phase change where in-context learning emerges.

04

Formation During Training: The Phase Change

Induction heads do not exist at initialization; they form abruptly during training in a phase change event. Research shows that models first develop bigram statistics (attending to the immediately previous token), and then suddenly restructure to form induction heads. This transition is visible in loss curves as a sharp drop and corresponds to the model transitioning from memorization to acquiring a general in-context copying algorithm. Once formed, induction heads rapidly strengthen and become the dominant mechanism for sequence completion tasks.

05

Relationship to Superposition and Polysemanticity

In larger models, induction heads often exhibit polysemanticity: a single head may implement multiple induction-like behaviors across different token positions or contexts. This is related to the phenomenon of superposition, where the model compresses more features than it has dimensions. Sparse autoencoders can be used to decompose an induction head's activations into distinct, monosemantic features, revealing that what appears as one head may actually be several superimposed induction circuits operating in parallel across different token types or positional offsets.

06

Causal Verification via Activation Patching

The functional role of induction heads is confirmed through activation patching experiments. By replacing the output of a candidate induction head with activations from a corrupted forward pass (where the prefix context is altered) and observing the resulting logit changes, researchers can causally verify that the head is responsible for copying behavior. Path patching further isolates the specific K-composition pathway, demonstrating that ablating the connection between the previous token head and the induction head's key computation destroys the copying capability while leaving other functions intact.

MECHANISTIC COMPARISON

Induction Heads vs. Related Mechanisms

A comparative analysis of induction heads against other attention mechanisms and circuits involved in in-context learning and sequence completion.

FeatureInduction HeadPrevious Token HeadFunction Vector

Primary Function

In-context copying and sequence completion via pattern matching

Attends to the immediately preceding token for local syntax

Encodes a specific input-output task behavior from demonstrations

Attention Pattern

Attends to the token following a similar current token in the past

Attends strictly to the previous token position

Not an attention head; a compact activation representation

Composition Mechanism

K-composition with a previous token head

Standalone attention without compositional chaining

Injected directly into residual stream activations

Causal Role in ICL

Core circuit enabling few-shot pattern replication

Provides raw positional context, not pattern induction

Triggers task behavior without requiring exemplars in context

Layer Location

Typically emerges in middle-to-late transformer layers

Common in early layers for local context aggregation

Derived from activation differences, not a fixed layer component

Discovery Method

Mechanistic analysis of attention patterns and causal tracing

Standard attention weight visualization

Activation engineering and causal intervention

Requires Prior Token Match

Generalizes to Novel Patterns

INDUCTION HEADS

Frequently Asked Questions

Clear, technical answers to the most common questions about the in-context learning circuit that powers sequence completion in transformer models.

An induction head is a specific attention head circuit in a transformer model that implements a simple in-context copying algorithm. It operates by attending to the token that immediately followed a previous occurrence of the current token. Mechanistically, the head uses a previous token head in an earlier layer to copy information about the preceding token into the current position's residual stream. The induction head then composes its attention pattern by looking for that same preceding token in the sequence history. When found, it attends to the token that came after it, effectively predicting that the sequence [A][B]... [A] should be completed with [B]. This circuit is the primary mechanism enabling in-context learning for sequence completion tasks, allowing models to recognize and continue patterns without weight updates.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.