Foundations — Tokenization fundamentals
Before you can read a single formula in the parent note, you need to know what each squiggle means and what picture lives behind it. We build them in order, each one using only the ones before it. Nothing is assumed.
1. Text as a stream of characters
The very first mental picture: a sentence is not a neat list of words to a computer. It is a ribbon of characters laid end to end, with no gaps except the space characters that are themselves just characters on the ribbon.

Look at the ribbon in the figure: H e l l o , w o r l d !. The space (drawn as ␣) is a real tile on the ribbon, not empty air. Why the topic needs this: every later idea — normalization, splitting, counting pairs — is an operation on this ribbon. If you don't see text as a physical sequence of tiles, phrases like "consecutive pair" or "sequence length" have nothing to point at.
2. The set — writing "the collection of allowed things"
The parent note writes the starting BPE vocabulary as
Read this slowly, symbol by symbol:
- is just a name we chose for the bag (V for vocabulary).
- The subscript means "the version before any merges" — a snapshot label, like "frame 0 of a movie."
- The braces say "here is the bag's contents."
The picture: a jar of unique tiles. Throwing a second l into the jar changes nothing, because the jar only ever keeps one of each.
3. Vocabulary and its size
The vertical bars are the same "how many?" idea you already use for the length of a list. Whenever you see in this chapter, translate it in your head to the plain English word "count of."
Why the topic needs it: the whole BPE loop stops when reaches a target like 50 000. Without a symbol for "size of the bag," we couldn't even state the stopping rule.
4. Token — the tile we actually work with
Picture a token as a single domino tile. The ribbon of characters gets glued into a shorter ribbon of these domino tiles. A word like newest might become the two tiles new and est.

The figure shows the same word cut three different ways: as 6 character-tiles, as 2 subword-tiles, and as 1 word-tile. This is the central trade-off of the entire topic — more tiles means longer sequences but a smaller jar; fewer tiles means a shorter sequence but a bigger, sparser jar. Everything the parent note says about "sequence length explosion" and "vocabulary explosion" is a comment on this one picture.
5. Counting and the "most frequent pair"
Compare two cousins:
- → the biggest value of .
- → the that produced that biggest value.
The parent's rule reads in plain English: "Look at every adjacent pair of tiles, count how often each occurs, and hand me back the pair that occurred most." The little star is just a decoration meaning "the chosen/winning one."
The picture: slide a two-tile window across the whole corpus, tally marks under each pair you see, then circle the pair with the most tally marks.

6. Union — growing the jar with
The merge rule now reads cleanly: "The next vocabulary is the current jar plus the one new merged tile." The subscripts and are just step numbers — "this iteration" and "the next iteration," like page numbers of the algorithm's diary.
Why the topic needs it: BPE literally is a sequence of jars each one tile larger than the last. The is the act of adding that tile.
7. Functions, arrows, and "maps to"
Think of a function as a vending machine: put in a string, out comes a list of numbers. The notation (square brackets) is a dictionary lookup — "find token in the vocab and read off its ID," exactly like looking up a word in a phone book to get its number.
The subscript numbering in just says "the 1st tile, 2nd tile, …, up to the -th (last) tile." The letter stands for however many tiles there happen to be — a placeholder for a count, not a fixed number.
8. Averages and the (sigma) symbol
So the average sequence length translates piece by piece:
- → "for every sentence in the corpus , add up…"
- → "…the number of tokens that sentence became" (bars = count, from §3).
- → "divide by how many sentences there are."
- The bar over → the common notation for an average.
Result: "the average number of tiles per sentence." Nothing mysterious — it is the ordinary classroom average, dressed in symbols so it fits on one line.
9. Putting the symbols back into the pipeline
Now every arrow in the parent's pipeline is readable: Each arrow is a function (§7). The words above the arrows name which vending machine is running. The endpoints move from ribbon (§1) → cleaner ribbon → domino tiles (§4) → integers (the phone-book numbers).
Once these atoms are in place you are ready for the algorithms that stack on top — 4.2.02-BPE-algorithm, 4.2.03-WordPiece-and-SentencePiece, and the fixed-size batching in 3.4.03-Sequence-length-and-padding. The integers you produce here are exactly what 4.3.01-Word-embedings turns into vectors, and what 5.1.02-Transformer-architecture consumes. The size of the jar and its unknown-token fallback are studied in 4.1.05-Vocabulary-and-OV, and the cross-language version in 4.2.08-Multilingual-tokenization.
Recall Self-test: read these aloud
What does mean? ::: The count of tokens in the vocabulary (its size). What is the difference between and ? ::: returns the biggest value; returns the input that produced it (here, the winning pair). What does do in words? ::: It builds the next vocabulary by adding the one newly-merged tile to the current jar. Why must exist? ::: So decoding can turn each integer ID back into its token, making the process reversible. In , what is ? ::: The number of tokens sentence becomes after tokenization.
Equipment checklist
Test yourself — you should be able to answer each without peeking.
I can picture text as a ribbon of character tiles including spaces
␣ is a real tile, not empty air.