mlsanityData to 7 Oct 2026

Layer Specialization Underlying Compositional Reasoning in Transformers

arXiv 2510.17469 ↗First posted 20 Oct 2025cs.LG cs.AIcited by 0

Not on the map. Why?

Abstract (arXiv)

Transformers exhibit compositional reasoning on sequences not observed during training, a capability often attributed to in-context learning (ICL) and skill composition. We investigate this phenomenon using the Random Hierarchy Model (RHM), a probabilistic context-free grammar that generates sequences through recursive rule application. Models are trained on subsets of sequences and evaluated across four generalization conditions: memorization, in-distribution generalization, out-of-distribution generalization with the same rules, and cross-layer transfer. Behaviorally, performance improves systematically with task complexity and the number of in-context examples, with out-of-distribution tasks requiring substantially more examples than in-distribution scenarios. Mechanistically, we identify a progressive emergence of layer specialization during training that correlates with generalization performance. Principal component analysis and attention pattern clustering reveal that transformers develop structured, hierarchically organized representations in specialized layers. These results demonstrate that transformers develop modular, interpretable mechanisms supporting compositional reasoning, linking internal algorithmic structure to observed behavioral capabilities.

Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 14 of its 20 references that are in the map. First posted on arXiv 20 Oct 2025.

Builds on

14 of 20 references.

References · 14

  1. 2020Language Models are Few-Shot Learnerscited by 32,199
  2. 2020Transformer Feed-Forward Layers Are Key-Value Memoriescited by 1,307
  3. 2022Toy Models of Superpositioncited by 928
  4. 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
  5. 2022Transformers learn in-context by gradient descentcited by 714
  6. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
  7. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
  8. 2022Transformer Feed-Forward Layers Build Predictions by Promoting Concepts in the Vocabulary Spacecited by 522
  9. 2019Measuring Compositional Generalization: A Comprehensive Method on Realistic Datacited by 280
  10. 2023Physics of Language Models: Part 3.1, Knowledge Storage and Extractioncited by 264
  11. 2022Omnigrok: Grokking Beyond Algorithmic Datacited by 142
  12. 2023A Tale of Two Circuits: Grokking as Competition of Sparse and Dense Subnetworkscited by 78
2 more
  1. 2023Grokking modular arithmeticcited by 77
  2. 2024Towards Understanding the Relationship between In-context Learning and Compositional Generalizationcited by 5

Built on by

Not cited yet.