mlsanityData to 14 Oct 2026

Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformer

arXiv 2305.16380 ↗First posted 25 May 2023cs.CL cs.AI cs.LGcited by 102

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

  1. 2017Attention Is All You Needcited by 60,361
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  3. 2014Adam: A Method for Stochastic Optimizationcited by 37,240
  4. 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,744
  5. 2020Language Models are Few-Shot Learnerscited by 32,419
  6. 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 30,186
  7. 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
  8. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
  9. 2021Swin Transformer: Hierarchical Vision Transformer using Shifted Windowscited by 12,139
  10. 2021Masked Autoencoders Are Scalable Vision Learnerscited by 7,403
  11. 2016Layer Normalizationcited by 5,669
  12. 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
38 more
  1. 2020wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representationscited by 3,905
  2. 2022OPT: Open Pre-trained Transformer Language Modelscited by 3,512
  3. 2016Pointer Sentinel Mixture Modelscited by 3,096
  4. 2022Scaling Instruction-Finetuned Language Modelscited by 3,024
  5. 2018Neural Tangent Kernel: Convergence and Generalization in Neural Networkscited by 2,621
  6. 2020Learning to summarize from human feedbackcited by 2,588
  7. 2020Reformer: The Efficient Transformercited by 1,668
  8. 2019Root Mean Square Layer Normalizationcited by 1,480
  9. 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
  10. 2022In-context Learning and Induction Headscited by 964
  11. 2018Adafactor: Adaptive Learning Rates with Sublinear Memory Costcited by 905
  12. 2018A Convergence Theory for Deep Learning via Over-Parameterizationcited by 787
  13. 2022Transformers learn in-context by gradient descentcited by 732
  14. 2022data2vec: A General Framework for Self-supervised Learning in Speech, Vision and Languagecited by 727
  15. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 715
  16. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
  17. 2018On Lazy Training in Differentiable Programmingcited by 675
  18. 2018Gradient Descent Provably Optimizes Over-parameterized Neural Networkscited by 659
  19. 2018Universal Transformerscited by 647
  20. 2018Gradient Descent Finds Global Minima of Deep Neural Networkscited by 574
  21. 2019Fine-Grained Analysis of Optimization and Generalization for Overparameterized Two-Layer Neural Networkscited by 566
  22. 2018A Mean Field View of the Landscape of Two-Layers Neural Networkscited by 466
  23. 2018On the Global Convergence of Gradient Descent for Over-parameterized Models using Optimal Transportcited by 426
  24. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 406
  25. 2018Learning and Generalization in Overparameterized Neural Networks, Going Beyond Two Layerscited by 340
  26. 2022UL2: Unifying Language Learning Paradigmscited by 295
  27. 2022Tensor Programs V: Tuning Large Neural Networks via Zero-Shot Hyperparameter Transfercited by 288
  28. 2018Learning Overparameterized Neural Networks via Stochastic Gradient Descent on Structured Datacited by 261
  29. 2022Exploring Length Generalization in Large Language Modelscited by 206
  30. 2022Hidden Progress in Deep Learning: SGD Learns Parities Near the Computational Limitcited by 187
  31. 2018A Convergence Analysis of Gradient Descent for Deep Linear Neural Networkscited by 184
  32. 2019Towards moderate overparameterization: global convergence guarantees for training shallow neural networkscited by 176
  33. 2021Inductive Biases and Variable Creation in Self-Attention Mechanismscited by 144
  34. 2020Infinite attention: NNGP and NTK for deep attention networkscited by 121
  35. 2021Self-Attention Networks Can Process Bounded Hierarchical Languagescited by 105
  36. 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 102
  37. 2022Vision Transformers provably learn spatial structurecited by 93
  38. 2023How Do Transformers Learn Topic Structure: Towards a Mechanistic Understandingcited by 86

50 most cited of 72 All 72 (JSON)

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2023: 9; 2024: 52; 2025: 20; 2026: 21.

102 papers.

Sort:

