Neural Networks: Zero to Hero
Andrej KarpathyFrom scalar autograd and backpropagation in pure Python up to modern Transformer language models built line-by-line from scratch.
Syllabus
11Spelled-Out Intro to Neural Networks & Backpropagation: Building micrograd
Demystifies PyTorch's autograd in 150 lines of clean Python by manually computing numerical derivatives, applying the multivariable chain rule, and verifying gradients against torch.Tensor.
Spelled-Out Intro to Language Modeling: Building makemore (Bigram & Cross-Entropy)
Builds character-level autoregressive language models two ways—explicit transition count tables and gradient-based one-hot neural networks—proving they converge to identical negative log-likelihood loss.
Building makemore Part 2: Multi-Layer Perceptron Language Models (Bengio et al. 2003)
Implements Bengio et al.'s landmark 2003 neural probabilistic language model from scratch: learned token embeddings, mini-batch SGD, learning-rate finder sweeps, and train/dev/test splits.
Building makemore Part 3: Activations, Gradients, Kaiming Init & BatchNorm
Essential deep-learning diagnostics: visualizing saturated tanh tails, dead ReLUs, Kaiming He variance preservation, Batch Normalization internals, and gradient-to-data update-ratio histograms.
Building makemore Part 4: Becoming a Backprop Ninja (Manual Tensor Gradients)
Deletes loss.backward() and manually derives analytical tensor gradients through BatchNorm, linear layers, and fused cross-entropy softmax—checking every tensor to floating-point precision.
Building makemore Part 5: Hierarchical Dilated Causal Convolutions (WaveNet)
Transforms a flat MLP into a DeepMind WaveNet tree-structured architecture while building clean torch.nn-style Sequential and FlattenConsecutive abstractions.
Let's Build GPT: From Scratch, in Code, Spelled Out
Perhaps the single most-watched modern AI engineering lecture: constructs a full decoder-only Transformer (scaled dot-product causal self-attention, multi-head blocks, residuals, LayerNorm) live from an empty file.
State of GPT: Pretraining, SFT, Reward Modeling & RLHF Pipeline
Crisp architectural map of the four-stage LLM training pipeline (base pretraining, supervised finetuning, reward modeling, RLHF) plus practical inference psychology on token-by-token compute.
Let's Build the GPT Tokenizer: Byte Pair Encoding & Unicode Internals
Reveals why tokenization is the root cause of weirdly brittle LLM behaviors (spelling, arithmetic, trailing whitespace, non-English token bloat) by implementing UTF-8 Byte Pair Encoding from scratch.
Let's Reproduce GPT-2 (124M): Distributed PyTorch, FlashAttention & FineWeb
Four-hour systems-and-ML tour de force: reproduces OpenAI's GPT-2 (124M) from an empty file, optimizing throughput 10x via BF16 tensor cores, torch.compile, FlashAttention, cosine decay, and multi-GPU DDP.
Introduction to Large Language Models
A remarkably dense, hype-free 60-minute mental model of what an LLM actually is—two files on disk (weights + inference code) shaped by pretraining compression and post-training alignment.










