Skip to main content
Primary: Phase 3Used in Phases 3, 4, 5Video SeriesIntermediateFree Learning Material
Andrej Karpathy

Neural Networks: Zero to Hero

A code-first introduction to neural networks covering automatic differentiation, backpropagation, language models, and GPT implementations.

Andrej Karpathy's flagship code-first lecture series is the backbone of Phases 3, 4, and 5 of this curriculum. Starting from an empty Python file, you build `micrograd` (a scalar reverse-mode autograd engine), progress through `makemore` (character-level language models using bigrams, MLPs, BatchNorm, diagnostic histograms, backprop ninja, and WaveNet), build a GPT tokenizer from scratch (`minbpe`), and culminate in implementing and training a GPT-2 decoder-only Transformer in PyTorch.

Resource Tracking

Course status is tracked independently from roadmap topic checkboxes so you can mark external courses without altering your topic mastery percentage.

Suggested Learning Position

Core Spine across Phase 3 (Autograd/DL), Phase 4 (Makemore/Tokenizers), and Phase 5 (GPT From Scratch)

Language:English
Access & Link Verification

All video lectures, GitHub repositories (micrograd, makemore, minbpe, nanoGPT), and Jupyter notebooks are 100% free and open-source.

Status: Verified (2026-11-09)

What You Will Learn from This Resource

  • Build a reverse-mode automatic differentiation engine (`micrograd`) and verify gradients.
  • Construct and diagnose multi-layer neural networks, activations, and batch/layer normalization.
  • Implement Byte Pair Encoding (BPE) tokenizers, character language models (`makemore`), and decoder-only GPT Transformers from scratch.

Recommended Prerequisites

Review these foundations before starting so you get the most out of this material:

  • Solid Python & NumPy fluency (Phase 0) and multivariable calculus/matrix multiplication (Phase 1).

Topics & Keywords

Andrej KarpathyMicrogradMakemoreBackpropagationAutogradTokenizersGPTPyTorch
Curriculum Integration

How This Resource Fits Into Your AI & LLM Roadmap

Open Interactive Roadmap

Phase-Specific Study Recommendations (3)

Phase 3 · Resource 3.1Start Here · Recommended

Neural Networks: Zero to Hero

In Phase 3: Deep Learning & Neural Networks

Start Phase 3 here! Watch Lecture 1 ('The spelled-out intro to neural networks and backpropagation: building micrograd') and Lectures 4–5 ('Becoming a Backprop Ninja' & activation/gradient diagnostics).

Phase 4 · Resource 4.3Additional Learning

Makemore — Neural Networks: Zero to Hero

In Phase 4: NLP & Language Modeling

In Phase 4, focus on the Makemore lectures (Bigrams, MLP character language model, and 'Let's build the GPT Tokenizer') to implement BPE tokenization and autoregressive character/subword modeling from scratch.

Phase 5 · Resource 5.1Start Here · Recommended

Neural Networks: Zero to Hero — GPT

In Phase 5: Transformers From Scratch

Start Phase 5 with the final two lectures of Zero to Hero: 'Let's build GPT: from scratch, in code, spelled out' and 'Let's reproduce GPT-2 (124M)' to implement every block of your Mini GPT.

Directly Associated Roadmap Modules (11)

Module 3.1Phase 3

Neural Network Fundamentals

Neurons, feedforward layers, modern activations (ReLU, GELU, SiLU), forward/backward passes, initialization, normalization, and residual streams.

Inspect module checklist →
Module 3.2Phase 3

Automatic Differentiation

Building a dynamic reverse-mode autodiff engine (micrograd-style) with computational graphs, topological sorting, and gradient accumulation.

Inspect module checklist →
Module 3.3Phase 3

PyTorch Fundamentals

PyTorch tensors, GPU acceleration, autograd mechanics, nn.Module architecture, DataLoaders, checkpointing, and mixed precision.

Inspect module checklist →
Module 4.2Phase 4

Traditional NLP

Bag of Words, TF-IDF weighting, N-gram statistical language models with smoothing, and dense static embeddings (Word2Vec, GloVe).

Inspect module checklist →
Module 4.3Phase 4

Tokenization

Character, word, and subword tokenization; Byte Pair Encoding (BPE), WordPiece, Unigram, vocabulary sizing, and special control tokens.

Inspect module checklist →
Module 4.4Phase 4

Language Modeling

Autoregressive next-token prediction, conditional probability factorization, cross-entropy training, perplexity evaluation, and sampling.

Inspect module checklist →
Module 5.1Phase 5

Attention Fundamentals

Why attention replaced recurrence, Queries/Keys/Values, scaled dot-product attention, softmax normalization, and causal lower-triangular masking.

Inspect module checklist →
Module 5.2Phase 5

Transformer Components

Multi-head attention, positional representations (sinusoidal, learned, RoPE), FFN blocks (GELU, SwiGLU), Pre-LN LayerNorm & RMSNorm, residual connections, weight tying, and initialization.

Inspect module checklist →
Module 5.3Phase 5

Transformer Architectures

Comparing Encoder-only (BERT), Decoder-only (GPT/LLaMA), and Encoder-Decoder (T5) architectures, attention masking patterns, and block stacking.

Inspect module checklist →
Module 5.4Phase 5

Implement GPT Architecture

Hands-on PyTorch implementation of a complete GPT-style language model from scratch—from embeddings and attention blocks to loss calculation, training loop, and generation.

Inspect module checklist →
Module 5.5Phase 5

Text Generation

Decoding strategies (greedy, temperature, top-k, top-p nucleus sampling), context window limits, stopping criteria, KV caching, and repetition mitigation.

Inspect module checklist →
Continue Exploring
Browse Full Library
Phases 5, 6Video Lecture
Andrej Karpathy
AdvancedFree Learning Material

Let's Build GPT: From Scratch

Standalone 2-hour hands-on video lecture building and training a generative pretrained Transformer (GPT) from an empty Python script.

Used across:Phase 6 (6.2)
Andrej KarpathyGPTVideo LecturePretrainingPyTorch
Your Status:
Phases 5, 6GitHub Repository
Andrej Karpathy
AdvancedFree Learning Material

nanoGPT

The simplest, fastest, and most readable open-source repository for training and fine-tuning medium-sized GPT language models (~300 lines of model code and ~300 lines of training loop).

Used across:Phase 5 (5.4)Phase 6 (6.3)
nanoGPTAndrej KarpathyGPT-2PyTorchPretraining
Your Status:
Phase 3Documentation / Tutorials
PyTorch
IntermediateFree Learning Material

PyTorch Beginner Tutorials

Official 'Learn the Basics' tutorial series covering PyTorch Tensors, Datasets/DataLoaders, `nn.Module`, `torch.autograd`, optimization loops, and model checkpointing.

PyTorchTensorsAutogradnn.ModuleDataLoader
Your Status:
Phases 5, 6, 8Recommended StartUniversity Course Materials
Stanford University
AdvancedFree Learning Material

CS336 — Language Modeling from Scratch

Graduate-level Stanford course walking through every aspect of building language models from scratch: Transformer architecture, tokenization, pretraining data pipelines, GPU systems, parallelism, and scaling laws.

Used across:Phase 5 (5.2)Phase 6 (6.1)Phase 8 (8.1)
StanfordCS336Language ModelingPretrainingScaling Laws
Your Status: