mlsanityData to 14 Oct 2026

Dissecting the Interplay of Attention Paths in a Statistical Mechanics Theory of Transformers

arXiv 2405.15926 ↗First posted 24 May 2024cs.LG cond-mat.dis-nn cond-mat.stat-mechcited by 9

Not on the map. Why?

Abstract (arXiv)

Despite the remarkable empirical performance of Transformers, their theoretical understanding remains elusive. Here, we consider a deep multi-head self-attention network, that is closely related to Transformers yet analytically tractable. We develop a statistical mechanics theory of Bayesian learning in this model, deriving exact equations for the network's predictor statistics under the finite-width thermodynamic limit, i.e., N,Prightarrow∞, P/N=O(1), where N is the network width and P is the number of training examples. Our theory shows that the predictor statistics are expressed as a sum of independent kernels, each one pairing different 'attention paths', defined as information pathways through different attention heads across layers. The kernels are weighted according to a 'task-relevant kernel combination' mechanism that aligns the total kernel with the task labels. As a consequence, this interplay between attention paths enhances generalization performance. Experiments confirm our findings on both synthetic and real-world sequence classification tasks. Finally, our theory explicitly relates the kernel combination mechanism to properties of the learned weights, allowing for a qualitative transfer of its insights to models trained via gradient descent. As an illustration, we demonstrate an efficient size reduction of the network, by pruning those attention heads that are deemed less relevant by our theory.

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

Builds on

56 of 70 references.

References · 56

  1. 2017Attention Is All You Needcited by 60,361
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  3. 2020Language Models are Few-Shot Learnerscited by 32,419
  4. 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 30,186
  5. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
  6. 2014Neural Machine Translation by Jointly Learning to Align and Translatecited by 4,548
  7. 2017Fashion-MNIST: a Novel Image Dataset for Benchmarking Machine Learning Algorithmscited by 4,349
  8. 2016Matching Networks for One Shot Learningcited by 2,255
  9. 2016Understanding deep learning requires rethinking generalizationcited by 1,674
  10. 2018Reconciling modern machine learning practice and the bias-variance trade-offcited by 927
  11. 2019Analyzing Multi-Head Self-Attention: Specialized Heads Do the Heavy Lifting, the Rest Can Be Prunedcited by 856
  12. 2017Deep Neural Networks as Gaussian Processescited by 622
38 more
  1. 2023TinyStories: How Small Can Language Models Be and Still Speak Coherent English?cited by 449
  2. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 406
  3. 2018Pyro: Deep Universal Probabilistic Programmingcited by 380
  4. 2023Trained Transformers Learn Linear Models In-Contextcited by 337
  5. 2017A Structured Self-attentive Sentence Embeddingcited by 318
  6. 2018Gaussian Process Behaviour in Wide Deep Neural Networkscited by 317
  7. 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 298
  8. 2019Theoretical Limitations of Self-Attention in Neural Sequence Modelscited by 288
  9. 2023Deja Vu: Contextual Sparsity for Efficient LLMs at Inference Timecited by 252
  10. 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 222
  11. 2016A Decomposable Attention Model for Natural Language Inferencecited by 215
  12. 2017A Conceptual Introduction to Hamiltonian Monte Carlocited by 209
  13. 2019Composable Effects for Flexible and Accelerated Probabilistic Programming in NumPyrocited by 191
  14. 2018A mathematical theory of semantic development in deep neural networkscited by 186
  15. 2020Spectral Bias and Task-Model Alignment Explain Generalization in Kernel Regression and Infinitely Wide Neural Networkscited by 166
  16. 2023A mathematical perspective on Transformerscited by 164
  17. 2016Long Short-Term Memory-Networks for Machine Readingcited by 161
  18. 2021Inductive Biases and Variable Creation in Self-Attention Mechanismscited by 144
  19. 2020Infinite attention: NNGP and NTK for deep attention networkscited by 121
  20. 2023What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalizationcited by 118
  21. 2023The mechanistic basis of data dependence and abrupt learning in an in-context classification taskcited by 118
  22. 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
  23. 2022Self-Consistent Dynamical Field Theory of Kernel Evolution in Wide Neural Networkscited by 105
  24. 2023Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformercited by 102
  25. 2017Structured Attention Networkscited by 95
  26. 2022Vision Transformers provably learn spatial structurecited by 93
  27. 2023A Theoretical Understanding of Shallow Vision Transformers: Learning, Generalization, and Sample Complexitycited by 77
  28. 2023How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representationscited by 75
  29. 2020Statistical Mechanics of Deep Linear Neural Networks: The Back-Propagating Kernel Renormalizationcited by 71
  30. 2023Max-Margin Token Selection in Attention Mechanismcited by 58
  31. 2019Torchmeta: A Meta-Learning library for PyTorchcited by 52
  32. 2023Transformers learn through gradual rank increasecited by 52
  33. 2023The Shaped Transformer: Attention Models in the Infinite Depth-and-Width Limitcited by 47
  34. 2023Dynamics of Finite Width Kernel and Prediction Fluctuations in Mean Field Neural Networkscited by 43
  35. 2023Bayes-optimal Learning of Deep Random Networks of Extensive-widthcited by 41
  36. 2023What can a Single Attention Layer Learn? A Study Through the Random Features Lenscited by 40
  37. 2024How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?cited by 35
  38. 2022Unraveling Attention via Convex Duality: Analysis and Interpretations of Vision Transformerscited by 30

50 most cited of 56 All 56 (JSON)

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 3; 2025: 3; 2026: 3.

9 papers.