mlsanityData to 14 Oct 2026

On the Role of Attention Masks and LayerNorm in Transformers

arXiv 2405.18781 ↗First posted 29 May 2024cs.LG stat.MLcited by 48

Not on the map. Why?

Abstract (arXiv)

Self-attention is the key mechanism of transformers, which are the essential building blocks of modern foundation models. Recent studies have shown that pure self-attention suffers from an increasing degree of rank collapse as depth increases, limiting model expressivity and further utilization of model depth. The existing literature on rank collapse, however, has mostly overlooked other critical components in transformers that may alleviate the rank collapse issue. In this paper, we provide a general analysis of rank collapse under self-attention, taking into account the effects of attention masks and layer normalization (LayerNorm). In particular, we find that although pure masked attention still suffers from exponential collapse to a rank one subspace, sparse or local masked attention can provably slow down the collapse rate. In the case of self-attention with LayerNorm, we first show that for certain classes of value matrices, collapse to a rank one subspace still happens exponentially. However, through construction of nontrivial counterexamples, we then establish that with proper choice of value matrices, a general class of sequences may not converge to a rank one subspace, and the self-attention dynamics with LayerNorm can simultaneously possess a rich set of equilibria with any possible rank between one and full. Our result refutes the previous hypothesis that LayerNorm plays no role in the rank collapse of self-attention and suggests that self-attention with LayerNorm constitutes a much more expressive, versatile nonlinear dynamical system than what was originally thought.

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

Builds on

35 of 41 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. 2020Language Models are Few-Shot Learnerscited by 32,419
  4. 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,305
  5. 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
  6. 2021Swin Transformer: Hierarchical Vision Transformer using Shifted Windowscited by 12,139
  7. 2016Layer Normalizationcited by 5,669
  8. 2020Longformer: The Long-Document Transformercited by 3,413
  9. 2019ALBERT: A Lite BERT for Self-supervised Learning of Language Representationscited by 2,790
  10. 2023Efficient Streaming Language Models with Attention Sinkscited by 2,186
  11. 2020Big Bird: Transformers for Longer Sequencescited by 1,684
  12. 2019Generating Long Sequences with Sparse Transformerscited by 1,546
23 more
  1. 2020On Layer Normalization in the Transformer Architecturecited by 922
  2. 2019How Contextual are Contextualized Word Representations? Comparing the Geometry of BERT, ELMo, and GPT-2 Embeddingscited by 784
  3. 2020Efficient Content-Based Sparse Attention with Routing Transformerscited by 471
  4. 2021Attention is Not All You Need: Pure Attention Loses Rank Doubly Exponentially with Depthcited by 419
  5. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 406
  6. 2019Representation Degeneration Problem in Training Natural Language Generation Modelscited by 255
  7. 2022Neighborhood Attention Transformercited by 239
  8. 2022Recurrent Memory Transformercited by 203
  9. 2023A mathematical perspective on Transformerscited by 164
  10. 2022Signal Propagation in Transformers: Theoretical Perspectives and the Role of Rank Collapsecited by 141
  11. 2023The emergence of clusters in self-attention dynamicscited by 140
  12. 2023Fast Attention Requires Bounded Entriescited by 102
  13. 2023Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformercited by 102
  14. 2023Scaling Transformer to 1M tokens and beyond with RMTcited by 98
  15. 2020O(n) Connections are Expressive Enough: Universal Approximability of Sparse Transformerscited by 83
  16. 2022Revisiting Over-smoothing in BERT from the Perspective of Graphcited by 72
  17. 2024Anisotropy Is Inherent to Self-Attention in Transformerscited by 63
  18. 2023Demystifying Oversmoothing in Attention-Based Graph Neural Networkscited by 49
  19. 2023Deep Transformers without Shortcuts: Modifying Self-attention for Faithful Signal Propagationcited by 45
  20. 2023Slide-Transformer: Hierarchical Vision Transformer with Local Self-Attentioncited by 38
  21. 2023On the Expressivity Role of LayerNorm in Transformers' Attentioncited by 33
  22. 2024TransformerFAM: Feedback attention is working memorycited by 22
  23. 2023On the impact of activation and normalization in obtaining isometric embeddings at initializationcited by 13

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 9; 2025: 17; 2026: 22.

48 papers.

Sort:

