[2407.15160] When Can Transformers Count to n?

[2407.15160] When Can Transformers Count to n?

arXiv - Machine Learning 4 min read Article

Summary

This paper investigates the limitations of transformer models in performing basic counting tasks, revealing a critical relationship between embedding dimension, vocabulary size, and task difficulty.

Why It Matters

Understanding the limitations of transformers in simple algorithmic tasks is crucial for improving their design and application in AI. This research highlights a significant phase transition that affects model performance, which could inform future developments in machine learning and natural language processing.

Key Takeaways

  • Transformers can accurately count tokens when embedding dimension matches or exceeds vocabulary size.
  • A phase transition occurs when vocabulary size exceeds embedding dimension, leading to performance drops.
  • Empirical validation shows pretrained models also struggle with counting tasks under these conditions.
  • The study reveals a critical blind spot in transformer capabilities regarding counting tasks.
  • Understanding these limitations can guide future improvements in transformer architecture.

Computer Science > Computation and Language arXiv:2407.15160 (cs) [Submitted on 21 Jul 2024 (v1), last revised 25 Feb 2026 (this version, v3)] Title:When Can Transformers Count to n? Authors:Gilad Yehudai, Haim Kaplan, Guy Dar, Royi Rassin, Asma Ghandeharioun, Mor Geva, Amir Globerson View a PDF of the paper titled When Can Transformers Count to n?, by Gilad Yehudai and 6 other authors View PDF HTML (experimental) Abstract: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 fai...

Related Articles

Llms

[R] Is autoresearch really better than classic hyperparameter tuning?

We did experiments comparing Optuna & autoresearch. Autoresearch converges faster, is more cost-efficient, and even generalizes bette...

Reddit - Machine Learning · 1 min ·
Llms

Claude Source Code?

Has anyone been able to successfully download the leaked source code yet? I've not been able to find it. If anyone has, please reach out....

Reddit - Artificial Intelligence · 1 min ·
Llms

[R] Solving the Jane Street Dormant LLM Challenge: A Systematic Approach to Backdoor Discovery

Submitted by: Adam Kruger Date: March 23, 2026 Models Solved: 3/3 (M1, M2, M3) + Warmup Background When we first encountered the Jane Str...

Reddit - Machine Learning · 1 min ·
Llms

[P] Gemma 4 running on NVIDIA B200 and AMD MI355X from the same inference stack, 15% throughput gain over vLLM on Blackwell

Google DeepMind dropped Gemma 4 today: Gemma 4 31B: dense, 256K context, redesigned architecture targeting efficiency and long-context qu...

Reddit - Machine Learning · 1 min ·
More in Llms: This Week Guide Trending

No comments

No comments yet. Be the first to comment!

Stay updated with AI News

Get the latest news, tools, and insights delivered to your inbox.

Daily or weekly digest • Unsubscribe anytime