Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformer
Not on the map. Why?
Abstract (arXiv)
Transformer architecture has shown impressive performance in multiple research domains and has become the backbone of many neural network models. However, there is limited understanding on how it works. In particular, with a simple predictive loss, how the representation emerges from the gradient training dynamics remains a mystery. In this paper, for 1-layer transformer with one self-attention layer plus one decoder layer, we analyze its SGD training dynamics for the task of next token prediction in a mathematically rigorous manner. We open the black box of the dynamic process of how the self-attention layer combines input tokens, and reveal the nature of underlying inductive bias. More specifically, with the assumption (a) no positional encoding, (b) long input sequence, and (c) the decoder layer learns faster than the self-attention layer, we prove that self-attention acts as a discriminative scanning algorithm: starting from uniform attention, it gradually attends more to distinct key tokens for a specific next token to be predicted, and pays less attention to common key tokens that occur across different next tokens. Among distinct tokens, it progressively drops attention weights, following the order of low to high co-occurrence between the key and the query token in the training set. Interestingly, this procedure does not lead to winner-takes-all, but decelerates due to a phase transition that is controllable by the learning rates of the two layers, leaving (almost) fixed token combination. We verify this textbfscan and snap dynamics on synthetic and real-world data (WikiText).
Key facts. Cited by 102 papers in the map (data through 14 Oct 2026). Builds on 72 of its 88 references that are in the map. First posted on arXiv 25 May 2023.
Builds on
72 of 88 references.
References · 72
- 2017Attention Is All You Needcited by 60,361
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
- 2014Adam: A Method for Stochastic Optimizationcited by 37,240
- 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,744
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 30,186
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
- 2021Swin Transformer: Hierarchical Vision Transformer using Shifted Windowscited by 12,139
- 2021Masked Autoencoders Are Scalable Vision Learnerscited by 7,403
- 2016Layer Normalizationcited by 5,669
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
38 more
- 2020wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representationscited by 3,905
- 2022OPT: Open Pre-trained Transformer Language Modelscited by 3,512
- 2016Pointer Sentinel Mixture Modelscited by 3,096
- 2022Scaling Instruction-Finetuned Language Modelscited by 3,024
- 2018Neural Tangent Kernel: Convergence and Generalization in Neural Networkscited by 2,621
- 2020Learning to summarize from human feedbackcited by 2,588
- 2020Reformer: The Efficient Transformercited by 1,668
- 2019Root Mean Square Layer Normalizationcited by 1,480
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
- 2022In-context Learning and Induction Headscited by 964
- 2018Adafactor: Adaptive Learning Rates with Sublinear Memory Costcited by 905
- 2018A Convergence Theory for Deep Learning via Over-Parameterizationcited by 787
- 2022Transformers learn in-context by gradient descentcited by 732
- 2022data2vec: A General Framework for Self-supervised Learning in Speech, Vision and Languagecited by 727
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 715
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
- 2018On Lazy Training in Differentiable Programmingcited by 675
- 2018Gradient Descent Provably Optimizes Over-parameterized Neural Networkscited by 659
- 2018Universal Transformerscited by 647
- 2018Gradient Descent Finds Global Minima of Deep Neural Networkscited by 574
- 2019Fine-Grained Analysis of Optimization and Generalization for Overparameterized Two-Layer Neural Networkscited by 566
- 2018A Mean Field View of the Landscape of Two-Layers Neural Networkscited by 466
- 2018On the Global Convergence of Gradient Descent for Over-parameterized Models using Optimal Transportcited by 426
- 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 406
- 2018Learning and Generalization in Overparameterized Neural Networks, Going Beyond Two Layerscited by 340
- 2022UL2: Unifying Language Learning Paradigmscited by 295
- 2022Tensor Programs V: Tuning Large Neural Networks via Zero-Shot Hyperparameter Transfercited by 288
- 2018Learning Overparameterized Neural Networks via Stochastic Gradient Descent on Structured Datacited by 261
- 2022Exploring Length Generalization in Large Language Modelscited by 206
- 2022Hidden Progress in Deep Learning: SGD Learns Parities Near the Computational Limitcited by 187
- 2018A Convergence Analysis of Gradient Descent for Deep Linear Neural Networkscited by 184
- 2019Towards moderate overparameterization: global convergence guarantees for training shallow neural networkscited by 176
- 2021Inductive Biases and Variable Creation in Self-Attention Mechanismscited by 144
- 2020Infinite attention: NNGP and NTK for deep attention networkscited by 121
- 2021Self-Attention Networks Can Process Bounded Hierarchical Languagescited by 105
- 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 102
- 2022Vision Transformers provably learn spatial structurecited by 93
- 2023How Do Transformers Learn Topic Structure: Towards a Mechanistic Understandingcited by 86
50 most cited of 72 All 72 (JSON)
Built on by
Citing papers per year: 2023: 9; 2024: 52; 2025: 20; 2026: 21.
102 papers.
Sort:
By area:
- 2024KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cachecited by 637
- 2023Birth of a Transformer: A Memory Viewpointcited by 161
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
- 2023In-Context Convergence of Transformerscited by 115
- 2024A Primer on the Inner Workings of Transformer-based Language Modelscited by 85
- 2023Transformers as Support Vector Machinescited by 74
- 2023Attention Satisfies: A Constraint-Satisfaction Lens on Factual Errors of Language Modelscited by 67
- 2024How Large Language Models Encode Context Knowledge? A Layer-Wise Probing Studycited by 64
- 2024RNNs are not Transformers (Yet): The Key Bottleneck on In-context Retrievalcited by 64
- 2023Max-Margin Token Selection in Attention Mechanismcited by 58
- 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 57
- 2024Demystifying Verbatim Memorization in Large Language Modelscited by 56
38 more
- 2024Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMscited by 56
- 2023JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attentioncited by 52
- 2024On the Role of Attention Masks and LayerNorm in Transformerscited by 48
- 2025Training Dynamics of In-Context Learning in Linear Attentioncited by 46
- 2024Why Larger Language Models Do In-context Learning Differently?cited by 45
- 2024An Information-Theoretic Analysis of In-Context Learningcited by 40
- 2024Attention with Markov: A Framework for Principled Analysis of Transformers via Markov Chainscited by 40
- 2023On the Optimization and Generalization of Multi-head Attentioncited by 37
- 2024How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?cited by 35
- 2024From Self-Attention to Markov Models: Unveiling the Dynamics of Generative Transformerscited by 34
- 2024Mechanics of Next Token Prediction with Self-Attentioncited by 34
- 2024Backward Lens: Projecting Language Model Gradients into the Vocabulary Spacecited by 32
- 2024Understanding Finetuning for Factual Knowledge Extractioncited by 32
- 2025Transformers Learn to Implement Multi-step Gradient Descent with Chain of Thoughtcited by 32
- 2024Implicit Bias and Fast Convergence Rates for Self-attentioncited by 31
- 2024A phase transition between positional and semantic learning in a solvable model of dot-product attentioncited by 30
- 2024Linear Transformers are Versatile In-Context Learnerscited by 28
- 2024Towards a Theoretical Understanding of the 'Reversal Curse' via Training Dynamicscited by 27
- 2024Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannotcited by 22
- 2024Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descentcited by 22
- 2024Self-attention Networks Localize When QK-eigenspectrum Concentratescited by 19
- 2024Implicit Regularization of Gradient Flow on One-Layer Softmax Attentioncited by 19
- 2024Attention layers provably solve single-location regressioncited by 17
- 2024On the Surprising Effectiveness of Attention Transfer for Vision Transformerscited by 17
- 2024One-Layer Transformer Provably Learns One-Nearest Neighbor In Contextcited by 16
- 2024Do LLMs dream of elephants (when told not to)? Latent concept association and associative memory in transformerscited by 15
- 2024Implicit Optimization Bias of Next-Token Prediction in Linear Modelscited by 14
- 2024What Improves the Generalization of Graph Transformers? A Theoretical Dive into the Self-attention and Positional Encodingcited by 14
- 2024How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regressioncited by 14
- 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
- 2024Next-token prediction capacity: general upper bounds and a lower bound for transformerscited by 11
- 2024Unraveling the Gradient Descent Dynamics of Transformerscited by 11
- 2025How Transformers Learn Regular Language Recognition: A Theoretical Study on Training Dynamics and Implicit Biascited by 11
- 2025Generalization or Hallucination? Understanding Out-of-Context Reasoning in Transformerscited by 10
- 2025From Condensation to Rank Collapse: A Two-Stage Analysis of Transformer Training Dynamicscited by 10
- 2024Dissecting the Interplay of Attention Paths in a Statistical Mechanics Theory of Transformerscited by 9
- 2024Amuro and Char: Analyzing the Relationship between Pre-Training and Fine-Tuning of Large Language Modelscited by 9
50 most cited of 102 All 102 (JSON)
- 2026Training Dynamics of Transformers on Unbounded Inputs: Attention Learning Can Lag Output Layer Learning14 Oct 2026
- 2026Attention Graphons: A Graph Limit Perspective on Graph Transformers28 Sep 2026
- 2026Faster Query-Key Learning Sharpens Attention in Self-Attention Models7 Aug 2026
- 2026Syntax vs. Semantics: How Transformers Learn Deep Dependencies26 Jun 2026
- 2026A Novel Approach to Temporal QoS Estimation via Extended Kalman Filter-Incorporated Latent Feature Analysis22 Jun 2026
- 2026FAiT: Frequency-Aware Inverted Transformer for Multivariate Time Series Forecasting31 May 2026
- 2026Transformers Provably Learn to Internalize Chain-of-Thought27 May 2026
- 2026The Stability of Singular Distribution: A Spectral Perspective on the Two-Phase Dynamics of Language Model Pre-training26 May 2026
- 2026Emergence of Frontier Superposition: M"obius attractor and Cascade Supervision12 May 2026
- 2026Transformers Provably Implement In-Context Reinforcement Learning with Policy Improvement7 May 2026
- 2026Sampling at intermediate temperatures is optimal for training large language models in protein structure prediction31 Mar 2026
- 2026Reconciling In-Context and In-Weight Learning via Dual Representation Space Encoding13 Mar 2026
38 more
- 2026Feature Resemblance: Towards a Theoretical Understanding of Analogical Reasoning in Transformers5 Mar 2026
- 2026Incremental Learning of Sparse Attention Patterns in Transformers22 Feb 2026
- 2026Uncovering Context Reliance in Unstructured Knowledge Editing22 Feb 2026
- 2026Breaking the Reversal Curse in Autoregressive Language Models via Identity Bridge2 Feb 2026
- 2026A Theoretical Analysis of Why Masked Diffusion Models Mitigate the Reversal Curse2 Feb 2026
- 2026Tuning the Implicit Regularizer of Masked Diffusion Language Models: Enhancing Generalization via Insights from k-Parity30 Jan 2026
- 2026How Do Transformers Learn to Associate Tokens: Gradient Leading Terms Bring Mechanistic Interpretability27 Jan 2026
- 2026Provably Learning Attention with Queries23 Jan 2026
- 2026Unlabeled Data Can Provably Enhance In-Context Learning of Transformers15 Jan 2026
- 2025Towards Understanding Transformers in Learning Random Walks28 Nov 2025
- 2025Facts in Stats: Impacts of Pretraining Diversity on Language Model Generalization17 Oct 2025
- 2025From Condensation to Rank Collapse: A Two-Stage Analysis of Transformer Training Dynamics8 Oct 2025
- 2025Decoupling Positional and Symbolic Attention Behavior in Transformers3 Oct 2025
- 2025Pool Me Wisely: On the Effect of Pooling in Transformer-Based Models2 Oct 2025
- 2025Hedonic Neurons: A Mechanistic Mapping of Latent Coalitions in Transformer MLPs28 Sep 2025
- 2025DISCO: Disentangled Communication Steering for Large Language Models20 Sep 2025
- 2025SSA: Improving Performance With a Better Scoring Function20 Aug 2025
- 2025Generalization or Hallucination? Understanding Out-of-Context Reasoning in Transformers12 Jun 2025
- 2025On the Convergence of Gradient Descent on Learning Transformers with Residual Connections5 Jun 2025
- 2025Bayes optimal learning of attention-indexed models2 Jun 2025
- 2025Taming Transformer Without Using Learning Rate Warmup28 May 2025
- 2025Attention with Trained Embeddings Provably Selects Important Tokens22 May 2025
- 2025How Transformers Learn In-Context Recall Tasks? Optimality, Training Dynamics and Generalization21 May 2025
- 2025How Transformers Learn Regular Language Recognition: A Theoretical Study on Training Dynamics and Implicit Bias2 May 2025
- 2025Transformers Learn to Implement Multi-step Gradient Descent with Chain of Thought28 Feb 2025
- 2025Disentangling Feature Structure: A Mathematically Provable Two-Stage Training Dynamics in Transformers28 Feb 2025
- 2025On the Robustness of Transformers against Context Hijacking for Linear Classification21 Feb 2025
- 2025Understanding Generalization in Transformers: Error Bounds and Training Dynamics Under Benign and Harmful Overfitting18 Feb 2025
- 2025Training Dynamics of In-Context Learning in Linear Attention27 Jan 2025
- 2024Reversed Attention: On The Gradient Descent Of Attention Layers In GPT22 Dec 2024
- 2024Revisiting the Initial Steps in Adaptive Gradient Descent Optimization3 Dec 2024
- 2024One-Layer Transformer Provably Learns One-Nearest Neighbor In Context16 Nov 2024
- 2024On the Surprising Effectiveness of Attention Transfer for Vision Transformers14 Nov 2024
- 2024Unraveling the Gradient Descent Dynamics of Transformers12 Nov 2024
- 2024A Mechanistic Study of Transformers Training Dynamics31 Oct 2024
- 2024Optimizing Attention with Mirror Descent: Generalized Max-Margin Token Selection18 Oct 2024
- 2024On the Learn-to-Optimize Capabilities of Transformers in In-Context Sparse Recovery17 Oct 2024
- 2024Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMs17 Oct 2024
50 newest of 102 All 102 (JSON)
- 2025Transformers Learn to Implement Multi-step Gradient Descent with Chain of Thoughtcited by 32
- 2024Towards a Theoretical Understanding of the 'Reversal Curse' via Training Dynamicscited by 27
- 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysiscited by 14
- 2025Generalization or Hallucination? Understanding Out-of-Context Reasoning in Transformerscited by 10
- 2026Breaking the Reversal Curse in Autoregressive Language Models via Identity Bridgecited by 2
- 2026Transformers Provably Learn to Internalize Chain-of-Thoughtcited by 2
- 2026Feature Resemblance: Towards a Theoretical Understanding of Analogical Reasoning in Transformerscited by 0
- 2026Emergence of Frontier Superposition: M"obius attractor and Cascade Supervisioncited by 0
- 2026Transformers Provably Learn to Internalize Chain-of-Thought27 May 2026
- 2026Emergence of Frontier Superposition: M"obius attractor and Cascade Supervision12 May 2026
- 2026Feature Resemblance: Towards a Theoretical Understanding of Analogical Reasoning in Transformers5 Mar 2026
- 2026Breaking the Reversal Curse in Autoregressive Language Models via Identity Bridge2 Feb 2026
- 2025Generalization or Hallucination? Understanding Out-of-Context Reasoning in Transformers12 Jun 2025
- 2025Transformers Learn to Implement Multi-step Gradient Descent with Chain of Thought28 Feb 2025
- 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysis3 Oct 2024
- 2024Towards a Theoretical Understanding of the 'Reversal Curse' via Training Dynamics7 May 2024
- 2024KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cachecited by 637
- 2023Birth of a Transformer: A Memory Viewpointcited by 161
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
- 2023In-Context Convergence of Transformerscited by 115
- 2024A Primer on the Inner Workings of Transformer-based Language Modelscited by 85
- 2023Transformers as Support Vector Machinescited by 74
- 2023Attention Satisfies: A Constraint-Satisfaction Lens on Factual Errors of Language Modelscited by 67
- 2024How Large Language Models Encode Context Knowledge? A Layer-Wise Probing Studycited by 64
- 2024RNNs are not Transformers (Yet): The Key Bottleneck on In-context Retrievalcited by 64
- 2023Max-Margin Token Selection in Attention Mechanismcited by 58
- 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 57
- 2024Demystifying Verbatim Memorization in Large Language Modelscited by 56
- 2024Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMscited by 56
12 most cited of 87 All 87 (JSON)
- 2026Training Dynamics of Transformers on Unbounded Inputs: Attention Learning Can Lag Output Layer Learning14 Oct 2026
- 2026Attention Graphons: A Graph Limit Perspective on Graph Transformers28 Sep 2026
- 2026Faster Query-Key Learning Sharpens Attention in Self-Attention Models7 Aug 2026
- 2026Syntax vs. Semantics: How Transformers Learn Deep Dependencies26 Jun 2026
- 2026A Novel Approach to Temporal QoS Estimation via Extended Kalman Filter-Incorporated Latent Feature Analysis22 Jun 2026
- 2026FAiT: Frequency-Aware Inverted Transformer for Multivariate Time Series Forecasting31 May 2026
- 2026The Stability of Singular Distribution: A Spectral Perspective on the Two-Phase Dynamics of Language Model Pre-training26 May 2026
- 2026Sampling at intermediate temperatures is optimal for training large language models in protein structure prediction31 Mar 2026
- 2026Reconciling In-Context and In-Weight Learning via Dual Representation Space Encoding13 Mar 2026
- 2026Incremental Learning of Sparse Attention Patterns in Transformers22 Feb 2026
- 2026Uncovering Context Reliance in Unstructured Knowledge Editing22 Feb 2026
- 2026Provably Learning Attention with Queries23 Jan 2026
12 newest of 87 All 87 (JSON)