Let's build the GPT Tokenizer
What it is
Andrej Karpathy builds the GPT tokenizer from scratch, implementing byte pair encoding along with encode and decode. He shows how many odd LLM behaviors trace back to tokenization, and covers Unicode byte encodings along the way.
Why Hacker News recommends it
Recommended as the best deep dive on tokenizers, worth the two hours for anyone working with LLMs.
- 5 people recommended it
- 5 different months
- 1 strong recommendations
- first 2024, last 2025
What HN commenters said
“Worth spending 2h for the deeper understanding if you deal with LLMs.”
Explains why tokenizers exist and how BPE works.
cranium, 2024-10 · Strong recommendation · in “Probably pay attention to tokenizers”
“check out Andrej Karpathy's latest video if you have 2 hours for a deep dive”
Two-hour deep dive on how GPT tokenizers work.
moozilla, 2024-03 · Recommendation · in “Ask HN: Did you encounter any leap year bugs today?”
“this video is a great resource”
Explains why models struggle with letters in words.
Chirono, 2024-08 · Recommendation · in “Artificial intelligence is losing hype”
“Understanding tokenization is surprisingly useful, even if that video seems awfully long to devote to such a tedious subject.”
In-depth explanation of byte-pair encoding tokenization.
zellyn, 2025-04 · Recommendation · in “Why Does Claude Speak Byzantine Music Notation?”
“also contains a good introduction to Unicode byte encodings, ASCII, UTF-8, UTF-16, UTF-32 in the first 20 minutes”
Good intro to Unicode byte encodings in the first 20 minutes.
vismit2000, 2025-09 · Recommendation · in “UTF-8 is a brilliant design”
Excerpts from Hacker News comments, linked to the originals. Summaries and labels were written by a language model from those comments.
Topics: byte pair encoding, tokenizer, gpt, unicode, llm
Also recommended by the same people
talkA Crash Course in Modern Hardware by Cliff ClickDevoxx · 3 HN recommenders · 2017–2025
otherSci-Fi Short Film “Slaughterbots” | DUSTDUST · 5 HN recommenders · 2021–2026
lectureLambda Calculus - Fundamentals of Lambda Calculus & Functional Programming in JavaScriptFullstack Academy · 5 HN recommenders · 2019–2024
explainerTransformers, the tech behind LLMs | Deep Learning Chapter 53Blue1Brown · 13 HN recommenders · 2024–2026
lectureDeep Dive into LLMs like ChatGPTAndrej Karpathy · 10 HN recommenders · 2025–2026
tutorialLet's build GPT: from scratch, in code, spelled out.Andrej Karpathy · 14 HN recommenders · 2023–2025
tutorialA Hackers' Guide to Language ModelsJeremy Howard · 8 HN recommenders · 2023–2024
talk[1hr Talk] Intro to Large Language ModelsAndrej Karpathy · 9 HN recommenders · 2023–2026