Tokenization
He treats the tokenizer as a separate pipeline stage trained with BPE, and as a frequent source of strange LLM behavior.
Based on Andrej Karpathy's public content. Not affiliated with or endorsed by Andrej Karpathy.
Covered in
GitHub · minbpe: Minimal, clean code for the Byte Pair Encoding (BPE) algorithm commonly used in LLM tokenization.
Karpathy's minbpe README presents a minimal, readable implementation of byte-level Byte Pair Encoding, the tokenization algorithm used by modern LLMs. He explains the three core tokenizer functions (train, encode, decode), walks through a toy example, shows verification against GPT-4's tiktoken tokenizer, and explains how to train custom tokenizers and safely handle special tokens.
Neural Networks: Zero To Hero
This is the course page for Karpathy's 'Neural Networks: Zero To Hero', which teaches neural networks by building them from scratch in code. It starts with backpropagation and works up to GPT and tokenizers. He argues that language models are an excellent vehicle for learning deep learning in general.
Let's build the GPT Tokenizer
This source introduces the tokenizer as a necessary and pervasive component of large language models that translates between strings and tokens (text chunks). Karpathy frames tokenizers as a completely separate stage of the LLM pipeline with their own training sets and training algorithm, Byte Pair Encoding. The provided excerpt is truncated, so only this framing is available.
GitHub · nn-zero-to-hero: Neural Networks: Zero to Hero
This README outlines Karpathy's course that teaches neural networks from the basics by coding and training them together, progressing from a scalar autograd engine (micrograd) through character-level language models (makemore) to building GPT and its tokenizer from scratch. He emphasizes hands-on implementation, understanding internals like gradients and activations, and building intuition that enables debugging and innovation.