mlsanityData to 14 Oct 2026

When Can Transformers Count to n?

arXiv 2407.15160 ↗First posted 21 Jul 2024cs.CL cs.AI cs.LGcited by 24

Not on the map. Why?

Abstract (arXiv)

Large language models based on the transformer architecture can solve highly complex tasks, yet their fundamental limitations on simple algorithmic problems remain poorly understood. In this work, we focus on basic counting tasks and investigate how the difficulty of these tasks scales with the transformer embedding dimension, the context length, and the vocabulary size. We reveal a sharp theoretical phase transition governed by the relationship between the embedding dimension and the vocabulary size. When the dimension is at least as large as the vocabulary, transformers can perfectly maintain token counts. However, when the vocabulary exceeds the embedding dimension, the interference between non-orthogonal token representations forces the network weights to scale polynomially. This renders the exact counting algorithm numerically unstable and practically unlearnable. We empirically validate this bottleneck by training transformers from scratch, demonstrating a strict performance drop at the theoretical threshold and catastrophic out of distribution failure when scaling the vocabulary or context length. Furthermore, we show that state-of-the-art pretrained models suffer from similar failure cases. Our work reveals a critical blind spot absent from the current literature regarding the connection among these three parameters, proving that vocabulary size fundamentally dictates the difficulty of counting tasks.

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

Builds on

22 of 35 references.

References · 22

  1. 2017Attention Is All You Needcited by 60,361
  2. 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,305
  3. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
  4. 2023Toolformer: Language Models Can Teach Themselves to Use Toolscited by 4,182
  5. 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,998
  6. 2022In-context Learning and Induction Headscited by 964
  7. 2023Towards Revealing the Mystery behind Chain of Thought: A Theoretical Perspectivecited by 294
  8. 2016Benefits of depth in neural networkscited by 250
  9. 2022Exploring Length Generalization in Large Language Modelscited by 206
  10. 2022The Parallelism Tradeoff: Limitations of Log-Precision Transformerscited by 193
  11. 2024Same Task, More Tokens: the Impact of Input Length on the Reasoning Performance of Large Language Modelscited by 152
  12. 2023Representational Strengths and Limitations of Transformerscited by 133
10 more
  1. 2022Overcoming a Theoretical Limitation of Self-Attentioncited by 113
  2. 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 102
  3. 2024Transformers need glasses! Information over-squashing in language taskscited by 91
  4. 2022Efficient Long-Text Understanding with Short-Text Modelscited by 71
  5. 2024On Limitations of the Transformer Architecturecited by 63
  6. 2024Language Models Need Inductive Biases to Count Inductivelycited by 25
  7. 2023How Many Neurons Does it Take to Approximate the Maximum?cited by 12
  8. 2024Contextual Counting: A Mechanistic Study of Transformers on a Quantitative Taskcited by 7
  9. 2024Counting in Small Transformers: The Delicate Interplay between Attention and Feed-Forward Layerscited by 6
  10. 2013All-Distances Sketches, Revisited: HIP Estimators for Massive Graphs Analysiscited by 1

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 5; 2025: 9; 2026: 10.

24 papers.

Sort:

By area:

  1. 2024Language Models Encode Numbers Using Digit Representations in Base 10cited by 32
  2. 2025Frontier LLMs Still Struggle with Simple Reasoning Taskscited by 21
  3. 2026Large Language Model Reasoning Failurescited by 21
  4. 2025Position: The Future of Bayesian Prediction Is Prior-Fittedcited by 20
  5. 2025Depth-Width tradeoffs in Algorithmic Reasoning of Graph Tasks with Transformerscited by 11
  6. 2024More Expressive Attention with Negative Weightscited by 9
  7. 2026Training Transformers for KV Cache Compressibilitycited by 7
  8. 2024Composing Global Solutions to Reasoning Tasks via Algebraic Objects in Neural Netscited by 6
  9. 2025Compositional Reasoning with Transformers, RNNs, and Chain of Thoughtcited by 6
  10. 2024Are You Human? An Adversarial Benchmark to Expose LLMscited by 5
  11. 2025Sequential Enumeration in Large Language Modelscited by 3
  12. 2024StringLLM: Understanding the String Processing Capability of Large Language Modelscited by 2
12 more
  1. 2025A Minimum Description Length Approach to Regularization in Neural Networkscited by 2
  2. 2025Tracr-Injection: Distilling Algorithms into Pre-trained Language Modelscited by 1
  3. 2025Vector Symbolic Algebras for the Abstraction and Reasoning Corpuscited by 1
  4. 2025Abacus: Self-Supervised Event Counting-Aligned Distributional Pretraining for Sequential User Modelingcited by 1
  5. 2026Every Bit Counts: A Theoretical Study of Precision-Expressivity Tradeoffs in Quantized Transformerscited by 1
  6. 2026ECG-LLM: Foundation Model for ECG-Based Cardiac Reasoningcited by 1
  7. 2026Semantic Content Determines Algorithmic Performancecited by 0
  8. 2026Artificial Effortcited by 0
  9. 2026Shape Over Intensity: Directional Topological Encoding for False Positive Reduction in Intracranial Aneurysm Detectioncited by 0
  10. 2026List Counting Failures Are Not One Phenomenoncited by 0
  11. 2026Counting on Thinking: Tracing Evidence Integration in Language Modelscited by 0
  12. 2026Counting with Attention and LayerNorm: Norm Scaling and Representation Geometrycited by 0