Why split text into subwords?
Both extremes have problems. Word-level tokenization needs a separate token for every word form, so the vocabulary balloons and any word outside it maps to an unknown token [1]. Character-level tokenization can represent any word, but sequences get much longer and a single character carries little meaning [1].
Subword tokenization sits in between: common words stay whole and rare words break into meaningful pieces [1]. Hugging Face notes this helps in particular with languages like Turkish, where long words are built by stringing suffixes together [1]. For example, "annoyingly" might become "annoying" and "ly", or "annoy", "ing" and "ly", depending on the vocabulary [1].
How does byte pair encoding (BPE) work?
Sennrich, Haddow and Birch adapted BPE for neural machine translation in 2015. They encode rare and unknown words as sequences of subword units and report gains of 1.1 and 1.3 BLEU over a dictionary back-off baseline on the WMT 15 English-German and English-Russian tasks [2].
The algorithm starts from single characters and keeps merging the most frequent adjacent pair into a new token until it reaches the target vocabulary size [1]. GPT-2 uses byte-level BPE, with 256 byte tokens, 50,000 merges and one special end-of-text token, for a vocabulary of 50,257 [1].
What other methods are there?
BERT-family models use WordPiece, and models such as T5 use Unigram [1]. SentencePiece applies BPE or Unigram straight to raw text, without assuming spaces separate words, so it also works for languages such as Chinese and Japanese [1].