Inferensys

Glossary

Induction Head

A specific type of attention head discovered through mechanistic analysis that performs in-context copying by attending to the token immediately following a previous occurrence of the current token.
Engineer optimizing context window usage on laptop, token usage charts visible, technical work session.
MECHANISTIC INTERPRETABILITY

What is an Induction Head?

An induction head is a specialized attention head in transformer models that performs in-context copying by attending to the token immediately following a previous occurrence of the current token, enabling pattern completion.

An induction head is a specific type of attention head discovered through mechanistic interpretability that implements a simple algorithm: given a current token, it searches the context for previous occurrences of that token and attends to the token that followed it. This mechanism allows the model to perform in-context copying and pattern completion, such as predicting B after seeing the sequence A, B, ... A. The head operates by composing two key operations: a previous token head that attends to the preceding token, and a K-composition step where the key vector is formed using the output of an earlier attention layer, enabling the head to match current queries against past contexts.

Formally, an induction head's behavior is characterized by its QK circuit attending to the token immediately after a prior instance of the current token, and its OV circuit copying the value of that attended token to the output. This two-step mechanism—matching the current token to a prior occurrence via the key, then retrieving the subsequent token via the value—is a fundamental building block of in-context learning. Induction heads are primarily found in intermediate transformer layers and are considered a key circuit responsible for the emergent ability of large language models to recognize and extend patterns without weight updates.

Mechanistic Analysis

Core Characteristics of Induction Heads

The defining computational signature and functional properties of induction heads, the primary mechanism enabling in-context learning and sequence copying in transformer models.

01

The Prefix-Matching Algorithm

An induction head implements a two-step attention algorithm. In the first layer, a previous token head copies information about the immediately preceding token into the current position. In the second layer, the induction head uses the current token as a query to attend to positions where that same token appeared before, specifically focusing on the token that followed it. This allows the model to predict B when it sees A after observing the pattern AB earlier in the sequence.

  • Step 1: A previous token head attends to the immediately preceding position
  • Step 2: The induction head attends to the token following a previous occurrence of the current token
  • Result: The model copies the continuation of a previously observed pattern
2-layer
Minimum Circuit Depth
02

QK and OV Circuit Composition

The induction head's behavior emerges from the precise interaction of its QK circuit (attention pattern) and OV circuit (information transfer). The QK circuit performs prefix matching: the query vector at the current position searches for keys at previous positions that are similar to the current token's embedding. The OV circuit then copies the value vector from the token immediately following the matched position, effectively retrieving the continuation of the pattern.

  • QK Circuit: Implements a match between the current token and previous occurrences
  • OV Circuit: Copies the token that followed the matched occurrence
  • K-Composition: The key is often composed from a previous attention head's output in an earlier layer
03

In-Context Learning Engine

Induction heads are the primary computational primitive behind in-context learning. When a model is presented with a few-shot prompt containing input-output pairs, induction heads detect the repeating pattern and generalize it to the final query. They do not update model weights; instead, they dynamically route information through the residual stream to copy the appropriate output format or answer structure from the demonstration examples.

  • Enable zero-shot pattern completion without weight updates
  • Form the basis of function vectors that can be extracted and injected
  • Critical for tasks like few-shot translation, classification, and code completion
04

Layer-Specific Formation Dynamics

Induction heads do not exist in randomly initialized models. They form abruptly during training in a phase change, typically emerging after the model has learned bigram statistics. In a two-layer attention-only transformer, the first layer develops previous token heads that pass positional information forward. The second layer then composes its key from this information, creating the induction mechanism. In larger models, induction heads cluster in specific layers, often in the middle-to-late stages of the network.

  • Formation is a discontinuous phase transition during training
  • Requires prior development of previous token heads in earlier layers
  • Emergence correlates with a sharp drop in loss on sequence copying tasks
Phase Change
Formation Pattern
05

Attention Pattern Signature

An induction head exhibits a distinctive attention pattern that serves as its diagnostic fingerprint. When processing a sequence with repeated tokens, the attention map shows a characteristic off-by-one diagonal: the head attends to the position immediately following the previous occurrence of the current token. For a sequence like A B ... A, the head at the second A will attend strongly to the position of B that followed the first A.

  • Attention focuses on token index = previous_match_index + 1
  • Pattern is visible in attention heatmaps as a shifted diagonal
  • Strength increases with the number of prior occurrences of the current token
06

Role in Factual Recall vs. Pattern Copying

Induction heads are specialized for pattern copying, not factual retrieval. They excel at replicating sequences observed in the current context window but do not directly access knowledge stored in MLP layers. This distinction is crucial: induction heads handle in-context patterns, while knowledge neurons in MLP layers handle memorized facts. The two systems can interact—an induction head may route a copied token to an MLP layer that enriches it with stored factual associations.

  • Induction Heads: Copy patterns from the current context
  • MLP Layers: Retrieve facts from parametric memory
  • Interaction: Copied tokens can trigger factual recall in downstream layers
MECHANISTIC INTERPRETABILITY

Frequently Asked Questions About Induction Heads

Induction heads are a pivotal discovery in transformer mechanistic interpretability, explaining how language models perform in-context learning without weight updates. These specialized attention heads implement a simple pattern-matching and copying algorithm that allows models to recognize repeated sequences and predict subsequent tokens.

An induction head is a specialized attention head discovered through mechanistic analysis that performs in-context copying by attending to the token immediately following a previous occurrence of the current token. The mechanism operates in two distinct phases: first, a previous token head attends to the token immediately preceding the current position, copying its representation into the residual stream. Second, the induction head uses this enriched representation as a query to find matching tokens earlier in the sequence, then attends to the token that followed that match. This implements the algorithm: 'If I see token A preceded by token B, find a previous occurrence of B and predict whatever came after it.' The circuit relies on the QK circuit to match prefix patterns and the OV circuit to copy the subsequent token's information forward.

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.