askNib

A series by Nib · for a curious adult who uses chatbots but has never studied computing

Why can’t AI count the r’s in “strawberry”?

6 explainers, each one drawn by Nib. Read it here, or play it and he draws and says every page. Updated .

▶ Play from the startQuick reviewCheat sheet

the short answer

A chatbot never receives the letters of your question. Before any thinking happens, your text is chopped into pieces called tokens and each piece is replaced by a number, so “strawberry” reaches the model as a few numbers with no letters inside them. Counting the r’s means recalling spellings the model has only learned indirectly, and that recall is shaky. Making it spell the word out first turns the job into counting letters it can actually see.

Part 1 of 6

What does an AI actually receive when you type a word?

▶ Play this partIts own page

Ask a chatbot how many r’s are in “strawberry” and, in a widely shared example from 2024, it answers two. A person finds that baffling: the word is ten letters long, you can see them all, and counting three r’s takes a second. To understand the mistake we have to start with what the chatbot is actually given when you type.

It is not given letters. A language model is, underneath, a very large pile of arithmetic, and arithmetic works on numbers. So before the model does anything with your message, a separate step converts the text into a list of numbers. Each number is an identification code for a piece of text, taken from a fixed catalog called the vocabulary. Your message becomes the codes for its pieces, in order, and that list is all the model receives.

The crucial detail is what a code is. A code is only a label, like a phone extension. The extension tells you nothing about how the person’s name is spelled, and the code for a piece of text does not spell out the letters inside it. Nothing in the number lets the model look inside and count.

So when you ask about the r’s, you are asking about something the model was never handed. It is a little like asking someone who has only seen a word in a language they cannot read to tell you how many times a certain shape appears in it. The rest of this path is about where those pieces come from and what the model can and cannot do about it.

The model never receives your letters, only numbers that stand for pieces of text.

Part 2 of 6

Where do tokens come from?

▶ Play this partIts own page

The pieces of text are called tokens, and a fixed procedure decides them before the model is trained, not the model itself. Several procedures exist. One of the most widely used is called byte pair encoding. It started life in 1994 as a way of compressing data, and around 2015 to 2016 researchers adapted it for neural machine translation; language models have used variants of it ever since.

The recipe is simple. Start with single characters. Scan a huge amount of text and find the pair of neighbors that appears together most often. Glue that pair into one new piece. Then scan again, glue the next most common pair, and repeat thousands of times. Early on it might glue an “e” and an “r” into “er”; later it glues small pieces into bigger ones, until whole common words are single pieces.

Notice what is missing: any idea of spelling rules or meaning. The pieces are chosen purely by how often characters sit together in the training text. The finished vocabulary is a numbered list of tens of thousands of pieces. Common words end up as a single token, while rarer or longer words are broken into several smaller ones. As a rough guide, OpenAI says one token is about four characters, or three quarters of a word, in everyday English.

From then on, typing a word is just a lookup: swap each piece for its number. The characters inside a piece do not travel with it. Only the number does.

Tokens are chunks chosen by how often characters appear together in old text, not by spelling or meaning.

Part 3 of 6

Why is “strawberry” split into pieces the model can’t see inside?

▶ Play this partIts own page

So how does this process treat “strawberry”? It depends on the tokenizer, and on the word’s surroundings. We can check two published OpenAI vocabularies directly. In the one used by GPT-4 and GPT-3.5, the word at the start of a text comes out as three pieces, “str”, “aw” and “berry”. In the one used by GPT-4o it comes out as “st”, “raw” and “berry”. With a space in front of it, as it usually would be in a sentence, both vocabularies treat the whole word as a single piece. Nib’s board uses the simplest picture, two chunks, straw and berry, because the exact cuts do not change the point.

The point is that every piece is one item to the model. Each becomes one number, and the three r’s sit inside those pieces where the model cannot see them. Asking the model to count them is like asking you to count the marbles in two closed boxes without ever opening them.

That changes how the mistake should be read. The model was not being careless, and it was not unable to count: the letters were never handed over. Whatever answer it gives has to come from somewhere other than looking at the word.

The miscount is not sloppiness: the r’s sit inside chunks the model receives as single numbers.

Part 4 of 6

How does a model learn spelling at all?

▶ Play this partIts own page

If the model never sees inside a token, why can it spell at all? Ask a chatbot to spell a common word and it usually can. The answer is that it picks up spelling from the text it was trained on, indirectly.

Some training text spells words out, such as “berry is b-e-r-r-y”, and there the letters appear as separate tokens next to the chunk, so the model can link the two. Other clues help too: typos split a word into unusual pieces, rhymes share endings, and capital letters leave traces. Researchers who have probed this found that models do learn a good deal about which characters their tokens contain, but imperfectly.

Those clues are real, but they are nothing like a reliable spelling table. A word that is rarely spelled out gives the model few examples to learn from, so what it knows about it is thin.

Now see what counting needs. The model has to recall the letters of each chunk and add up the r’s. If “straw” gives one and its memory of “berry” is fuzzy and says one rather than two, the total comes out as two instead of three. The weak link is not the adding, which is trivial, but the recall of what is inside each chunk.

Spelling is learned indirectly and faintly, so recalling the letters inside a chunk is the weak step.

Part 5 of 6

Why does letting it write the letters out fix the count?

▶ Play this partIts own page

Here is the practical fix. If you ask for the count straight away, the model has to recall letter facts about hidden chunks, and that recall is weak. But ask it to spell the word out first, s, t, r, a, w, b, e, r, r, y, and something changes.

