Andrej Karpathy on Model Training
Karpathy treats model training as an optimization process over data, where good losses, healthy gradients, careful hyperparameter tuning, and strong data curation matter more than mystique.
- Training is iterative loss minimization with backpropagation, not magic.
- A model should start near a sensible baseline; if it begins confidently wrong, optimization gets harder.
- Most training problems are practical: gradients, initialization, learning rates, and experiment discipline.
- As models scale, data curation becomes part of the training code, not a side task.
- Serious training systems need correct checkpointing and infrastructure, because optimization is expensive and iterative.

“At initialization, we have no reason to believe any characters to be much more likely than others, and so we'd expect that the probability distribution that comes out initially is a uniform distribution assigning about equal probability to all the 27 characters. So basically, what we'd like is the probability for any character would be roughly 1 over 27. That is the probability we should record, and then the loss is the negative log probability. So let's wrap this in a tensor and then we can take the log of it, and then the negative log probability is the loss we would expect, which is 3.29, much, much lower than 27.”Building makemore Part 3 lecture, 2021 · 5:06
Training is just optimization over a loss
Karpathy’s core framing is simple: a neural network is a mathematical expression, and training means adjusting its parameters to reduce a loss. Backpropagation is the key mechanism because it efficiently computes how each weight affects that loss, which makes iterative improvement possible.12
This view strips away the mystique around training. The important question is not what story you tell about the model, but whether your objective is well defined and whether gradients can reliably move parameters in a better direction.2
He applies the same logic across scales. Whether you are fitting a tiny character model or reproducing GPT-2, the machinery is fundamentally the same even if the forward pass becomes more complex.45
Use the loss as a diagnostic, especially at initialization
Karpathy emphasizes that the initial loss should make sense before you train for long. If a classifier begins with no reason to prefer one token over another, its predictions should be close to uniform, and the starting loss should reflect that baseline instead of being wildly inflated.6
When the initial logits are too large, the network can start off confidently wrong. That is a bad training state because the model is making sharp mistakes before it has learned anything, which slows improvement and often signals poor initialization or scaling inside the network.
This mindset is practical: inspect logits, probabilities, and loss early, not just final metrics. A healthy training run often starts with boring, sensible outputs and only becomes confident as learning earns that confidence.6

“At initialization, we have no reason to believe any characters to be much more likely than others, and so we'd expect that the probability distribution that comes out initially is a uniform distribution assigning about equal probability to all the 27 characters. So basically, what we'd like is the probability for any character would be roughly 1 over 27. That is the probability we should record, and then the loss is the negative log probability. So let's wrap this in a tensor and then we can take the log of it, and then the negative log probability is the loss we would expect, which is 3.29, much, much lower than 27.”Building makemore Part 3 lecture, 2021 · full transcript →
Healthy gradients depend on initialization and activation behavior
Karpathy repeatedly makes gradients concrete. Each operation contributes a local derivative, and the backward pass chains those effects together, which means training quality depends on whether those signals remain usable through the network.2
That is why activation saturation matters so much. In his BatchNorm lecture, he shows that poor initialization can push tanh units toward extremes, where gradients shrink and learning stalls; similar pathologies show up as dead or inactive neurons in common nonlinearities.
The practical implication is to watch internal statistics, not only the top-line loss. If activations or gradients are unhealthy, optimization may look noisy or slow even when the model architecture is otherwise fine.
Learning rates and hyperparameters should be tuned by experiment, not hope
Karpathy treats optimization settings as empirical choices. Learning rate schedules matter because a larger step size can speed early progress, while later decay helps settle into finer solutions once the model is near a good region.10
But he is also explicit that casual choices are not enough for real work. If you want production-quality training, you should expose optimization settings as hyperparameters and run many experiments to discover what actually works, rather than trusting ad hoc defaults.11
He also watches the gap between training and validation. When they begin to separate, that is a sign to think about model capacity, regularization, or whether continued fitting is helping generalization.11

