When Can Transformers Count to n?
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
- 2017Attention Is All You Needcited by 60,361
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,305
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2023Toolformer: Language Models Can Teach Themselves to Use Toolscited by 4,182
- 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,998
- 2022In-context Learning and Induction Headscited by 964
- 2023Towards Revealing the Mystery behind Chain of Thought: A Theoretical Perspectivecited by 294
- 2016Benefits of depth in neural networkscited by 250
- 2022Exploring Length Generalization in Large Language Modelscited by 206
- 2022The Parallelism Tradeoff: Limitations of Log-Precision Transformerscited by 193
- 2024Same Task, More Tokens: the Impact of Input Length on the Reasoning Performance of Large Language Modelscited by 152
- 2023Representational Strengths and Limitations of Transformerscited by 133
10 more
- 2022Overcoming a Theoretical Limitation of Self-Attentioncited by 113
- 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 102
- 2024Transformers need glasses! Information over-squashing in language taskscited by 91
- 2022Efficient Long-Text Understanding with Short-Text Modelscited by 71
- 2024On Limitations of the Transformer Architecturecited by 63
- 2024Language Models Need Inductive Biases to Count Inductivelycited by 25
- 2023How Many Neurons Does it Take to Approximate the Maximum?cited by 12
- 2024Contextual Counting: A Mechanistic Study of Transformers on a Quantitative Taskcited by 7
- 2024Counting in Small Transformers: The Delicate Interplay between Attention and Feed-Forward Layerscited by 6
- 2013All-Distances Sketches, Revisited: HIP Estimators for Massive Graphs Analysiscited by 1
Built on by
Citing papers per year: 2024: 5; 2025: 9; 2026: 10.
24 papers.
Sort:
By area:
- 2024Language Models Encode Numbers Using Digit Representations in Base 10cited by 32
- 2025Frontier LLMs Still Struggle with Simple Reasoning Taskscited by 21
- 2026Large Language Model Reasoning Failurescited by 21
- 2025Position: The Future of Bayesian Prediction Is Prior-Fittedcited by 20
- 2025Depth-Width tradeoffs in Algorithmic Reasoning of Graph Tasks with Transformerscited by 11
- 2024More Expressive Attention with Negative Weightscited by 9
- 2026Training Transformers for KV Cache Compressibilitycited by 7
- 2024Composing Global Solutions to Reasoning Tasks via Algebraic Objects in Neural Netscited by 6
- 2025Compositional Reasoning with Transformers, RNNs, and Chain of Thoughtcited by 6
- 2024Are You Human? An Adversarial Benchmark to Expose LLMscited by 5
- 2025Sequential Enumeration in Large Language Modelscited by 3
- 2024StringLLM: Understanding the String Processing Capability of Large Language Modelscited by 2
12 more
- 2025A Minimum Description Length Approach to Regularization in Neural Networkscited by 2
- 2025Tracr-Injection: Distilling Algorithms into Pre-trained Language Modelscited by 1
- 2025Vector Symbolic Algebras for the Abstraction and Reasoning Corpuscited by 1
- 2025Abacus: Self-Supervised Event Counting-Aligned Distributional Pretraining for Sequential User Modelingcited by 1
- 2026Every Bit Counts: A Theoretical Study of Precision-Expressivity Tradeoffs in Quantized Transformerscited by 1
- 2026ECG-LLM: Foundation Model for ECG-Based Cardiac Reasoningcited by 1
- 2026Semantic Content Determines Algorithmic Performancecited by 0
- 2026Artificial Effortcited by 0
- 2026Shape Over Intensity: Directional Topological Encoding for False Positive Reduction in Intracranial Aneurysm Detectioncited by 0
- 2026List Counting Failures Are Not One Phenomenoncited by 0
- 2026Counting on Thinking: Tracing Evidence Integration in Language Modelscited by 0
- 2026Counting with Attention and LayerNorm: Norm Scaling and Representation Geometrycited by 0
- 2026Counting with Attention and LayerNorm: Norm Scaling and Representation Geometry12 Oct 2026
- 2026Counting on Thinking: Tracing Evidence Integration in Language Models26 Sep 2026
- 2026List Counting Failures Are Not One Phenomenon3 Sep 2026
- 2026ECG-LLM: Foundation Model for ECG-Based Cardiac Reasoning15 Jul 2026
- 2026Shape Over Intensity: Directional Topological Encoding for False Positive Reduction in Intracranial Aneurysm Detection6 Jul 2026
- 2026Training Transformers for KV Cache Compressibility7 May 2026
- 2026Artificial Effort17 Apr 2026
- 2026Large Language Model Reasoning Failures5 Feb 2026
- 2026Every Bit Counts: A Theoretical Study of Precision-Expressivity Tradeoffs in Quantized Transformers2 Feb 2026
- 2026Semantic Content Determines Algorithmic Performance29 Jan 2026
- 2025Abacus: Self-Supervised Event Counting-Aligned Distributional Pretraining for Sequential User Modeling18 Dec 2025
- 2025Sequential Enumeration in Large Language Models4 Dec 2025
12 more
- 2025Vector Symbolic Algebras for the Abstraction and Reasoning Corpus11 Nov 2025
- 2025Frontier LLMs Still Struggle with Simple Reasoning Tasks9 Jul 2025
- 2025Position: The Future of Bayesian Prediction Is Prior-Fitted29 May 2025
- 2025A Minimum Description Length Approach to Regularization in Neural Networks19 May 2025
- 2025Tracr-Injection: Distilling Algorithms into Pre-trained Language Models15 May 2025
- 2025Depth-Width tradeoffs in Algorithmic Reasoning of Graph Tasks with Transformers3 Mar 2025
- 2025Compositional Reasoning with Transformers, RNNs, and Chain of Thought3 Mar 2025
- 2024More Expressive Attention with Negative Weights11 Nov 2024
- 2024Language Models Encode Numbers Using Digit Representations in Base 1015 Oct 2024
- 2024Are You Human? An Adversarial Benchmark to Expose LLMs12 Oct 2024
- 2024Composing Global Solutions to Reasoning Tasks via Algebraic Objects in Neural Nets2 Oct 2024
- 2024StringLLM: Understanding the String Processing Capability of Large Language Models2 Oct 2024
- 2026Training Transformers for KV Cache Compressibilitycited by 7
- 2026Training Transformers for KV Cache Compressibility7 May 2026
- 2024Language Models Encode Numbers Using Digit Representations in Base 10cited by 32
- 2025Position: The Future of Bayesian Prediction Is Prior-Fittedcited by 20
- 2025Depth-Width tradeoffs in Algorithmic Reasoning of Graph Tasks with Transformerscited by 11
- 2024More Expressive Attention with Negative Weightscited by 9
- 2024Composing Global Solutions to Reasoning Tasks via Algebraic Objects in Neural Netscited by 6
- 2024Are You Human? An Adversarial Benchmark to Expose LLMscited by 5
- 2025Sequential Enumeration in Large Language Modelscited by 3
- 2024StringLLM: Understanding the String Processing Capability of Large Language Modelscited by 2
- 2025A Minimum Description Length Approach to Regularization in Neural Networkscited by 2
- 2025Tracr-Injection: Distilling Algorithms into Pre-trained Language Modelscited by 1
- 2025Vector Symbolic Algebras for the Abstraction and Reasoning Corpuscited by 1
- 2025Abacus: Self-Supervised Event Counting-Aligned Distributional Pretraining for Sequential User Modelingcited by 1
12 most cited of 19 All 19 (JSON)
- 2026Counting with Attention and LayerNorm: Norm Scaling and Representation Geometry12 Oct 2026
- 2026List Counting Failures Are Not One Phenomenon3 Sep 2026
- 2026ECG-LLM: Foundation Model for ECG-Based Cardiac Reasoning15 Jul 2026
- 2026Shape Over Intensity: Directional Topological Encoding for False Positive Reduction in Intracranial Aneurysm Detection6 Jul 2026
- 2026Artificial Effort17 Apr 2026
- 2026Every Bit Counts: A Theoretical Study of Precision-Expressivity Tradeoffs in Quantized Transformers2 Feb 2026
- 2026Semantic Content Determines Algorithmic Performance29 Jan 2026
- 2025Abacus: Self-Supervised Event Counting-Aligned Distributional Pretraining for Sequential User Modeling18 Dec 2025
- 2025Sequential Enumeration in Large Language Models4 Dec 2025
- 2025Vector Symbolic Algebras for the Abstraction and Reasoning Corpus11 Nov 2025
- 2025Position: The Future of Bayesian Prediction Is Prior-Fitted29 May 2025
- 2025A Minimum Description Length Approach to Regularization in Neural Networks19 May 2025
12 newest of 19 All 19 (JSON)