Home Knowledge Base Tokenization

Tokenization is the process of converting raw text into a sequence of discrete tokens (subword units) that serve as the input vocabulary for language models — determining how text is segmented into meaningful units, where the tokenizer's vocabulary size and algorithm directly impact model performance, multilingual capability, and inference efficiency.

Tokenization Approaches

MethodGranularityVocabulary SizeExample: "unhappiness"
Word-levelFull words50K-500K["unhappiness"]
Character-levelSingle chars26-256["u","n","h","a","p","p","i","n","e","s","s"]
BPE (Subword)Subword units32K-100K["un", "happiness"]
Byte-level BPEByte sequences50K-100K["un", "happ", "iness"]

Byte Pair Encoding (BPE)

1. Start with character vocabulary + special end-of-word token. 2. Count all adjacent character pairs in training corpus. 3. Merge the most frequent pair into a new token. 4. Repeat steps 2-3 until desired vocabulary size reached.

WordPiece (BERT)

SentencePiece

Vocabulary Size Impact

Vocab SizeTokens/WordSequence LengthCompute
4K~2.5Long sequencesHigh
32K~1.3MediumMedium
100K~1.1ShortLower
256K~1.0ShortestLowest

Tokenization Challenges

Tokenization is the often-overlooked foundation that constrains everything a language model can do — a poorly designed tokenizer wastes model capacity on suboptimal text segmentation, while a well-designed one enables efficient multilingual processing and better numerical reasoning.

tokenizationbyte pair encodingbpesentencepiecewordpiece tokenizer

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.