“Actually, have confidence that our learning rate is set very well, that our learning rate decay, which we just do at random, is set very well. And, um, so the optimization here is kind of suspect, to be honest, and this is not how you would do it typically in production. In production, you would create parameters or hyperparameters out of all these settings, and then you would run lots of experiments and see whichever ones are working well for you. Okay. So we have 2.17 now and 2.2. Okay. So you see how the training and the validation performance are starting to slightly, slowly depart. So maybe we're getting the sense that the neural net is getting good enough or that number of parameters is large.”Building makemore Part 2: MLP, online lecture, 2020 · full transcript →
Better models often come from better representations and better data
Karpathy’s training advice is not just about optimizers. He shows that some approaches fail because the representation does not scale: simple count tables blow up combinatorially as context grows, while learned embeddings let models share statistical strength across similar inputs and generalize beyond memorized counts.12
That same idea expands into his broader Software 2.0 view. In learned systems, the optimization writes the behavior into the weights, but the dataset strongly determines what gets written, which is why he treats the dataset as a form of code.1415
This is also why labeling and curation are central to training quality. If the dataset encodes the system’s behavior, then the people and processes shaping labels are effectively programming the model by determining what optimization is allowed to learn.1718
At scale, training becomes a systems problem
Karpathy is unusually concrete about the operational side of training. Large training jobs are expensive, involve many outputs and constraints, and must be repeated continuously without regressions, so training is not a one-off act but an ongoing engineering loop.19
That systems view includes checkpointing correctly. Saving weights alone is not always enough; to resume optimization faithfully, you also need optimizer state and care around randomness, otherwise the resumed run is not truly the same training process.20
He also points to infrastructure and efficiency improvements as part of model training itself. Kernel-level speedups, training clusters, and custom hardware all matter because they change how many experiments you can afford and how quickly you can iterate.2219

