Interactive Lab · Tokenization
Before an LLM sees your prompt, a tokenizer chops it into pieces. But which pieces? Byte-Pair Encoding figures it out from data with one dead-simple rule, repeated: find the most common adjacent pair and glue it into a new token. Do that a few thousand times and useful chunks like ·the and cat emerge on their own. Slide the merges below and watch raw characters fuse into subwords.
▶ The playground, type text, then merge
Before an LLM sees text, a tokenizer chops it into subword pieces (BPE). It's why models have token limits, why rare words cost more, and why the same prompt is pricier in some languages. Every API call's cost and context window is counted in these tokens.
The code that's actually running
Type a word many times (e.g. paste banana banana banana banana) and slide the merges up. Watch it collapse from b·a·n·a·n·a down to a single token, because a token that appears constantly is worth its own vocabulary slot. Now add a word you only typed once: it stays broken into small pieces. That's the whole trade-off BPE balances, common strings get short tokens, rare strings get spelled out, which is exactly why an LLM handles a typo or a made-up word gracefully instead of choking.
The takeaway
token + ization), sometimes a single character for anything rare.