Skip to content
English

Switch theme

// Stage 4 · Transformers & LLMs

Tokenization & Embeddings

BPE tokenisation, per-token pricing, embeddings and semantic similarity.

about 6 hours6 algorithms2 paperslesson text ready

01Goals

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

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. 1
    Tiktokenizer ↗Interactive

    Paste Chinese, English and code and count tokens across tokenizers.

  2. 2
    karpathy/minbpe ↗Reference code

    Implement a BPE tokenizer step by step following the repo’s exercise guide.

  3. 3
    google/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

Data updated: AI algorithms & curriculum(UTC+8)