// Stage 4 · Transformers & LLMs
Tokenization & Embeddings
BPE tokenisation, per-token pricing, embeddings and semantic similarity.
about 6 hours6 algorithms2 paperslesson text ready
01Goals
- Write a minimal BPE by hand
- Relate token counts to cost and context length
- Understand embeddings and cosine similarity
Do these first: CNNs, RNNs and the Birth of Attention
02Read on this site
03Algorithms to master
Each card has the original paper, prerequisites and resources.
04Must-read papers
05Courses & videos
- karpathy/minbpe ↗Reference codeEN
- huggingface.co ↗CoursesEN
- openai/tiktoken ↗Reference codeEN
- Karpathy:Neural Networks: Zero to Hero ↗VideoEN
06Hands-on: project, code & exercises
Free, official or author-published pages. Most run in the browser or on a free Colab GPU.
PROJECT
Following minbpe, train a 4K-vocabulary BPE on a Chinese corpus and compare its token count with tiktoken on the same Chinese text.
- 1
- 2karpathy/minbpe ↗Reference code
Implement a BPE tokenizer step by step following the repo’s exercise guide.
- 3google/sentencepiece ↗Reference code
Train a SentencePiece tokenizer on Chinese text and compare BPE vs Unigram.
07Self-test
Answer in your head, then open to check.
Why does Chinese often use more tokens than English?
Vocabularies contain fewer Chinese merges, so one character can take more than one token.
How does BPE handle unseen words?
It splits them into known sub-words or bytes.
What does it mean when two embeddings are close?
Similar meaning or usage.
On these routes: Everyday Users · Application Developers · Algorithm Researchers