mlsanityData to 14 Oct 2026

Training Dynamics of Transformers to Recognize Word Co-occurrence via Gradient Flow Analysis

arXiv 2410.09605 ↗First posted 12 Oct 2024cs.LG cs.CLcited by 9

Not on the map. Why?

Abstract (arXiv)

Understanding the training dynamics of transformers is important to explain the impressive capabilities behind large language models. In this work, we study the dynamics of training a shallow transformer on a task of recognizing co-occurrence of two designated words. In the literature of studying training dynamics of transformers, several simplifications are commonly adopted such as weight reparameterization, attention linearization, special initialization, and lazy regime. In contrast, we analyze the gradient flow dynamics of simultaneously training three attention matrices and a linear MLP layer from random initialization, and provide a framework of analyzing such dynamics via a coupled dynamical system. We establish near minimum loss and characterize the attention model after training. We discover that gradient flow serves as an inherent mechanism that naturally divide the training process into two phases. In Phase 1, the linear MLP quickly aligns with the two target signals for correct classification, whereas the softmax attention remains almost unchanged. In Phase 2, the attention matrices and the MLP evolve jointly to enlarge the classification margin and reduce the loss to a near minimum value. Technically, we prove a novel property of the gradient flow, termed textitautomatic balancing of gradients, which enables the loss values of different samples to decrease almost at the same rate and further facilitates the proof of near minimum training loss. We also conduct experiments to verify our theoretical results.

Key facts. Cited by 9 papers in the map (data through 14 Oct 2026). Builds on 35 of its 42 references that are in the map. First posted on arXiv 12 Oct 2024.

Builds on

35 of 42 references.

References · 35

  1. 2017Attention Is All You Needcited by 60,361
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  3. 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 30,186
  4. 2023GPT-4 Technical Reportcited by 18,396
  5. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
  6. 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,592
  7. 2023PaLM 2 Technical Reportcited by 1,162
  8. 2023Gemini: A Family of Highly Capable Multimodal Modelscited by 872
  9. 2022Transformers learn in-context by gradient descentcited by 732
  10. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 406
  11. 2023Trained Transformers Learn Linear Models In-Contextcited by 337
  12. 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 298
23 more
  1. 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
  2. 2022Transformers Learn Shortcuts to Automatacited by 268
  3. 2021Inductive Biases and Variable Creation in Self-Attention Mechanismscited by 144
  4. 2023Representational Strengths and Limitations of Transformerscited by 133
  5. 2023What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalizationcited by 118
  6. 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
  7. 2023In-Context Convergence of Transformerscited by 115
  8. 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 102
  9. 2023Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformercited by 102
  10. 2022Vision Transformers provably learn spatial structurecited by 93
  11. 2023How Do Transformers Learn Topic Structure: Towards a Mechanistic Understandingcited by 86
  12. 2021Why Do Pretrained Language Models Help in Downstream Tasks? An Analysis of Head and Prompt Tuningcited by 82
  13. 2023A Theoretical Understanding of Shallow Vision Transformers: Learning, Generalization, and Sample Complexitycited by 77
  14. 2024Training Dynamics of Multi-Head Softmax Attention for In-Context Learning: Emergence, Convergence, and Optimalitycited by 74
  15. 2023Max-Margin Token Selection in Attention Mechanismcited by 58
  16. 2023JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attentioncited by 52
  17. 2023Do Transformers Parse while Predicting the Masked Word?cited by 48
  18. 2024How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?cited by 35
  19. 2024Implicit Bias and Fast Convergence Rates for Self-attentioncited by 31
  20. 2024Provably learning a multi-head attention layercited by 21
  21. 2024Implicit Optimization Bias of Next-Token Prediction in Linear Modelscited by 14
  22. 2023On the Convergence of Encoder-only Shallow Transformerscited by 13
  23. 2024A Theoretical Analysis of Self-Supervised Learning for Vision Transformerscited by 6

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 5; 2026: 4.

9 papers.