Why AI Struggles to Count Letters: Subword Tokenization

Artificial intelligence language models can write complex essays and code, yet they frequently fail at simple tasks like counting the number of "r"s in the word "strawberry." This article explores the root cause of this limitation: subword tokenization. By examining how AI processes text as chunks of characters rather than individual letters, we will uncover why character-level tasks remain a major hurdle for modern large language models (LLMs) and how they actually "read" human language.

What is Subword Tokenization?

Humans read text by recognizing individual letters that form words. Large language models, however, do not see letters or words. Instead, they read "tokens." Before a prompt ever reaches the AI's neural network, a system called a tokenizer breaks the text down into smaller pieces.

Most modern LLMs use a method called subword tokenization, often relying on algorithms like Byte-Pair Encoding (BPE). This approach splits text into frequently occurring chunks of characters. A common word like "apple" might remain a single token, while a more complex word like "tokenization" might be split into two tokens: "token" and "ization".

The Numerical Blindfold

Once the text is split into subword tokens, each token is converted into a unique number (a token ID). The AI model only sees these numbers.

For example, the word "strawberry" might be broken down into the tokens "straw" and "berry". The tokenizer then converts "straw" into the number 1456, and "berry" into the number 8921.

When the AI processes your prompt, it does not see the letters s-t-r-a-w-b-e-r-r-y. It only sees [1456, 8921]. Because the individual characters are locked inside these numerical IDs, the model is essentially blind to the spelling of the word.

Why Character-Level Tasks Fail

Because the AI processes concepts through numerical token IDs, it relies on statistical associations to understand what those numbers mean, not how they are spelled. It knows that [1456, 8921] represents a red, sweet fruit with seeds on the outside, because it has seen those numbers used in that context millions of times during training.

However, when you ask the AI to count the letter "r" in "strawberry", it cannot simply look at the word and count the letters as a human would. Instead, it has to rely on memorized training data regarding how the tokens "straw" and "berry" are spelled. If the model hasn't explicitly memorized the exact letter counts of those specific tokens during its training, it is forced to guess, leading to confident but incorrect answers.

This same limitation explains why AI struggles with other character-level tasks, including:

  • Reversing words: The AI cannot easily reverse a sequence of letters it cannot see.
  • Acrostics and crosswords: Matching specific letter positions requires character awareness that token IDs obscure.
  • Rhyming: While models memorize many rhymes, they cannot phonetically sound out individual letters within a token to invent new ones reliably.

Why Not Use Character-Level Tokenization?

If subword tokenization causes these blind spots, the obvious solution is to feed the AI individual characters instead. While character-level tokenization does exist, it creates massive efficiency problems.

Processing text letter by letter drastically increases the length of the data sequence. A 500-word essay might equal about 650 subword tokens, but it contains roughly 3,000 individual characters. If an AI had to process 3,000 individual data points instead of 650, it would require vastly more computing power, memory, and time to generate a response. Furthermore, subword tokens help the AI capture the meaning of root words and prefixes much faster than trying to deduce meaning from a long string of individual letters.

Overcoming the Limitation

Currently, the most effective way for an AI to solve character-level problems is by working around its own architecture. Users and developers can bypass tokenization blindness by forcing the AI to space out the letters (e.g., "s-t-r-a-w-b-e-r-r-y"). By separating the letters with spaces or hyphens, the tokenizer is forced to assign a unique token ID to each individual letter. Once every letter is its own token, the AI can accurately see and count them. Alternatively, modern AI systems often write and execute a quick Python script in the background to count the letters programmatically, relying on traditional code to do what their neural networks cannot.