Every large language model — GPT, LLaMA, BERT — begins with the same invisible step: it tokenizes the input. Before any attention mechanism fires, the raw text is sliced into a sequence of tokens drawn from a fixed vocabulary. Those tokens are not characters, and they are not always whole words. They are the output of a surprisingly simple algorithm called Byte-Pair Encoding (BPE).
BPE was invented in 1994 as a lossless data-compression scheme: find the most frequent pair of adjacent bytes, replace every occurrence with a new byte, repeat. In 2016, Rico Sennrich, Barry Haddow and Alexandra Birch adapted it for neural machine translation, and it has dominated NLP ever since.
The idea is disarmingly simple. Start with a vocabulary of individual characters (or bytes). Count every adjacent pair of symbols in the training corpus. Merge the most frequent pair into a new symbol. Repeat until the vocabulary reaches its target size — typically 30,000 to 100,000 tokens. The result is a vocabulary that covers common words as single tokens, splits rare words into recognizable pieces, and handles any unseen text without ever hitting an unknown-word problem.
Comments
Loading comments...