Seven words, twelve merges, one vocabulary — built in front of you. Every pair count, every merge decision and every token on this page comes from running byte-pair encoding, not drawn as a diagram of it. By the last tab you will know precisely why a model that reads tokens cannot count the letters in "strawberry".
Step through at your own pace · prerequisites: NLP Evolution (09)
Start on Train BPE — the other three tabs all use the vocabulary it builds. There is no random seed anywhere on this page: given the corpus and the tie-break rule, byte-pair encoding is deterministic, so every count you see is reproducible with a pencil. The Train and Encode tabs each end with a self-check that recomputes their result by a second, independent route and prints whether the two agree.
cranberry needing letters the vocabulary has no id for. That hole is exactly what byte-level BPE closes." berry" and "berry" are different ids) or append an end-of-word symbol, so merges can never cross a word boundary and word-final pieces stay distinct. Here each word is merged independently with no marker, which keeps the chips readable at the cost of that distinction.<|endoftext|> and friends before the first merge is ever applied. All of that sits around the algorithm shown here, not inside it.