Memorization Capacity of Multi-Head Attention in Transformers
Not on the map. Why?
Abstract (arXiv)
Transformers have become the go-to architecture for language and vision tasks, yet their theoretical properties, especially memorization capacity, remain elusive. This paper investigates the memorization abilities of multi-head attention mechanisms, examining how many example sequences they can memorize, as a function of the number of heads and sequence length. Motivated by experimental findings on vision transformers, we introduce novel assumptions about the linear independence of input data, distinct from the commonly used general-position assumption. Under these assumptions, we demonstrate that an attention layer with H heads, dimension d, and context size n < d, featuring Theta(Hd2) parameters, can memorize Omega(Hn) examples. Our analysis sheds light on how different attention heads handle various example sequences, aided by the softmax operator's saturation property. We validate our findings through experiments on synthetic data.
Key facts. Cited by 39 papers in the map (data through 7 Oct 2026). Builds on 32 of its 48 references that are in the map. First posted on arXiv 3 Jun 2023.
Builds on
32 of 48 references.
References · 32
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
- 2023GPT-4 Technical Reportcited by 18,132
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2019HuggingFace's Transformers: State-of-the-art Natural Language Processingcited by 2,201
- 2020Extracting Training Data from Large Language Modelscited by 2,144
- 2016Understanding deep learning requires rethinking generalizationcited by 1,657
- 2020Transformer Feed-Forward Layers Are Key-Value Memoriescited by 1,307
- 2022Transformers learn in-context by gradient descentcited by 714
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
20 more
- 2023Scaling Vision Transformers to 22 Billion Parameterscited by 690
- 2020Hopfield Networks is All You Needcited by 461
- 2021Attention is Not All You Need: Pure Attention Loses Rank Doubly Exponentially with Depthcited by 411
- 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 220
- 2021Inductive Biases and Variable Creation in Self-Attention Mechanismscited by 144
- 2022Vision Transformers provably learn spatial structurecited by 92
- 2020Low-Rank Bottleneck in Multi-head Attention Modelscited by 88
- 2020O(n) Connections are Expressive Enough: Universal Approximability of Sparse Transformerscited by 82
- 2023A Theoretical Understanding of Shallow Vision Transformers: Learning, Generalization, and Sample Complexitycited by 77
- 2018Small ReLU networks are powerful memorizers: a tight analysis of memorization capacitycited by 76
- 2022Your Transformer May Not be as Powerful as You Expectcited by 55
- 2021On the Optimal Memorization Power of ReLU Neural Networkscited by 40
- 2022Memorization and Optimization in Deep Neural Networks with Minimum Over-parameterizationcited by 36
- 2020Provable Memorization via Deep Neural Networks using Sub-linear Parameterscited by 34
- 2022Unraveling Attention via Convex Duality: Analysis and Interpretations of Vision Transformerscited by 30
- 2020Network size and weights size for memorization with two-layers neural networkscited by 16
- 2021An Exponential Improvement on the Memorization Capacity of Deep Threshold Networkscited by 14
- 2020Memory capacity of neural networks with threshold and ReLU activationscited by 13
- 2022When Expressivity Meets Trainability: Fewer than n Neurons Can Workcited by 8
Built on by
Citing papers per year: 2023: 4; 2024: 19; 2025: 12; 2026: 4.
39 papers.
Sort:
By area:
- 2023Challenges and Applications of Large Language Modelscited by 251
- 2025How much do language models memorize?cited by 53
- 2023Are Transformers with One Layer Self-Attention Using Low-Rank Weight Matrices Universal Approximators?cited by 46
- 2024Understanding Factual Recall in Transformers via Associative Memoriescited by 45
- 2024On Statistical Rates and Provably Efficient Criteria of Latent Diffusion Transformers (DiTs)cited by 39
- 2023On the Optimization and Generalization of Multi-head Attentioncited by 37
- 2024How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpadcited by 35
- 2024Implicit Bias and Fast Convergence Rates for Self-attentioncited by 31
- 2024Undesirable Memorization in Large Language Models: A Surveycited by 29
- 2025Taming Knowledge Conflicts in Language Modelscited by 27
- 2024Prompting a Pretrained Transformer Can Be a Universal Approximatorcited by 25
- 2024Mixture of Parrots: Experts improve memorization more than reasoningcited by 20
27 more
- 2024What Can Transformer Learn with Varying Depth? Case Studies on Sequence Learning Taskscited by 19
- 2024Superiority of Multi-Head Attention in In-Context Linear Regressioncited by 17
- 2024Do LLMs dream of elephants (when told not to)? Latent concept association and associative memory in transformerscited by 14
- 2024How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regressioncited by 13
- 2024Next-token prediction capacity: general upper bounds and a lower bound for transformerscited by 11
- 2024On the Optimal Memorization Capacity of Transformerscited by 10
- 2024Understanding Addition and Subtraction in Transformerscited by 6
- 2024Global Convergence in Training Large-Scale Transformerscited by 5
- 2025MeMo: Towards Language Models with Associative Memory Mechanismscited by 5
- 2025Transformers Can Overcome the Curse of Dimensionality: A Theoretical Study from an Approximation Perspectivecited by 5
- 2024On the Benefits of Rank in Attention Layerscited by 4
- 2025Memory Limitations of Prompt Tuning in Transformerscited by 4
- 2025The Effect of Attention Head Count on Transformer Approximationcited by 4
- 2023State space models can express n-gram languagescited by 3
- 2024Memorization in Attention-only Transformerscited by 2
- 2025Exact Sequence Interpolation with Transformerscited by 2
- 2025When Do Transformers Outperform Feedforward and Recurrent Networks? A Statistical Perspectivecited by 2
- 2026On the Expressive Power of Floating-Point Transformerscited by 2
- 2024Empirical Capacity Model for Self-Attention Neural Networkscited by 1
- 2025Systematic Evaluation of Optimization Techniques for Long-Context Language Modelscited by 1
- 2025Towards Theoretical Understanding of Transformer Test-Time Computing: Investigation on In-Context Linear Regressioncited by 1
- 2025Analyzing the Power of Chain of Thought through Memorization Capabilitiescited by 1
- 2026Geometric Factual Recall in Transformerscited by 1
- 2024Hierarchically Disentangled Recurrent Network for Factorizing System Dynamics of Multi-scale Systems: An application on Hydrological Systemscited by 0
- 2025Capacity Matters: a Proof-of-Concept for Transformer Memorization on Real-World Datacited by 0
- 2026Approximation Error Upper and Lower Bounds for H"older Class with Transformerscited by 0
- 2026On the Capability and Limitation of Hard Promptcited by 0
- 2026On the Capability and Limitation of Hard Prompt26 Sep 2026
- 2026Geometric Factual Recall in Transformers12 May 2026
- 2026Approximation Error Upper and Lower Bounds for H"older Class with Transformers8 May 2026
- 2026On the Expressive Power of Floating-Point Transformers23 Jan 2026
- 2025Analyzing the Power of Chain of Thought through Memorization Capabilities3 Nov 2025
- 2025The Effect of Attention Head Count on Transformer Approximation8 Oct 2025
- 2025Memory Limitations of Prompt Tuning in Transformers30 Aug 2025
- 2025Towards Theoretical Understanding of Transformer Test-Time Computing: Investigation on In-Context Linear Regression11 Aug 2025
- 2025Systematic Evaluation of Optimization Techniques for Long-Context Language Models1 Aug 2025
- 2025Capacity Matters: a Proof-of-Concept for Transformer Memorization on Real-World Data17 Jun 2025
- 2025How much do language models memorize?30 May 2025
- 2025Transformers Can Overcome the Curse of Dimensionality: A Theoretical Study from an Approximation Perspective18 Apr 2025
27 more
- 2025When Do Transformers Outperform Feedforward and Recurrent Networks? A Statistical Perspective14 Mar 2025
- 2025Taming Knowledge Conflicts in Language Models14 Mar 2025
- 2025MeMo: Towards Language Models with Associative Memory Mechanisms18 Feb 2025
- 2025Exact Sequence Interpolation with Transformers4 Feb 2025
- 2024Understanding Factual Recall in Transformers via Associative Memories9 Dec 2024
- 2024Memorization in Attention-only Transformers15 Nov 2024
- 2024Global Convergence in Training Large-Scale Transformers31 Oct 2024
- 2024Mixture of Parrots: Experts improve memorization more than reasoning24 Oct 2024
- 2024Undesirable Memorization in Large Language Models: A Survey3 Oct 2024
- 2024On the Optimal Memorization Capacity of Transformers26 Sep 2024
- 2024How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regression8 Aug 2024
- 2024Hierarchically Disentangled Recurrent Network for Factorizing System Dynamics of Multi-scale Systems: An application on Hydrological Systems29 Jul 2024
- 2024On the Benefits of Rank in Attention Layers23 Jul 2024
- 2024Empirical Capacity Model for Self-Attention Neural Networks22 Jul 2024
- 2024On Statistical Rates and Provably Efficient Criteria of Latent Diffusion Transformers (DiTs)1 Jul 2024
- 2024Do LLMs dream of elephants (when told not to)? Latent concept association and associative memory in transformers26 Jun 2024
- 2024How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpad10 Jun 2024
- 2024Next-token prediction capacity: general upper bounds and a lower bound for transformers22 May 2024
- 2024What Can Transformer Learn with Varying Depth? Case Studies on Sequence Learning Tasks2 Apr 2024
- 2024Prompting a Pretrained Transformer Can Be a Universal Approximator22 Feb 2024
- 2024Implicit Bias and Fast Convergence Rates for Self-attention8 Feb 2024
- 2024Understanding Addition and Subtraction in Transformers4 Feb 2024
- 2024Superiority of Multi-Head Attention in In-Context Linear Regression30 Jan 2024
- 2023On the Optimization and Generalization of Multi-head Attention19 Oct 2023
- 2023Are Transformers with One Layer Self-Attention Using Low-Rank Weight Matrices Universal Approximators?26 Jul 2023
- 2023Challenges and Applications of Large Language Models19 Jul 2023
- 2023State space models can express n-gram languages20 Jun 2023
- 2023Challenges and Applications of Large Language Modelscited by 251
- 2025How much do language models memorize?cited by 53
- 2023Are Transformers with One Layer Self-Attention Using Low-Rank Weight Matrices Universal Approximators?cited by 46
- 2024Understanding Factual Recall in Transformers via Associative Memoriescited by 45
- 2023On the Optimization and Generalization of Multi-head Attentioncited by 37
- 2024How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpadcited by 35
- 2024Implicit Bias and Fast Convergence Rates for Self-attentioncited by 31
- 2024Undesirable Memorization in Large Language Models: A Surveycited by 29
- 2025Taming Knowledge Conflicts in Language Modelscited by 27
- 2024Prompting a Pretrained Transformer Can Be a Universal Approximatorcited by 25
- 2024What Can Transformer Learn with Varying Depth? Case Studies on Sequence Learning Taskscited by 19
- 2024Superiority of Multi-Head Attention in In-Context Linear Regressioncited by 17
12 most cited of 36 All 36 (JSON)
- 2026On the Capability and Limitation of Hard Prompt26 Sep 2026
- 2026Geometric Factual Recall in Transformers12 May 2026
- 2026Approximation Error Upper and Lower Bounds for H"older Class with Transformers8 May 2026
- 2026On the Expressive Power of Floating-Point Transformers23 Jan 2026
- 2025The Effect of Attention Head Count on Transformer Approximation8 Oct 2025
- 2025Memory Limitations of Prompt Tuning in Transformers30 Aug 2025
- 2025Towards Theoretical Understanding of Transformer Test-Time Computing: Investigation on In-Context Linear Regression11 Aug 2025
- 2025Systematic Evaluation of Optimization Techniques for Long-Context Language Models1 Aug 2025
- 2025Capacity Matters: a Proof-of-Concept for Transformer Memorization on Real-World Data17 Jun 2025
- 2025How much do language models memorize?30 May 2025
- 2025Transformers Can Overcome the Curse of Dimensionality: A Theoretical Study from an Approximation Perspective18 Apr 2025
- 2025When Do Transformers Outperform Feedforward and Recurrent Networks? A Statistical Perspective14 Mar 2025
12 newest of 36 All 36 (JSON)