Why Do Large Language Models (LLMs) Struggle to Count Letters?

Tairan Fu, Raquel Ferrando, Javier Conde, Carlos Arriaga, Pedro Reviriego
12/19/2024
cs.CL

No confident code implementation found for this paper.

Abstract

Large Language Models (LLMs) have achieved unprecedented performance on many complex tasks, being able, for example, to answer questions on almost any topic. However, they struggle with other simple tasks, such as counting the occurrences of letters in a word, as illustrated by the inability of many LLMs to count the number of "r" letters in "strawberry". Several works have studied this problem and linked it to the tokenization used by LLMs, to the intrinsic limitations of the attention mechanism, or to the lack of character-level training data. In this paper, we conduct an experimental study to evaluate the relations between the LLM errors when counting letters with 1) the frequency of the word and its components in the training dataset and 2) the complexity of the counting operation. We present a comprehensive analysis of the errors of LLMs when counting letter occurrences by evaluating a representative group of models over a large number of words. The results show a number of consistent trends in the models evaluated: 1) models are capable of recognizing the letters but not counting them; 2) the frequency of the word and tokens in the word does not have a significant impact on the LLM errors; 3) there is a positive correlation of letter frequency with errors, more frequent letters tend to have more counting errors, 4) the errors show a strong correlation with the number of letters or tokens in a word and 5) the strongest correlation occurs with the number of letters with counts larger than one, with most models being unable to correctly count words in which letters appear more than twice.

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{fu2024large,
  title  = {Why Do Large Language Models (LLMs) Struggle to Count Letters?},
  author = {Tairan Fu and Raquel Ferrando and Javier Conde and Carlos Arriaga and Pedro Reviriego},
  year   = {2024},
  eprint = {2412.18626},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2412.18626v1}
}

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/2412.18626.svg)](https://codeofpaper.com/paper/2412.18626)

Discussion