Learn about byte-pair encoding, UTF-8, and more
You can read the stage instructions for free. To start building, you'll need a membership.
Want to try a free challenge? Try Build your own Redis — it's free until 31 December 2026.
Why does GPT-2 split strawberry into three tokens, but keep strawberry as one?
Its tokenizer converts text into token IDs, the numbers the model receives. Its learned vocabulary includes the space-prefixed word as one token, while the unspaced word uses smaller pieces. You'll build a tokenizer that learns merge rules from text, encodes and decodes text, and loads GPT-2's vocabulary to match its IDs.
You'll learn how UTF-8 represents text as bytes, how byte-pair encoding learns merges, and why token boundaries depend on whitespace.