Abstract: Large Language Models (LLMs) demonstrate remarkable Out-of-Distribution (OOD) generalization, yet the internal mechanisms driving this capability remain opaque. This paper investigates the role of compositional attention circuits, specifically induction heads, in facilitating symbolic reasoning. We propose the Common Bridge Representation hypothesis, suggesting that OOD generalization emerges when early layers learn to write information into a latent subspace that subsequent layers are tuned to read. Through synthetic experiments and interventions on large-scale models like Llama-3, we demonstrate that this "bridge" formation corresponds to a sharp phase transition from statistical memorization to rule-based learning.
Introduction
Standard statistical learning theory often struggles to explain why models perform well on data distributions significantly different from their training sets. In the context of Transformers, In-Context Learning (ICL) allows models to infer rules from a few examples, effectively performing symbolic reasoning on novel inputs. This study explores whether simple pattern-matching circuits, known as induction heads, serve as the fundamental building blocks for such complex reasoning. We hypothesize that OOD generalization is not a monolithic capability but an act of composition: models solve novel tasks by wiring together simpler internal circuits across different layers.
Methods and Metrics
To analyze the emergence of these circuits, we utilized a combination of synthetic training and mechanistic interpretability on pretrained models.
- Synthetic Copying Task: We trained minimal 2-layer Transformers on sequences containing repeated segments obscured by random noise. This allowed us to pinpoint the exact training step where the model transitions from memorizing token frequencies to learning a generalizable rule.
- Progress Measures: We introduced two key metrics to track circuit formation:
- Diagonal Score: Measures the signal-to-noise ratio within specific attention circuits.
- Subspace Matching Score: Quantifies the alignment between the "write" subspace of an early layer and the "read" subspace of a later layer.
- Ablation Studies: We performed "brain surgery" on Llama-2 and Llama-3 models by identifying induction heads and manually zeroing their attention weights to observe the impact on symbolic reasoning tasks like GSM8K (math word problems) and randomized variants (GSM8K-rand).
The Common Bridge Representation
A central finding of this work is the "Aha!" moment during training—a sharp phase transition where the model moves from a "weak learning" phase (frequency-based guessing) to a "rule-learning" phase. This transition occurs precisely when the internal subspaces of two layers align, creating what we call a Common Bridge Representation.
In a 2-layer configuration, Layer 1 typically acts as a "position shifter," while Layer 2 acts as a "token matcher." When these two specialized layers align their latent representations, they form a functional induction head capable of completing patterns like [A][B][C]...[A][B] -> [C]. This bridge allows the model to process symbolic inputs it has never encountered before by passing intermediate results through a shared, structured latent space.
Key Results
- Abrupt Emergence: In synthetic tasks, error rates plummeted from ~90% to ~10% almost instantaneously once the inter-layer bridge was established.
- Induction Heads and Mathematics: Induction heads are critical for mathematical reasoning. Removing the top 50 induction heads from Llama2-7B caused a significant collapse in GSM8K performance. On randomized OOD math tasks, Llama3-70B’s accuracy dropped from 96% to 51% upon removal of these heads, while removing random heads had negligible impact.
- Symbolic Reasoning: In "symbolized" tasks where words are replaced by random characters, LLMs rely almost exclusively on induction circuits. Without them, models revert to random guessing, confirming that these compositional circuits are the primary engine for symbolic OOD reasoning.
Discussion and Limitations
While induction heads provide a powerful lens for understanding OOD generalization, they are likely not the only compositional mechanism at play. Real-world LLMs include Multi-Layer Perceptrons (MLPs) and Layer Normalization, which add layers of complexity beyond the simplified attention models studied here. Future work should investigate whether the formation of these "bridges" is the underlying cause of "Grokking"—the phenomenon where models suddenly generalize long after apparent overfitting. Understanding the optimization pressures that force this subspace alignment remains a key open question.
Summary updated