Video lesson 8
Let's build the GPT Tokenizer
The final module - and the one that explains the folklore. Build byte-pair encoding, the exact algorithm GPT-4 reads with, in pure Python: bytes as the universal alphabet, the count-and-merge loop that mints tokens from frequency alone, GPT-4's regex guardrails, and the special tokens that carry a chat product's control plane. Train it on Shakespeare and read the vocabulary it invents.
UTF-8 and code pointsByte-pair encodingPair statisticsThe merge operationVocabulary mintingMint-order encoding