Byte-Level BPE
An ordinary subword tokeniser starts from characters, and a character it never saw during training has nowhere to go. Byte-level BPE removes that failure case by starting one level further down.
256 symbols is enough
Text on a computer is UTF-8 bytes, so the base alphabet here is the 256 possible byte values rather than the open-ended set of Unicode characters. Merges are then learned exactly as in ordinary BPE — repeatedly join the most frequent adjacent pair — but over bytes. Because every string is a sequence of bytes, every string is encodable: there is no UNK token and no out-of-vocabulary case, ever. Implementations first map the 256 bytes onto printable characters so whitespace and control bytes survive the ordinary string handling in between; the mapping is reversible exactly.
Where it is used, and what it costs
GPT-2 introduced the scheme and RoBERTa and BART adopted it; in Hugging Face tokenizers it is ByteLevelBPETokenizer. The cost falls unevenly across languages. A Latin-script letter is one byte, but a Devanagari or CJK character occupies three, so the same sentence in Hindi or Chinese consumes far more tokens — more of the context window, more compute, less room for the actual task.
Why it matters
Emoji, code, mixed scripts, mojibake and unusual brand names all pass through losslessly instead of collapsing into a single unknown token. The flip side is that one character can straddle a token boundary, so a model can emit a byte sequence that is not yet valid UTF-8; a decoder has to hold the partial bytes until the character completes, which is why streaming output occasionally shows a replacement character before correcting itself.
Byte-level BPE applies byte-pair merges to the UTF-8 bytes of text rather than to characters, giving a base alphabet of exactly 256 symbols. Any string is therefore encodable and no out-of-vocabulary token is ever required — the property that made it the tokeniser of GPT-2, RoBERTa and BART. The cost falls unevenly: scripts whose characters span several bytes consume proportionally more tokens, and a single character can split across a token boundary.
Every piece of text on a computer is ultimately a string of small numbers — the same limited set whether you typed English, Hindi, an emoji, or a line of code. A system that works at that level can therefore swallow absolutely anything you give it.
Byte-level BPE does exactly that. It chops text into useful chunks, but builds those chunks out of raw computer bytes rather than out of letters, so there is no such thing as a symbol it has never seen and has to give up on. The catch is fairness: languages not written in the Latin alphabet need more bytes per character, so the very same sentence costs the machine more to read in Hindi than in English.