What is Tokenization
Splitting text into tokens for model processing
Tokenization is the process of breaking down text into individual units (tokens) for subsequent processing by a language model or NLP system.
Types of Tokenization
- Word-based — splitting by spaces and punctuation
- Subword (BPE) — splitting into frequent substrings
- Character-level — each character as a separate token
- SentencePiece — language-independent tokenization
Why Tokenization Matters
- Defines the model's vocabulary
- Affects handling of rare words
- Determines API request costs (per token)
- Impacts processing speed
Token Examples
- "hello world" → ["hello", " world"] (GPT)
- "machine learning" → ["machine", " learning"] (BPE)
- "unbelievable" → ["un", "believ", "able"] (subword)
Popular Tokenizers
- tiktoken (OpenAI) — for GPT models
- SentencePiece — Google, language-independent
- Byte-Level BPE — works with bytes
- WordPiece — BERT and derivatives