When Can Transformers Count to n?

Gilad Yehudai, Haim Kaplan, Asma Ghandeharioun, Mor Geva, Amir Globerson
7/21/2024
cs.CLcs.AIcs.LG

No confident code implementation found for this paper.

Abstract

Large language models based on the transformer architectures can solve highly complex tasks. But are there simple tasks that such models cannot solve? Here we focus on very simple counting tasks, that involve counting how many times a token in the vocabulary have appeared in a string. We show that if the dimension of the transformer state is linear in the context length, this task can be solved. However, the solution we propose does not scale beyond this limit, and we provide theoretical arguments for why it is likely impossible for a size limited transformer to implement this task. Our empirical results demonstrate the same phase-transition in performance, as anticipated by the theoretical argument. Our results demonstrate the importance of understanding how transformers can solve simple tasks.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{yehudai2024when,
  title  = {When Can Transformers Count to n?},
  author = {Gilad Yehudai and Haim Kaplan and Asma Ghandeharioun and Mor Geva and Amir Globerson},
  year   = {2024},
  eprint = {2407.15160},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2407.15160v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2407.15160.svg)](https://codeofpaper.com/paper/2407.15160)

Discussion