How Do Transformers Learn Topic Structure: Towards a Mechanistic Understanding
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 85 papers in the map (data through 7 Oct 2026). Builds on 41 of its 60 references that are in the map. First posted on arXiv 7 Mar 2023.
Builds on
41 of 60 references.
References · 41
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
- 2019BERT Rediscovers the Classical NLP Pipelinecited by 1,046
- 2019What Does BERT Look At? An Analysis of BERT's Attentioncited by 994
- 2020On Layer Normalization in the Transformer Architecturecited by 906
- 2021Probing Classifiers: Promises, Shortcomings, and Advancescited by 831
- 2019Designing and Interpreting Probes with Control Taskscited by 608
- 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
- 2019Revealing the Dark Secrets of BERTcited by 300
- 2016Using the Output Embedding to Improve Language Modelscited by 266
29 more
- 2022Transformers Learn Shortcuts to Automatacited by 260
- 2019Analyzing the Structure of Attention in a Transformer Language Modelcited by 241
- 2020Understanding the Difficulty of Training Transformerscited by 210
- 2019Transformers without Tears: Improving the Normalization of Self-Attentioncited by 153
- 2021Inductive Biases and Variable Creation in Self-Attention Mechanismscited by 144
- 2018On the Practical Computational Power of Finite Precision RNNs for Language Recognitioncited by 117
- 2021Self-Attention Networks Can Process Bounded Hierarchical Languagescited by 105
- 2022Unveiling Transformers with LEGO: a synthetic reasoning taskcited by 105
- 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 101
- 2022Vision Transformers provably learn spatial structurecited by 92
- 2019Do Attention Heads in BERT Track Syntactic Dependencies?cited by 87
- 2020On the Computational Power of Transformers and its Implications in Sequence Modelingcited by 85
- 2020Tired of Topic Models? Clusters of Pretrained Word Embeddings Make for Fast and Good Topics too!cited by 73
- 2020RNNs can generate bounded hierarchical languages with optimal memorycited by 59
- 2019Sequential Neural Networks as Automatacited by 54
- 2020Contrastive estimation reveals topic posterior information to linear modelscited by 54
- 2020How Can Self-Attention Networks Recognize Dyck-n Languages?cited by 51
- 2019LSTM Networks Can Perform Dynamic Countingcited by 45
- 2020Topic Modeling with Contextualized Word Representation Clusterscited by 41
- 2021Approximating How Single Head Attention Learnscited by 38
- 2022Is Neural Topic Modelling Better than Clustering? An Empirical Study on Clustering with Contextual Embeddings for Topicscited by 35
- 2022Topic Discovery via Latent Space Clustering of Pretrained Language Model Representationscited by 34
- 2021Robust Optimization for Multilingual Translation with Imbalanced Datacited by 15
- 2022An Analysis of Attention via the Lens of Exchangeability and Latent Variable Modelscited by 15
- 2021Effective Attention Sheds Light On Interpretabilitycited by 11
- 2016Provable Algorithms for Inference in Topic Modelscited by 6
- 2021The Limitations of Limited Context for Constituency Parsingcited by 5
- 2015On some provably correct cases of variational inference for topic modelscited by 1
- 2023Topics in Contextualised Attention Embeddingscited by 1
Built on by
Citing papers per year: 2023: 27; 2024: 27; 2025: 20; 2026: 11.
85 papers.
Sort:
By area:
- 2023TinyStories: How Small Can Language Models Be and Still Speak Coherent English?cited by 425
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
- 2023Towards Best Practices of Activation Patching in Language Models: Metrics and Methodscited by 328
- 2023Birth of a Transformer: A Memory Viewpointcited by 154
- 2023Skill-it! A Data-Driven Skills Framework for Understanding and Training Language Modelscited by 120
- 2023Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformercited by 101
- 2023Linear attention is (maybe) all you need (to understand transformer optimization)cited by 97
- 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 93
- 2023Exposing Attention Glitches with Flip-Flop Language Modelingcited by 74
- 2023JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attentioncited by 52
- 2023Attention Scheme Inspired Softmax Regressioncited by 49
- 2023An Over-parameterized Exponential Regressioncited by 45
38 more
- 2024Why Larger Language Models Do In-context Learning Differently?cited by 44
- 2024An Information-Theoretic Analysis of In-Context Learningcited by 39
- 2024Attention with Markov: A Framework for Principled Analysis of Transformers via Markov Chainscited by 39
- 2025When is Task Vector Provably Effective for Model Editing? A Generalization Analysis of Nonlinear Transformerscited by 38
- 2023SoK: Memorization in General-Purpose Large Language Modelscited by 36
- 2023An Iterative Algorithm for Rescaled Hyperbolic Functions Regressioncited by 35
- 2024How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?cited by 35
- 2024Mechanics of Next Token Prediction with Self-Attentioncited by 34
- 2023In-Context Learning for Attention Scheme: from Single Softmax Regression to Multiple Softmax Regression via a Tensor Trickcited by 32
- 2023A Fast Optimization View: Reformulating Single Layer Attention in LLM Based on Tensor and SVM Trick, and Solving It in Matrix Multiplication Timecited by 30
- 2023Transformers are uninterpretable with myopic methods: a case study with bounded Dyck grammarscited by 30
- 2025Taming Knowledge Conflicts in Language Modelscited by 27
- 2023The Crucial Role of Normalization in Sharpness-Aware Minimizationcited by 26
- 2024In-Context Learning with Transformers: Softmax Attention Adapts to Function Lipschitznesscited by 22
- 2024Multi-Layer Transformers Gradient Can be Approximated in Almost Linear Timecited by 22
- 2024Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descentcited by 21
- 2023Zero-th Order Algorithm for Softmax Attention Optimizationcited by 16
- 2024Implicit Regularization of Gradient Flow on One-Layer Softmax Attentioncited by 16
- 2024Attention layers provably solve single-location regressioncited by 15
- 2024On the Training Convergence of Transformers for In-Context Classification of Gaussian Mixturescited by 15
- 2024Tracking the Feature Dynamics in LLM Training: A Mechanistic Studycited by 15
- 2024What Improves the Generalization of Graph Transformers? A Theoretical Dive into the Self-attention and Positional Encodingcited by 14
- 2024Do LLMs dream of elephants (when told not to)? Latent concept association and associative memory in transformerscited by 14
- 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysiscited by 14
- 2024One-Layer Transformer Provably Learns One-Nearest Neighbor In Contextcited by 14
- 2025Why and How LLMs Hallucinate: Connecting the Dots with Subsequence Associationscited by 14
- 2024How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regressioncited by 13
- 2023Unmasking Transformers: A Theoretical Approach to Data Recovery via Attention Weightscited by 11
- 2024Attention Meets Post-hoc Interpretability: A Mathematical Perspectivecited by 11
- 2024What Should Embeddings Embed? Autoregressive Models Represent Latent Generating Distributionscited by 10
- 2025On the Query Complexity of Verifier-Assisted Language Generationcited by 10
- 2023Local Convergence of Approximate Newton Method for Two Layer Nonlinear Regressioncited by 9
- 2024Theoretical Insights into Fine-Tuning Attention Mechanism: Generalization and Optimizationcited by 9
- 2025On the Emergence of Linear Analogies in Word Embeddingscited by 9
- 2025From Condensation to Rank Collapse: A Two-Stage Analysis of Transformer Training Dynamicscited by 9
- 2023Solving Tensor Low Cycle Rank Approximationcited by 8
- 2024Learning on Transformers is Provable Low-Rank and Sparse: A One-layer Analysiscited by 8
- 2024Training Dynamics of Transformers to Recognize Word Co-occurrence via Gradient Flow Analysiscited by 8
50 most cited of 85 All 85 (JSON)
- 2026Faster Query-Key Learning Sharpens Attention in Self-Attention Models7 Aug 2026
- 2026The Stability of Singular Distribution: A Spectral Perspective on the Two-Phase Dynamics of Language Model Pre-training26 May 2026
- 2026Rethinking Layer Relevance in Large Language Models Beyond Cosine Similarity13 May 2026
- 2026A Unified Framework for Critical Scaling of Inverse Temperature in Self-Attention12 May 2026
- 2026Transformers Learn Latent Mixture Models In-Context via Mirror Descent12 Apr 2026
- 2026Reconciling In-Context and In-Weight Learning via Dual Representation Space Encoding13 Mar 2026
- 2026Beyond Linearity in Attention Projections: The Case for Nonlinear Queries11 Mar 2026
- 2026Training Dynamics of Softmax Self-Attention: Fast Global Convergence via Preconditioning2 Mar 2026
- 2026Incremental Learning of Sparse Attention Patterns in Transformers22 Feb 2026
- 2026A Theoretical Analysis of Why Masked Diffusion Models Mitigate the Reversal Curse2 Feb 2026
- 2026How Do Transformers Learn to Associate Tokens: Gradient Leading Terms Bring Mechanistic Interpretability27 Jan 2026
- 2025From Shortcut to Induction Head: How Data Diversity Shapes Algorithm Selection in Transformers21 Dec 2025
38 more
- 2025Towards Understanding Transformers in Learning Random Walks28 Nov 2025
- 2025Mixture-of-Transformers Learn Faster: A Theoretical Study on Classification Problems30 Oct 2025
- 2025A Framework for Quantifying How Pre-Training and Context Benefit In-Context Learning26 Oct 2025
- 2025Optimality and NP-Hardness of Transformers in Learning Markovian Dynamical Functions21 Oct 2025
- 2025From Condensation to Rank Collapse: A Two-Stage Analysis of Transformer Training Dynamics8 Oct 2025
- 2025Cross-Model Semantics in Representation Learning5 Aug 2025
- 2025Understanding Learning Dynamics Through Structured Representations4 Aug 2025
- 2025Structured Transformations for Stable and Interpretable Neural Computation31 Jul 2025
- 2025Provable In-Context Learning of Nonlinear Regression with Transformers28 Jul 2025
- 2025On the Emergence of Linear Analogies in Word Embeddings24 May 2025
- 2025Why and How LLMs Hallucinate: Connecting the Dots with Subsequence Associations17 Apr 2025
- 2025When is Task Vector Provably Effective for Model Editing? A Generalization Analysis of Nonlinear Transformers15 Apr 2025
- 2025Taming Knowledge Conflicts in Language Models14 Mar 2025
- 2025Disentangling Feature Structure: A Mathematically Provable Two-Stage Training Dynamics in Transformers28 Feb 2025
- 2025On the Query Complexity of Verifier-Assisted Language Generation17 Feb 2025
- 2025Closed-Form Training Dynamics Reveal Learned Features and Linear Structure in Word2Vec-like Models14 Feb 2025
- 2025Transformers versus the EM Algorithm in Multi-class Clustering9 Feb 2025
- 2025Technical Debt in In-Context Learning: Diminishing Efficiency in Long Context7 Feb 2025
- 2025Dynamics of Spontaneous Topic Changes in Next Token Prediction with Self-Attention10 Jan 2025
- 2024Tracking the Feature Dynamics in LLM Training: A Mechanistic Study23 Dec 2024
- 2024One-Layer Transformer Provably Learns One-Nearest Neighbor In Context16 Nov 2024
- 2024Global Convergence in Training Large-Scale Transformers31 Oct 2024
- 2024On the Training Convergence of Transformers for In-Context Classification of Gaussian Mixtures15 Oct 2024
- 2024Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descent15 Oct 2024
- 2024Training Dynamics of Transformers to Recognize Word Co-occurrence via Gradient Flow Analysis12 Oct 2024
- 2024Theoretical Insights into Fine-Tuning Attention Mechanism: Generalization and Optimization3 Oct 2024
- 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysis3 Oct 2024
- 2024Attention layers provably solve single-location regression2 Oct 2024
- 2024Multi-Layer Transformers Gradient Can be Approximated in Almost Linear Time23 Aug 2024
- 2024How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regression8 Aug 2024
- 2024Promises and Pitfalls of Generative Masked Language Modeling: Theoretical Framework and Practical Guidelines22 Jul 2024
- 2024Do LLMs dream of elephants (when told not to)? Latent concept association and associative memory in transformers26 Jun 2024
- 2024Learning on Transformers is Provable Low-Rank and Sparse: A One-layer Analysis24 Jun 2024
- 2024What Should Embeddings Embed? Autoregressive Models Represent Latent Generating Distributions6 Jun 2024
- 2024What Improves the Generalization of Graph Transformers? A Theoretical Dive into the Self-attention and Positional Encoding4 Jun 2024
- 2024A Theory for Token-Level Harmonization in Retrieval-Augmented Generation3 Jun 2024
- 2024Contextual Counting: A Mechanistic Study of Transformers on a Quantitative Task30 May 2024
- 2024Why Larger Language Models Do In-context Learning Differently?30 May 2024
50 newest of 85 All 85 (JSON)
- 2023TinyStories: How Small Can Language Models Be and Still Speak Coherent English?cited by 425
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
- 2023Towards Best Practices of Activation Patching in Language Models: Metrics and Methodscited by 328
- 2023Birth of a Transformer: A Memory Viewpointcited by 154
- 2023Skill-it! A Data-Driven Skills Framework for Understanding and Training Language Modelscited by 120
- 2023Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformercited by 101
- 2023Linear attention is (maybe) all you need (to understand transformer optimization)cited by 97
- 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 93
- 2023Exposing Attention Glitches with Flip-Flop Language Modelingcited by 74
- 2023JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attentioncited by 52
- 2023Attention Scheme Inspired Softmax Regressioncited by 49
- 2023An Over-parameterized Exponential Regressioncited by 45
12 most cited of 77 All 77 (JSON)
- 2026Faster Query-Key Learning Sharpens Attention in Self-Attention Models7 Aug 2026
- 2026The Stability of Singular Distribution: A Spectral Perspective on the Two-Phase Dynamics of Language Model Pre-training26 May 2026
- 2026A Unified Framework for Critical Scaling of Inverse Temperature in Self-Attention12 May 2026
- 2026Transformers Learn Latent Mixture Models In-Context via Mirror Descent12 Apr 2026
- 2026Reconciling In-Context and In-Weight Learning via Dual Representation Space Encoding13 Mar 2026
- 2026Beyond Linearity in Attention Projections: The Case for Nonlinear Queries11 Mar 2026
- 2026Training Dynamics of Softmax Self-Attention: Fast Global Convergence via Preconditioning2 Mar 2026
- 2026Incremental Learning of Sparse Attention Patterns in Transformers22 Feb 2026
- 2026How Do Transformers Learn to Associate Tokens: Gradient Leading Terms Bring Mechanistic Interpretability27 Jan 2026
- 2025From Shortcut to Induction Head: How Data Diversity Shapes Algorithm Selection in Transformers21 Dec 2025
- 2025Towards Understanding Transformers in Learning Random Walks28 Nov 2025
- 2025A Framework for Quantifying How Pre-Training and Context Benefit In-Context Learning26 Oct 2025
12 newest of 77 All 77 (JSON)