When the model writes the word letter by letter, each letter becomes its own token, sitting separately on the page. The model reads its own output as it goes, so the letters are now in front of it as separate items rather than hidden inside chunks. Counting stops being a memory task and becomes a simple check of what is on the page.

Add a running tally, r one, r two, r three, and each step is tiny. Writing out intermediate steps is a well-known way to improve the accuracy of language models on multi-step problems, and this is a clean example of why it works: each step only has to handle a small piece in plain view.

This is also a likely reason many newer chatbots do better on this question: many now work through a problem step by step before they answer, which for a question like this can amount to spelling the word out, though it is not guaranteed. You are not tricking the model by asking it to do so; you are giving it letters it can actually see.

Spelling the word out gives the model separate visible letters, so counting becomes a check of the page, not a memory test.

Part 6 of 6

What else do tokens explain?

▶ Play this partIts own page

Once you picture the chunks, the strawberry puzzle stops being a one-off. The same blind spot shows up wherever a task depends on what is inside a piece.

Reversing a word is the same wall: the model received chunks rather than letters, so it has to reconstruct the backward order from memory. Rhyming and wordplay depend on how words sound and end, and a token is only a number, so those too are learned indirectly from text rather than seen.

Numbers are chopped as well. In the OpenAI vocabularies mentioned above, the number 1234567 comes out as the pieces 123, 456 and 7. Long numbers are cut in uneven places, the digits do not line up in columns, and that makes long arithmetic harder than it looks. Writing a long sum out step by step helps for the same reason as spelling a word out: each step uses short pieces in plain view.

Tokens also decide what you pay and how much you can fit in. Services that sell access to language models, such as OpenAI and Anthropic, charge by the token rather than by the word, so a long or unusual word costs more than a short common one. And text in some languages needs several times as many tokens as the same text in English, because the vocabulary was built mostly from English text.

A model works in chunks, not letters or digits, and that one fact explains letter counting, wordplay, long sums and pricing.

A chatbot never reads letters. It reads numbered chunks chosen by frequency, and it knows what is inside a chunk only faintly, from patterns in text. That is why it can miscount the r’s in “strawberry”, why spelling the word out first fixes it, and why the same hidden pieces explain reversing, rhyming, long sums and the price tag.

Quick review

The whole series in a few minutes: each part's last board, its one idea, and the lines worth keeping.

Part 1

What does an AI actually receive when you type a word?

Not letters: a list of numbers that stand for pieces of text.

  • What you see on screen is not what the model receives.
  • The model only works with numbers, so your text is converted first.
  • The model gets ID numbers from a catalog of text pieces, not the text itself.
  • A number is a label, not a container of letters.
  • A letter-counting question asks about something the model was never directly given.

Part 2

Where do tokens come from?

A fixed procedure chops text into common chunks before the model is ever trained.

  • Tokens are fixed pieces of text, chosen before the model ever trains.
  • Repeatedly gluing the most frequent neighboring pair builds the chunk vocabulary.
  • Each merge turns a frequent pair into one piece, and merges stack into bigger chunks.
  • Common words become one token; rare words split into several.
  • Each chunk becomes one number; the characters inside it are not passed along.

Part 3

Why is “strawberry” split into pieces the model can’t see inside?

Each chunk reaches the model as one item, with the r’s locked inside.

  • A word is turned into a few chunks before the model sees anything.
  • Each chunk becomes one number, with no letters attached.
  • The r's are inside the chunks, and the model only gets the sealed boxes.
  • The failure comes from what the model is given, not from carelessness.

Part 4

How does a model learn spelling at all?

Indirectly, from patterns in text, so the knowledge is faint and easy to get wrong.

  • A token's number says nothing about its letters.
  • Most letter knowledge comes from text that spells words out.
  • Other clues exist, but they are hints, not a lookup table.
  • Weak letter facts, combined from chunks, can add up wrong.

Part 5

Why does letting it write the letters out fix the count?

Written out, every letter is its own visible token, so counting becomes looking.

  • Counting straight from the chunks is a memory lookup, and memory is shaky here.
  • Writing it out turns hidden letters into separate, visible tokens.
  • What it writes becomes input it can read, so counting becomes checking, not recalling.
  • A running tally makes each step small, so the final count is read off, not guessed.

Part 6

What else do tokens explain?

Reversing words, rhyming, long sums and the price tag all come from the same hidden pieces.

  • Reversing a word needs the letters, and the letters are hidden inside chunks.
  • Rhyme is about word endings, which chunk-numbers don't directly expose.
  • Uneven chunking of digits makes column-style arithmetic hard.
  • Usage is priced in tokens because tokens are what the model actually processes.

Cheat sheet

One sheet: every part's key drawing and its key line.

  1. 1. What does an AI actually receive when you type a word? Not letters: a list of numbers that stand for pieces of text.

  2. 2. Where do tokens come from? A fixed procedure chops text into common chunks before the model is ever trained.

  3. 3. Why is “strawberry” split into pieces the model can’t see inside? Each chunk reaches the model as one item, with the r’s locked inside.

  4. 4. How does a model learn spelling at all? Indirectly, from patterns in text, so the knowledge is faint and easy to get wrong.

  5. 5. Why does letting it write the letters out fix the count? Written out, every letter is its own visible token, so counting becomes looking.

  6. 6. What else do tokens explain? Reversing words, rhyming, long sums and the price tag all come from the same hidden pieces.