By area:

  1. 2025Why do LLMs attend to the first token?cited by 127
  2. 2025On the Emergence of Position Bias in Transformerscited by 59
  3. 2025Attention Sinks and Compression Valleys in LLMs are Two Sides of the Same Coincited by 52
  4. 2024Dynamic metastability in the self-attention modelcited by 46
  5. 2025Hallucination Detection in LLMs Using Spectral Features of Attention Mapscited by 43
  6. 2024Measure-to-measure interpolation using Transformerscited by 29
  7. 2024Understanding and Mitigating Bottlenecks of State Space Models through the Lens of Recency and Over-smoothingcited by 18
  8. 2024The Asymptotic Behavior of Attention in Transformerscited by 16
  9. 2025Pay Attention to Attention Distribution: A New Local Lipschitz Bound for Transformerscited by 11
  10. 2025All You Need is One: Capsule Prompt Tuning with a Single Vectorcited by 8
  11. 2025Optimizing Rank for High-Fidelity Implicit Neural Representationscited by 8
  12. 2024Transformer Normalisation Layers and the Independence of Semantic Subspacescited by 6
36 more
  1. 2025Attention-Only Transformers via Unrolled Subspace Denoisingcited by 5
  2. 2025Rethinking Layer-wise Model Merging through Chain of Mergescited by 5
  3. 2025DoPE: Denoising Rotary Position Embeddingcited by 5
  4. 2024Lambda-Skip Connections: the architectural component that prevents Rank Collapsecited by 4
  5. 2026Revisiting [CLS] and Patch Token Interaction in Vision Transformerscited by 4
  6. 2026Attention Drift: What Autoregressive Speculative Decoding Models Learncited by 4
  7. 2024ReLU's Revival: On the Entropic Overload in Normalization-Free Large Language Modelscited by 3
  8. 2024AERO: Entropy-Guided Framework for Private LLM Inferencecited by 3
  9. 2026NerVE: Nonlinear Eigenspectrum Dynamics in LLM Feed-Forward Networkscited by 3
  10. 2025MODA: MOdular Duplex Attention for Multimodal Perception, Cognition, and Emotion Understandingcited by 2
  11. 2026Stochastic Parroting in Temporal Attention -- Regulating the Diagonal Sinkcited by 2
  12. 2026How Data Shapes RoPE Frequency Usage: From Positional Scale Matching to Length Generalizationcited by 2
  13. 2026Transforming Rank: How Architecture Navigates the Spectral Pathologies of Depthcited by 2
  14. 2024Provable optimal transport with transformers: The essence of depth and prompt engineeringcited by 1
  15. 2025TTrace: Lightweight Error Checking and Diagnosis for Distributed Trainingcited by 1
  16. 2025Understanding the Failure Modes of Transformers through the Lens of Graph Neural Networkscited by 1
  17. 2025Memory as Resonance: A Biomimetic Architecture for Infinite Context Memory on Ergodic Phonetic Manifoldscited by 1
  18. 2026Rank, Head-Channel Non-Identifiability, and Symmetry Breaking: A Precise Analysis of Representational Collapse in Transformerscited by 1
  19. 2026Sink vs. diagonal patterns as mechanisms for attention switch and oversmoothing preventioncited by 1
  20. 2025SSL-SLR: Self-Supervised Representation Learning for Sign Language Recognitioncited by 0
  21. 2025Reversal Invariance in Autoregressive Language Modelscited by 0
  22. 2025How Smoothing is N-simplicial Attention?cited by 0
  23. 2026On the Runway Cascade of Transformers for Language Modelingcited by 0
  24. 2026RefineFormer3D: Efficient 3D Medical Image Segmentation via Adaptive Multi-Scale Transformer with Cross Attention Fusioncited by 0
  25. 2026PeakFocus: Bridging Peak Localization and Intensity Regression via a Unified Multi-Scale Framework for Electricity Load Forecastingcited by 0
  26. 2026Analogies between Transformer Layers and Power Methodcited by 0
  27. 2026Anti Mode-Collapse in Mean-Field Transformer via Auxiliary Variablescited by 0
  28. 2026Activation-Based Active Learning for In-Context Learning: Challenges and Insightscited by 0
  29. 2026A Unifying View of Attention Sinks: From Mechanisms to Architectural Interventionscited by 0
  30. 2026From Self-Attention to Connection Laplacian: A Unified Operator View of Transformerscited by 0
  31. 2026The Devil is in the Spectrum: Mitigating Representation Collapse in LLMs via Topologically Regularized Side-Pathcited by 0
  32. 2026Self-Attention Dynamics with Rotary Position Embeddings: Twisted States and Explicit Consensus Rates on the Spherecited by 0
  33. 2026Why Post-Norm Transformers Collapse: Attention Amplification and Gradient Repair Failurecited by 0
  34. 2026Linear Algebra Foundations of Efficient Attention: A Phase Reversal in Rank Collapse Under SVD Compressioncited by 0
  35. 2026Training and Inference Dynamics of PLDR-LLMs: Row-Map Collapse, Renormalization, and Predictive Reductioncited by 0
  36. 2026Asymptotic Analysis of Discrete-Time Self-Attention Dynamics in Transformerscited by 0