How many letters does a language model see?

Ask a chat model how many times the letter r appears in the word strawberry and, for a long time, many of them said two. The answer is three. The model was not careless. It never saw the letters. Before a language model reads anything, a tokenizer cuts the text into pieces, and the model only ever receives the numbers of those pieces. A common English word becomes a single piece. A rare word becomes two or three. The letters inside a piece are not visible to the model at all; it has to have learned, from many examples, which letters each piece contains.

This is a reasonable trade. Pieces are shorter than letters, so a sentence becomes a short sequence and the model can read more of it at once. The cost of attention grows with the square of the sequence length, so a sequence half as long is about four times cheaper to attend over. Tokenizers were built to make language models fast, and they do.

The trade has a price that shows up in strange places. A model that cannot see letters struggles to count them, to spell a word backwards, to say which letter comes fifth, to rhyme, to solve a crossword clue, to read a misspelled word, to handle a chemical formula or a strand of genetic code where every single character carries meaning. It struggles with numbers, because a number like 2026 may be one piece while 2027 is two. It struggles with languages the tokenizer was not trained on, because their words fall apart into many small pieces, which makes every sentence longer, slower and more expensive than the same sentence in English.

The alternative is old and simple: read the bytes. Every character in every language can be written as one to four bytes in UTF-8, and there are only 256 possible bytes. A model that reads bytes has a tiny vocabulary, never meets an unknown word, and sees every letter. The problem is length. English text is roughly four bytes for each token, so a byte-level model has to read sequences about four times as long, and other scripts are longer still. Training such a model from scratch costs a great deal, and for years byte-level models trailed the subword models that everyone already had.

Byte-level models found a way around the length problem by grouping bytes into patches. A small model reads the bytes, decides where one group should end and the next begin, and passes one summary per group to the large model in the middle. Predictable stretches of text, such as the end of a familiar word, can go into one long patch; surprising stretches, such as the start of a new word or a rare name, start new patches. The big model then reads about as many patches as it would have read tokens, but the small models at the edges still see every byte.

Byteification takes this one step further. Instead of training a byte-level model from scratch, it takes an existing subword model and replaces only its input and output layers. A small local encoder reads bytes and builds patches; a boundary predictor decides where patches end; the original transformer in the middle is kept; a small local decoder turns its output back into bytes. In the first stage the middle stays frozen while the new edges learn to imitate the old model. In the second stage the whole network trains together. The reported cost is less than one percent of what training the original model took, and the converted models keep most of their original skill while becoming much better at tasks that need the letters.

What does this mean for anyone who uses or builds these systems? It means the tokenizer is no longer a fixed fact of life. It means character tasks can be measured rather than argued about. It means text in many languages may soon cost the same to process as English. And it means it is worth looking closely at what a tokenizer actually does to a sentence, which is what this small library is for.

A tokenizer in this library is trained the same way the widely used byte pair encoding tokenizers are trained. Start from the 256 bytes. Count every pair of neighbouring pieces in the training text. Join the most frequent pair into a new piece. Count again and repeat until the vocabulary is the size you asked for. Common words end up as single pieces because their pairs were joined again and again; rare words stay in fragments. Because this tokenizer is trained only on English, it treats other scripts the way large tokenizers treat languages that were rare in their training data: it falls back on bytes.

The patches in this library come from a much smaller idea than a trained boundary predictor. A short byte model counts which byte tends to follow each run of three bytes in the training text. For every position in a new text it asks how uncertain the next byte is. Where the uncertainty is high, a new patch begins. Where it is low, the patch continues. The result is not what a real byte-level model would choose, but it shows the same shape: long patches inside common words, short patches at the start of words and in unfamiliar text.

Here are some things worth trying. Type a long word and see how many tokens it becomes. Type the same sentence in another language and compare the number of tokens, bytes and patches. Type a number and then the next number. Type a word with a spelling mistake. Ask which letters are hidden inside tokens: in a word like strawberry, most of the r's sit inside longer pieces, where a subword model cannot see them. Then make a set of character tasks, give them to a model you use, and grade its answers. The point is not to catch a model out. It is to know what it can and cannot see.

Counting letters is a small thing. Seeing text the way it is written is not. Scientific text is full of strings where every character matters: sequences of bases in DNA, chemical names, identifiers, code, measurements with their units. A system that reads these strings in arbitrary chunks will make arbitrary mistakes. Reading bytes is not free, but it is honest about what is on the page.
