Lune

ICML2023Top-tier venue

How Do Transformers Learn Topic Structure: Towards a Mechanistic Understanding

Yuchen Li, Yuanzhi Li, Andrej Risteski

Abstract

While the successes of transformers across many domains are indisputable, accurate understanding of the learning mechanics is still largely lacking. Their capabilities have been probed on benchmarks which include a variety of structured and reasoning tasks -- but mathematical understanding is lagging substantially behind. Recent lines of work have begun studying representational aspects of this question: that is, the size/depth/complexity of attention-based networks to perform certain tasks. However, there is no guarantee the learning dynamics will converge to the constructions proposed. In our paper, we provide fine-grained mechanistic understanding of how transformers learn"semantic structure", understood as capturing co-occurrence structure of words. Precisely, we show, through a combination of mathematical analysis and experiments on Wikipedia data and synthetic data modeled by Latent Dirichlet Allocation (LDA), that the embedding layer and the self-attention layer encode the topical structure. In the former case, this manifests as higher average inner product of embeddings between same-topic words. In the latter, it manifests as higher average pairwise attention between same-topic words. The mathematical results involve several assumptions to make the analysis tractable, which we verify on data, and might be of independent interest as well.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

65 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Skill-it! A data-driven skills framework for understanding and training language models cites Language Models are Few-Shot Learners
  • An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale cites Language Models are Few-Shot Learners
  • How Transformers Learn Causal Structure with Gradient Descent cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • How Transformers Learn Causal Structure with Gradient Descent cites Language Models are Few-Shot Learners
  • How Transformers Learn Causal Structure with Gradient Descent cites Birth of a Transformer: A Memory Viewpoint
  • How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression? cites Language Models are Few-Shot Learners
  • Birth of a Transformer: A Memory Viewpoint cites Language Models are Few-Shot Learners
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers65

  1. Towards Best Practices of Activation Patching in Language Models: Metrics and MethodsFred Zhang, Neel NandaICLR 2024 · 233 citations
  2. Birth of a Transformer: A Memory ViewpointAlberto Bietti, Vivien Cabannes, Diane Bouchacourt, Hervé Jégou et al.NeurIPS 2023 · 182 citations
  3. Skill-it! A data-driven skills framework for understanding and training language modelsMayee F. Chen, Nicholas Roberts, Kush Bhatia, Jue Wang et al.NeurIPS 2023 · 143 citations
  4. How Transformers Learn Causal Structure with Gradient DescentEshaan Nichani, Alex Damian, Jason D. LeeICML 2024 · 117 citations
  5. How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?Jingfeng Wu, Difan Zou, Zixiang Chen, Vladimir Braverman et al.ICLR 2024 · 94 citations

Builds on20

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
  3. On Layer Normalization in the Transformer ArchitectureRuibin Xiong, Yunchang Yang, Di He, Kai Zheng et al.ICML 2020 · 1,388 citations
  4. Are Transformers universal approximators of sequence-to-sequence functions?Chulhee Yun, Srinadh Bhojanapalli, Ankit Singh Rawat, Sashank J. Reddi et al.ICLR 2020 · 481 citations
  5. Why are Adaptive Methods Good for Attention Models?Jingzhao Zhang, Sai Praneeth Karimireddy, Andreas Veit, Seungyeon Kim et al.NeurIPS 2020 · 397 citations

Related papers

  1. A Mechanistic Analysis of a Transformer Trained on a Symbolic Multi-Step Reasoning TaskJannik Brinkmann, Abhay Sheshadri, Victor Levoso, Paul Swoboda et al.ACL Findings 2024 · 3 citations
  2. Identifying Semantic Induction Heads to Understand In-Context LearningJie Ren, Qipeng Guo, Hang Yan, Dongrui Liu et al.ACL Findings 2024 · 4 citations
  3. A Phase Transition between Positional and Semantic Learning in a Solvable Model of Dot-Product AttentionHugo Cui, Freya Behrens, Florent Krzakala, Lenka ZdeborováNeurIPS 2024 · 35 citations
  4. How Do Transformers Learn to Associate Tokens: Gradient Leading Terms Bring Mechanistic InterpretabilityShawn Im, Changdae Oh, Zhen Fang, Sharon LiICLR 2026 · 4 citations
  5. A Meta-Learning Perspective on Transformers for Causal Language ModelingXinbo Wu, Lav R. VarshneyACL Findings 2024 · 3 citations
Dusk over the sea between two cliffs drawn in fine vertical lines