By area:

  1. 2024KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cachecited by 637
  2. 2023Birth of a Transformer: A Memory Viewpointcited by 161
  3. 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
  4. 2023In-Context Convergence of Transformerscited by 115
  5. 2024A Primer on the Inner Workings of Transformer-based Language Modelscited by 85
  6. 2023Transformers as Support Vector Machinescited by 74
  7. 2023Attention Satisfies: A Constraint-Satisfaction Lens on Factual Errors of Language Modelscited by 67
  8. 2024How Large Language Models Encode Context Knowledge? A Layer-Wise Probing Studycited by 64
  9. 2024RNNs are not Transformers (Yet): The Key Bottleneck on In-context Retrievalcited by 64
  10. 2023Max-Margin Token Selection in Attention Mechanismcited by 58
  11. 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 57
  12. 2024Demystifying Verbatim Memorization in Large Language Modelscited by 56
38 more
  1. 2024Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMscited by 56
  2. 2023JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attentioncited by 52
  3. 2024On the Role of Attention Masks and LayerNorm in Transformerscited by 48
  4. 2025Training Dynamics of In-Context Learning in Linear Attentioncited by 46
  5. 2024Why Larger Language Models Do In-context Learning Differently?cited by 45
  6. 2024An Information-Theoretic Analysis of In-Context Learningcited by 40
  7. 2024Attention with Markov: A Framework for Principled Analysis of Transformers via Markov Chainscited by 40
  8. 2023On the Optimization and Generalization of Multi-head Attentioncited by 37
  9. 2024How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?cited by 35
  10. 2024From Self-Attention to Markov Models: Unveiling the Dynamics of Generative Transformerscited by 34
  11. 2024Mechanics of Next Token Prediction with Self-Attentioncited by 34
  12. 2024Backward Lens: Projecting Language Model Gradients into the Vocabulary Spacecited by 32
  13. 2024Understanding Finetuning for Factual Knowledge Extractioncited by 32
  14. 2025Transformers Learn to Implement Multi-step Gradient Descent with Chain of Thoughtcited by 32
  15. 2024Implicit Bias and Fast Convergence Rates for Self-attentioncited by 31
  16. 2024A phase transition between positional and semantic learning in a solvable model of dot-product attentioncited by 30
  17. 2024Linear Transformers are Versatile In-Context Learnerscited by 28
  18. 2024Towards a Theoretical Understanding of the 'Reversal Curse' via Training Dynamicscited by 27
  19. 2024Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannotcited by 22
  20. 2024Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descentcited by 22
  21. 2024Self-attention Networks Localize When QK-eigenspectrum Concentratescited by 19
  22. 2024Implicit Regularization of Gradient Flow on One-Layer Softmax Attentioncited by 19
  23. 2024Attention layers provably solve single-location regressioncited by 17
  24. 2024On the Surprising Effectiveness of Attention Transfer for Vision Transformerscited by 17
  25. 2024One-Layer Transformer Provably Learns One-Nearest Neighbor In Contextcited by 16
  26. 2024Do LLMs dream of elephants (when told not to)? Latent concept association and associative memory in transformerscited by 15
  27. 2024Implicit Optimization Bias of Next-Token Prediction in Linear Modelscited by 14
  28. 2024What Improves the Generalization of Graph Transformers? A Theoretical Dive into the Self-attention and Positional Encodingcited by 14
  29. 2024How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regressioncited by 14
  30. 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysiscited by 14
  31. 2024Non-asymptotic Convergence of Training Transformers for Next-token Predictioncited by 13
  32. 2024Next-token prediction capacity: general upper bounds and a lower bound for transformerscited by 11
  33. 2024Unraveling the Gradient Descent Dynamics of Transformerscited by 11
  34. 2025How Transformers Learn Regular Language Recognition: A Theoretical Study on Training Dynamics and Implicit Biascited by 11
  35. 2025Generalization or Hallucination? Understanding Out-of-Context Reasoning in Transformerscited by 10
  36. 2025From Condensation to Rank Collapse: A Two-Stage Analysis of Transformer Training Dynamicscited by 10
  37. 2024Dissecting the Interplay of Attention Paths in a Statistical Mechanics Theory of Transformerscited by 9
  38. 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)