Tokenization

Tokenization is the process of breaking text into smaller units called tokens so that a machine learning model can process them.

Different types of tokenization techniques

1. Word-level tokenization

2. Character-level tokenization

3. Subword-level tokenization

4. Byte-level tokenization

5. Unigram tokenization

BPE (Byte Pair Encoding)

Comparison: Which technique is better?

TechniqueVocabularySequence lengthCommon application
Word-levelLargeShortTraditional NLP
Character-levelSmallVery longCharacter models
SubwordMediumMediumModern LLMs
Byte-levelSmall base unitsVariableRobust text processing
UnigramMediumMediumModern NLP/LLMs

If your goal is to build an LLM from scratch, learn these in this order:

  1. Word-level tokenization – understand the basics.
  2. Character-level tokenization – understand vocabulary and IDs.
  3. BPE – understand how modern tokenizers learn vocabulary.
  4. WordPiece – understand BERT tokenization.
  5. Unigram – understand probabilistic segmentation.
  6. Byte-level BPE – understand GPT-style tokenization.

Leave a Reply