Save this video — free

Building makemore Part 2: MLP

Andrej Karpathy · 1:15:40 · Watch on YouTube

Building makemore Part 2: MLP Watch on YouTube →

Overview

Andrej Karpathy implements a Multi-Layer Perceptron (MLP) for character-level language modeling, building upon the previous bigram model. This MLP uses embeddings to represent characters, a hidden layer for non-linear transformations, and an output layer for predicting the next character, drawing inspiration from the Bengio et al. (2003) paper. The implementation details include efficient tensor manipulation with PyTorch's `view` and `cat`, numerical stability considerations for cross-entropy, and a systematic approach to hyperparameter tuning and training with mini-batches.

Key takeaways

Chapters

0:00 Limitations of Bigram Models and Introduction to MLPs
2:30 The Bengio et al. (2003) Paper and Embedding Concepts
8:00 MLP Architecture Diagram and Components
9:00 Data Preparation: Block Size and Input/Output Tensors
12:10 Implementing Character Embeddings with PyTorch
16:20 Efficiently Embedding Multiple Characters using PyTorch Indexing
17:30 Constructing the Hidden Layer: Concatenation and `view`
24:10 Hidden Layer Calculations: Linear Transformation and Tanh Activation
28:20 Output Layer: Logits and Softmax for Probabilities
30:00 Calculating Loss: Negative Log Likelihood and `F.cross_entropy`
36:40 Training Loop: Gradients, Backpropagation, and Parameter Updates
40:20 Mini-Batch Training for Efficiency
45:00 Learning Rate Tuning and Finding Optimal Settings
51:40 Data Splitting: Train, Dev, and Test Sets
58:20 Scaling Up the Model: Increasing Hidden Layer and Embedding Size
1:05:00 Visualizing Character Embeddings and Sampling from the Model
1:13:20 Final Thoughts and Further Improvements

Keep these chapters and the full searchable transcript in your own library.

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Andrej Karpathy.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.