How Transformers Learn Regular Language Recognition: A Theoretical Study on Training Dynamics and Implicit Bias
Not on the map. Why?
Abstract (arXiv)
Language recognition tasks are fundamental in natural language processing (NLP) and have been widely used to benchmark the performance of large language models (LLMs). These tasks also play a crucial role in explaining the working mechanisms of transformers. In this work, we focus on two representative tasks in the category of regular language recognition, known as `even pairs' and `parity check', the aim of which is to determine whether the occurrences of certain subsequences in a given sequence are even. Our goal is to explore how a one-layer transformer, consisting of an attention layer followed by a linear layer, learns to solve these tasks by theoretically analyzing its training dynamics under gradient descent. While even pairs can be solved directly by a one-layer transformer, parity check need to be solved by integrating Chain-of-Thought (CoT), either into the inference stage of a transformer well-trained for the even pairs task, or into the training of a one-layer transformer. For both problems, our analysis shows that the joint training of attention and linear layers exhibits two distinct phases. In the first phase, the attention layer grows rapidly, mapping data sequences into separable vectors. In the second phase, the attention layer becomes stable, while the linear layer grows logarithmically and approaches in direction to a max-margin hyperplane that correctly separates the attention layer outputs into positive and negative samples, and the loss decreases at a rate of O(1/t). Our experiments validate those theoretical results.
Key facts. Cited by 11 papers in the map (data through 14 Oct 2026). Builds on 45 of its 57 references that are in the map. First posted on arXiv 2 May 2025.
Builds on
45 of 57 references.
References · 45
- 2017Attention Is All You Needcited by 60,361
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,374
- 2017The Implicit Bias of Gradient Descent on Separable Datacited by 655
- 2023Trained Transformers Learn Linear Models In-Contextcited by 337
- 2019Learning Deep Transformer Models for Machine Translationcited by 309
- 2019Theoretical Limitations of Self-Attention in Neural Sequence Modelscited by 288
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
- 2022Neural Networks and the Chomsky Hierarchycited by 217
- 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 170
- 2017On the Properties of the Softmax Function with Application in Game Theory and Reinforcement Learningcited by 142
- 2023What Formal Languages Can Transformers Express? A Surveycited by 124
33 more
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
- 2023In-Context Convergence of Transformerscited by 115
- 2022Overcoming a Theoretical Limitation of Self-Attentioncited by 113
- 2018Convergence of Gradient Descent on Separable Datacited by 110
- 2023Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformercited by 102
- 2022On the Implicit Bias in Deep-Learning Algorithmscited by 86
- 2023A Theoretical Understanding of Shallow Vision Transformers: Learning, Generalization, and Sample Complexitycited by 77
- 2023Transformers as Support Vector Machinescited by 74
- 2024Why are Sensitive Functions Hard for Transformers?cited by 74
- 2024Training Dynamics of Multi-Head Softmax Attention for In-Context Learning: Emergence, Convergence, and Optimalitycited by 74
- 2023Transformers Implement Functional Gradient Descent to Learn Non-Linear Functions In Contextcited by 63
- 2023Max-Margin Token Selection in Attention Mechanismcited by 58
- 2023Transformers learn through gradual rank increasecited by 52
- 2023JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attentioncited by 52
- 2024Transformers Provably Solve Parity Efficiently with Chain of Thoughtcited by 50
- 2022Implicit Bias in Leaky ReLU Networks Trained on High-Dimensional Datacited by 46
- 2024Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscapecited by 46
- 2020Effects of Parameter Norm Growth During Transformer Training: Inductive Bias from Gradient Descentcited by 40
- 2024In-Context Learning with Representations: Contextual Generalization of Trained Transformerscited by 38
- 2023On the Optimization and Generalization of Multi-head Attentioncited by 37
- 2024Mechanics of Next Token Prediction with Self-Attentioncited by 34
- 2021Fast Margin Maximization via Dual Accelerationcited by 33
- 2024Implicit Bias and Fast Convergence Rates for Self-attentioncited by 31
- 2024From Sparse Dependence to Sparse Attention: Unveiling How Chain-of-Thought Enhances Transformer Sample Efficiencycited by 29
- 2024Provably learning a multi-head attention layercited by 21
- 2024Implicit Regularization of Gradient Flow on One-Layer Softmax Attentioncited by 19
- 2023Implicit Bias of Gradient Descent for Two-layer ReLU and Leaky ReLU Networks on Nearly-orthogonal Datacited by 18
- 2024Superiority of Multi-Head Attention in In-Context Linear Regressioncited by 17
- 2024Unveil Benign Overfitting for Transformer in Vision: Training Dynamics, Convergence, and Generalizationcited by 17
- 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysiscited by 14
- 2024Non-asymptotic Convergence of Training Transformers for Next-token Predictioncited by 13
- 2024Benign Overfitting in Single-Head Attentioncited by 12
- 2024Training Dynamics of Transformers to Recognize Word Co-occurrence via Gradient Flow Analysiscited by 9
Built on by
Citing papers per year: 2025: 5; 2026: 6.
11 papers.
- 2025Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalizationcited by 14
- 2025Provable Benefit of Curriculum in Transformer Tree-Reasoning Post-Trainingcited by 4
- 2026Context-Free Recognition with Transformerscited by 4
- 2025Transformers Provably Learn Directed Acyclic Graphs via Kernel-Guided Mutual Informationcited by 2
- 2025Transformers with RL or SFT Provably Learn Sparse Boolean Functions, But Differentlycited by 2
- 2026Unlabeled Data Can Provably Enhance In-Context Learning of Transformerscited by 2
- 2025How Transformers Learn In-Context Recall Tasks? Optimality, Training Dynamics and Generalizationcited by 1
- 2026Length Generalization with Log-Depth Recurrent Unitscited by 1
- 2026A Theoretical Analysis of Why Masked Diffusion Models Mitigate the Reversal Cursecited by 0
- 2026The Stability of Singular Distribution: A Spectral Perspective on the Two-Phase Dynamics of Language Model Pre-trainingcited by 0
- 2026Training Dynamics of Transformers on Unbounded Inputs: Attention Learning Can Lag Output Layer Learningcited by 0
- 2026Training Dynamics of Transformers on Unbounded Inputs: Attention Learning Can Lag Output Layer Learning14 Oct 2026
- 2026The Stability of Singular Distribution: A Spectral Perspective on the Two-Phase Dynamics of Language Model Pre-training26 May 2026
- 2026Length Generalization with Log-Depth Recurrent Units25 May 2026
- 2026A Theoretical Analysis of Why Masked Diffusion Models Mitigate the Reversal Curse2 Feb 2026
- 2026Unlabeled Data Can Provably Enhance In-Context Learning of Transformers15 Jan 2026
- 2026Context-Free Recognition with Transformers5 Jan 2026
- 2025Transformers with RL or SFT Provably Learn Sparse Boolean Functions, But Differently22 Nov 2025
- 2025Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalization10 Nov 2025
- 2025Provable Benefit of Curriculum in Transformer Tree-Reasoning Post-Training10 Nov 2025
- 2025Transformers Provably Learn Directed Acyclic Graphs via Kernel-Guided Mutual Information29 Oct 2025
- 2025How Transformers Learn In-Context Recall Tasks? Optimality, Training Dynamics and Generalization21 May 2025
Similar, not cited
Close in wording, no citation either way
- 2025Is Random Attention Sufficient for Sequence Modeling? Disentangling Trainable Components in the Transformer
- 2024From Attention to Activation: Unravelling the Enigmas of Large Language Models
- 2024On Limitation of Transformer for Learning HMMs
- 2026Trust, but Verify: Peeling Low-Bit Transformer Networks for Training Monitoring
- 2025Emergence of Minimal Circuits for Indirect Object Identification in Attention-Only Transformers
- 2023Jump to Conclusions: Short-Cutting Transformers With Linear Transformations
- 2026Transformer-Based Language Models Across Domain Verticals: Architectures, Applications and Critical Assessment
- 2024Towards Universality: Studying Mechanistic Similarity Across Language Model Architectures