On the Optimal Memorization Capacity of Transformers
Tokio Kajitsuka, Issei Sato
Abstract
Recent research in the field of machine learning has increasingly focused on the memorization capacity of Transformers, but how efficient they are is not yet well understood. We demonstrate that Transformers can memorize labels with Õ( √ N ) parameters in a next-token prediction setting for N input sequences of length n, which is proved to be optimal up to logarithmic factors. This indicates that Transformers can efficiently perform memorization with little influence from the input length n owing to the benefit of parameter sharing. We also analyze the memorization capacity in the sequence-to-sequence setting, and find that Õ( √ nN ) parameters are not only sufficient, but also necessary at least for Transformers with hardmax. These results suggest that while self-attention mechanisms can efficiently identify input sequences, the feed-forward network becomes a bottleneck when associating a label to each token.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext c4829fac-10ea-4f54-8ea1-9ae754b70566Cited by top-tier papers5
- Unveiling the Basin-Like Loss Landscape in Large Language ModelsHuanran Chen, Zeming Wei, Yao Huang, Yichi Zhang et al.ICLR 2026 · 14 citations
- Approximation Bounds for Transformer Networks with Application to RegressionYuling Jiao, Yanming Lai, Defeng Sun, Yang Wang et al.ICML 2026 · 6 citations
- Analyzing the Power of Chain of Thought through Memorization CapabilitiesLijia Yu, Xiao-Shan Gao, Lijun ZhangNeurIPS 2025 · 2 citations
- A Capacity-Based Rationale for Multi-Head AttentionMicah AdlerICML 2026 · 2 citations
- Approximation Error Upper and Lower Bounds for Hölder Class with TransformersXin He, Yuling Jiao, Xiliang Lu, Jerry YangICML 2026
Builds on18
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
- Scalable Diffusion Models with TransformersWilliam Peebles, Saining XieICCV 2023 · 5,568 citations
- Big Bird: Transformers for Longer SequencesManzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie et al.NeurIPS 2020 · 3,159 citations
- MetaFormer is Actually What You Need for VisionWeihao Yu, Mi Luo, Pan Zhou, Chenyang Si et al.CVPR 2022 · 1,114 citations
- Deep Double Descent: Where Bigger Models and More Data HurtPreetum Nakkiran, Gal Kaplun, Yamini Bansal, Tristan Yang et al.ICLR 2020 · 1,108 citations
Related papers
- Provable Memorization Capacity of TransformersJunghwan Kim, Michelle Kim, Barzan MozafariICLR 2023
- Memorization Capacity of Multi-Head Attention in TransformersSadegh Mahdavi, Renjie Liao, Christos ThrampoulidisICLR 2024 · 34 citations
- Understanding the Expressive Power and Mechanisms of Transformer for Sequence ModelingMingze Wang, Weinan ENeurIPS 2024 · 32 citations
- Are Transformers with One Layer Self-Attention Using Low-Rank Weight Matrices Universal Approximators?Tokio Kajitsuka, Issei SatoICLR 2024 · 31 citations
- The Effect of Attention Head Count on Transformer ApproximationPenghao Yu, Haotian Jiang, Zeyu Bao, Ruoxi Yu et al.ICLR 2026 · 5 citations
