Save this video free

The spelled-out intro to language modeling: building makemore

Andrej Karpathy · 1:57:45 · Watch on YouTube

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

Andrej Karpathy builds a character-level bigram language model called makemore from scratch, demonstrating how to process text data, count character bigram frequencies, and represent these counts in a 2D PyTorch tensor. He then implements the same model using a neural network, showing how gradient-based optimization can learn the same probability distributions as direct counting, achieving a comparable loss of ~2.45. This neural network approach, while initially more complex, offers greater flexibility for future model enhancements.

Key takeaways

Chapters

0:00 Introduction to Makemore and Character-Level Language Models
3:13 Loading and Analyzing the Names Dataset
4:27 Understanding Bigram Statistics and Data Representation
13:29 Transitioning from Dictionary Counts to a 2D Tensor
15:34 Creating Character-to-Integer Mappings
18:29 Visualizing the Bigram Count Tensor
21:40 Refining the Bigram Model with a Single Special Token
23:30 Sampling Characters from the Bigram Model
30:17 Generating Names with the Bigram Model
35:17 Comparing Bigram Model Performance to Uniform Distribution
37:37 Improving Efficiency: Pre-calculating Probability Matrix
42:43 Understanding and Avoiding Broadcasting Errors
53:27 Evaluating Model Quality with Negative Log Likelihood
57:20 Calculating NLL Loss for the Bigram Model
1:04:11 Introducing the Neural Network Approach to Bigram Modeling
1:06:44 Preparing the Training Data for the Neural Network
1:10:53 One-Hot Encoding Input Characters
1:13:32 Constructing the First Neural Network Layer (Linear Layer)
1:18:37 Interpreting Neural Network Outputs: Logits, Counts, and Probabilities
1:23:28 The Softmax Function for Probability Distribution Output
1:28:37 Implementing the Forward Pass and Calculating Loss
1:30:44 Backpropagation and Gradient Descent for Weight Updates
1:38:33 Training the Neural Network on the Full Dataset
1:45:40 Comparing Counting vs. Neural Network Approaches
1:50:09 Sampling from the Trained Neural Network Model

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

Transcript excerpt

0:00 Hi everyone. Hope you're well. And uh next up what I'd like to do is I'd like to build out make more. Like micrograd before it, make more is a repository that I have on my GitHub webpage. Uh you can look at it. Uh but just like with micrograd, I'm going to build it out step-by-step and I'm going to spell everything out. So, we're going to build it out slowly and together. Now, what is make more? Make more, uh as the name suggests, uh makes more of things that you give it. So, here's an example. names.txt is an example data set to make more. And when you look at names.txt, you'll find that it's a very large data set of names. So, here's lots of different types of names. In fact, I believe there are 32,000 names that I've sort of found randomly on a government website.

0:47 And if you train make more on this data set, it will learn to make more of things like this. Um and in particular in this case, that will mean more things that sound name-like, but are actually unique names. And maybe if you have a baby and you're trying to assign name, maybe you're looking for a cool new sounding unique name, make more might help you. So, here are some example generations from the neural network once we train it on our data set. So, here's some example unique names that it will generate. Dontal, uh Irot, uh Zendy, and so on. And so, all these sort of sound name-like, uh but they're not, of course, names. So, under the hood, make more is a character-level language model. So, what

1:35 that means is that it is treating every single line here as an example. And within each example, it's treating

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

Related notes

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.