What did Andrej Karpathy say about overfitting and hyperparameter tuning?
Andrej Karpathy said the optimization process here was still suspect and not how you would normally do it in production. In practice, he said you should expose these settings as hyperparameters, run lots of experiments, and choose whatever works best on the dev set. He noted that when training and validation performance start to diverge, it can be a sign the model is getting too powerful and beginning to overfit.
“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.”

Key takeaways
- Treat learning rate and decay as tunable hyperparameters, not magic constants.
- Watch train vs. validation loss for signs of overfitting.
- Use the dev set to select models; report test performance only once.
Context
In a 2020 online lecture on makemore, Karpathy is tuning an MLP for next-character prediction and discussing training curves. The quote above is taken word for word from the recording's transcript.
In the transcript
…the total loss over the training set is 2.3 and the test, or the dev set, is 2.38 as well. So, so far so good. Uh, let's try to now decrease the learning rate by a factor of 10 and train for another 50,000 iterations. We'd hope that we would be able to beat, uh, 2.32. But again, we're just kind of like doing this very haphazardly, so I don't
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.
Enough that we are slowly starting to overfit. Uh, let's maybe run one more iteration of this and see where we get. But yeah, basically, you would be running lots of experiments, and then you are slowly scrutinizing whichever ones give you the best dev performance. And then once you find all the, uh, hyperparameters that make your dev performance good, you take that model and you evaluate the test…
Read the full transcript of Building makemore Part 2: MLP, online lecture
Topics
What others said about productivity
More questions about Andrej Karpathy
- Why did Andrej Karpathy say bigram language models break down with more context?
- How does Andrej Karpathy sample from a trained language model?
- What did Andrej Karpathy say about how to use AI tools responsibly?
- What did Andrej Karpathy say about whether reasoning models can generalize beyond math and code?
- Why did Andrej Karpathy say the model he built is decoder-only?
- What is a neural network, according to Andrej Karpathy?
All Andrej Karpathy answers · All Andrej Karpathy recordings
How this answer was made: the quote is checked word for word against the transcript of the recording and confirmed as the speaker's own words; the summary above it was drafted with AI from that transcript and quality-checked. Methodology and corrections.