“Because remember that the optimizer has a few additional buffers because of ADAM, so it's got the m and v, and, uh, you need to also resume the optimizer properly. You have to be careful with your RNG seeds, uh, random number generators, and so on. So if you wanted to exactly be able to resume optimization, you have to think through the state of the training process. But if you just want to save the model, this is how you would do it. And one, one nice reason why you might want to do this is because you may want to evaluate the model a lot more carefully. So here we are only kind of like winging the hell swag eval, but you may want to use something, um, nicer like, for example, the Luther, uh, Luther evaluation hardness.”OpenAI / online talk, 2022-11 · full transcript →
Karpathy on model training, in his own words
“Because remember that the optimizer has a few additional buffers because of ADAM, so it's got the m and v, and, uh, you need to also resume the optimizer properly. You have to be careful with your RNG seeds, uh, random number generators, and so on. So if you wanted to exactly be able to resume optimization, you have to think through the state of the training process. But if you just want to save the model, this is how you would do it. And one, one nice reason why you might want to do this is because you may want to evaluate the model a lot more carefully. So here we are only kind of like winging the hell swag eval, but you may want to use something, um, nicer like, for example, the Luther, uh, Luther evaluation hardness.”
Where to watch
Andrej Karpathy on Activations & Gradients: BatchNorm2021 · 116 min · full transcriptBest practical walkthrough of initialization, logits, saturated activations, gradients, and why training can fail early.
Andrej Karpathy on Neural Networks: Building Micrograd2021 · 146 min · full transcriptBest foundation for understanding backpropagation, gradients, and why training is just optimization on a mathematical expression.
Andrej Karpathy on Software 2.0: Data Is the New Code2018 · 55 min · full transcriptBest statement of why data curation and labeling are central parts of training, especially in real deployed systems.
Andrej Karpathy on GPT-2 Reproduction: Rebuilding 124M From Scratch2022 · 241 min · full transcriptBest look at training realism for larger Transformer models, including matching checkpoints and careful resume state.
Andrej Karpathy on MLPs for Language Modeling: makemore2020 · 76 min · full transcriptBest small-scale example of hyperparameter tuning, embeddings, validation behavior, and practical language-model training.
Andrej Karpathy on PyTorch at Tesla2018 · 11 min · full transcriptBest sense of what training looks like when it becomes a large, iterative systems and infrastructure problem.
Questions people ask
- How expensive is it to train Andrej Karpathy's Autopilot networks at Tesla?
- What did Andrej Karpathy say about overfitting and hyperparameter tuning?
- What did Andrej Karpathy say changes when you move from bigram models to transformers?
- What initialization loss did Andrej Karpathy expect for a character-level language model?
- What is micrograd and why did Andrej Karpathy build it?
- What did Andrej Karpathy say about checkpointing and resuming training during GPT-2 reproduction?
Sources
Every quote above, word for word from the transcripts. Numbers match the text.
“Even neural networks are just a mathematical expression.”
“Micrograd is basically an autograd engine. Autograd is short for automatic gradient, and really what it does is it implements backpropagation. Now, backpropagation is this algorithm that allows you to efficiently evaluate the gradient of some kind of a loss function with respect to the weights of a neural network, and what that allows us to do then is we can iteratively tune the weights of that neural network to minimize the loss function and therefore improve the accuracy of the network. So backpropagation would be at the mathematical core of any modern deep neural network library, like say PyTorch or JAX. So the functionality of micrograd is, I think, best illustrated by an example, so…”
“None of this will fundamentally change. The only thing that will change is the way we do the forward pass where we take in some previous characters and calculate the logits for the next character in a sequence. That will become more complex, and, uh, but we'll use the same machinery to optimize it. And, um, it's not obvious how we would have extended this bigram approach into the case where there are many more characters at the input because eventually these tables would get way too large because there's way too many combinations of what previous characters, uh, could be.”
“…we can actually match the 124 million parameter checkpoints of GPT-2…”
“At initialization, we have no reason to believe any characters to be much more likely than others, and so we'd expect that the probability distribution that comes out initially is a uniform distribution assigning about equal probability to all the 27 characters. So basically, what we'd like is the probability for any character would be roughly 1 over 27. That is the probability we should record, and then the loss is the negative log probability. So let's wrap this in a tensor and then we can take the log of it, and then the negative log probability is the loss we would expect, which is 3.29, much, much lower than 27.”
“You'll notice that in the update here, the learning rate is scaled as a function of number of iterations, and it shrinks. This is something called learning rate decay. So, in the beginning, you have a high learning rate, and as the network sort of stabilizes near the end, you bring down the learning rate to get some of the fine details in the end. And in the end, we see the decision surface of the neural net, and we see that it learns to separate out the red and the blue area based on the data points.”
“Actually, have confidence that our learning rate is set very well, that our learning rate decay, which we just do at random, is set very well. And, um, so the optimization here is kind of suspect, to be honest, and this is not how you would do it typically in production. In production, you would create parameters or hyperparameters out of all these settings, and then you would run lots of experiments and see whichever ones are working well for you. Okay. So we have 2.17 now and 2.2. Okay. So you see how the training and the validation performance are starting to slightly, slowly depart. So maybe we're getting the sense that the neural net is getting good enough or that number of parameters is large.”
“That the predictions from this model are not very good because you only take one character of context. So the model didn't produce very name-like sounding things. Now, the problem with this approach, though, is that if we are to take more context into account when predicting the next character in the sequence, things quickly blow up, and this table—the size of this table—grows, and in fact it grows exponentially with the length of the context. Because if we only take a single character at a time, that's 27 possibilities of context. But if we take two characters in the past and try to predict the third one, suddenly the number of rows in this matrix, you can look at it that way, is 27 * 27. So there's 729 possibilities for what could have come in the context.”
“The optimization really writes the code; we only identify a region where we should search.”
“…your data set is really the code.”
“…the labelers are kind of the programmers…”
“…this is a whole new way of designing software and we need tooling for it.”
“But all in all, if you're trying to train all of the neural networks for the autopilot, it is actually a fairly expensive task. In particular, today we would train 48 different networks that make 1,000 different predictions—just if you count the number of output tensors—and it takes 70,000 GPU hours to train to compile the autopilot. It leaves the neural network stack. So if you had a single node with 8 GPUs, you would be training for a year. So it's a lot of networks and a lot of predictions, and a lot of them must work and none of them can regress ever. And then you're not just training this once—you have to iterate on this.”
“Because remember that the optimizer has a few additional buffers because of ADAM, so it's got the m and v, and, uh, you need to also resume the optimizer properly. You have to be careful with your RNG seeds, uh, random number generators, and so on. So if you wanted to exactly be able to resume optimization, you have to think through the state of the training process. But if you just want to save the model, this is how you would do it. And one, one nice reason why you might want to do this is because you may want to evaluate the model a lot more carefully. So here we are only kind of like winging the hell swag eval, but you may want to use something, um, nicer like, for example, the Luther, uh, Luther evaluation hardness.”
“As you'll notice here on the bottom, we have a GPU cluster. The hardware team is also working on a project we call Dojo. And a Dojo is a neural network training computer and a chip. And so we hope to do the exact same thing for training as we did for inference: improve basically the efficiency by roughly an order of magnitude at a lower cost. But I'm not ready to talk about more details in that project just yet. So in summary, I talked about the full lifecycle of developing these neural hours for the autopilot and how we own everything in-house.”
How this guide was made: drafted with AI from the full transcripts of the recordings cited, then checked: every quotation must match a transcript word for word and be the speaker's own words, and an independent review gates accuracy. Methodology and corrections.



