Andrej Karpathy

AI researcher and educator: OpenAI founding member, former Tesla AI lead. On how LLMs work and the future of software.

12 topics · 132 distinct points

How LLMs work

2022–2026 · changed view

“Neural networks have done language modeling for a long time. So really what's new or interesting or exciting is just realizing that when you scale it up with a powerful enough neural net, Transformer, you have all these emergent properties, where basically what happens is if you have a large enough data set of text, you are in the task of predicting the next word, you are multitasking a huge amount of different kinds of problems. You are multitasking understanding of, you know, chemistry, physics, human nature. Lots of things are sort of clustered in that objective. It's a very simple objective, but actually you have to understand a lot about the world to make that prediction.”

Software 3.0 & the future of programming

2022–2026 · changed view

“Yeah, so I had a blog post on Software 2.0, I think several years ago now. And the reason I wrote that post is because I kept— I kind of saw something remarkable happening in like software development and how a lot of code was being transitioned to be written not in sort of like C++ and so on, but it's written in the weights of a neural net. Basically just saying that neural nets are taking over software, the realm of software, and taking more and more tasks. And at the time I think not many people understood this deeply enough, that this is a big deal, it's a big transition. Neural networks were seen as one of multiple classification algorithms you might use for your data set problem on Kaggle. Like, this is not that; this is a change in how we program computers. And I saw neural nets as, this is going to take over, the way we program computers is going to change, is not going to be people writing a software in C++ or something like that and directly programming the software. It's going to be accumulating training sets and data sets and crafting these objectives by which we train these neural nets, and at some point there's going to be a compilation process from the data sets and the objective and the architecture specification into the binary, which is really just the neural net, you know, weights and the forward pass of the neural net, and then you can deploy that binary.”

Learning & education

2022–2026 · changed view

“One more thing that I would say is that many times, when people think about education, they think more about what I would say is a softer component of diffusing knowledge. I have something very hard and technical in mind. In my mind, education is the very difficult technical process of building ramps to knowledge. In my mind, nanochat is a ramp to knowledge because it's very simple. It's the super simplified full-stack thing. If you give this artifact to someone and they look through it, they're learning a ton of stuff. It's giving you a lot of what I call eurekas per second, which is understanding per second. That's what I want, lots of eurekas per second. So to me, this is a technical problem of how do we build these ramps to knowledge. So I almost think of Eureka as maybe not that different from some of the frontier labs or some of the work that's going on there.”

AGI & AI timelines

2022–2026 · changed view

“The consistent thing I've been always interested in, for me at least, is AI, and that's probably where I'm spending my rest of my life on, because I just care about a lot. And I actually care about like many other problems as well, like say aging, which I basically view as disease, and I care about that as well, but I don't think it's a good idea to go after it specifically. I don't actually think that humans will be able to come up with the answer. I think the correct thing to do is to ignore those problems and you solve AI and then use that to solve everything else. And I think there's a chance that this will work; I think it's a very high chance. And that's kind of like the way I'm betting.”

Self-driving & robotics

2022–2026

“Yeah, the data engine is what I call the almost biological feeling like process by which you perfect the training sets for these neural networks. So because most of the programming now is in the level of these data sets, and make sure they're large, diverse and clean. Oh, basically you have a data set that you think is good, you train your neural net, you deploy it, and then you observe how well it's performing, and you're trying to always increase the quality of your data set. So you're trying to catch scenarios basically there are basically rare, and it is in these scenarios that the neural nets will typically struggle in, because they weren't told what to do in those rare cases in the data set. But now you can close the loop, because if you can now collect all those at scale, you can then feed them back into the reconstruction process I described and reconstruct the truth in those cases and add it to the data set. And so the whole thing ends up being like a staircase of improvement of perfecting your training set. And you have to go through deployments so that you can mine the parts that are not yet represented well in the data set. So your data set is basically imperfect, it needs to be diverse, it has pockets there are missing, and you need to pad out the pockets. You can sort of think of it that way.”

Using LLMs well

2025

“If it is the case that those tokens are not any more useful to your next query, I encourage you to do this, because these tokens in this window are expensive, and they're expensive in kind of like two ways. Number one, if you have lots of tokens here, then the model can actually find it a little bit distracting. So if this was a lot of tokens, the model might, this is kind of like the working memory of the model, the model might be distracted by all the tokens in the past when it is trying to sample tokens much later on. So it could be distracting and it could actually decrease the accuracy of the model and of its performance. And number two, the more tokens are in the window, the more expensive it is, by a little bit, not by too much but by a little bit, to sample the next token in the sequence. So your model is actually slightly slowing down, it's becoming more expensive to calculate the next token, and the more tokens there are here. And so think of the tokens in the context window as a precious resource. Think of that as the working memory of the model, and don't overload it with irrelevant information and keep it as short as you can, and you can expect that to work faster and slightly better.”

Research & building

2022–2026

“I wouldn't say that setting impossible goals exactly is a good idea, but I think setting very ambitious goals is a good idea. I think there's a— what I call sublinear scaling of difficulty, which means that 10x problems are not 10x hard. Usually 10x harder problem is like 2 or 3x harder to execute on. Because if you want to actually, like, if you want to improve the system by 10%, it costs some amount of work, and if you want to 10x improve the system, it doesn't cost, you know, 100x amount of the work. And it's because you fundamentally change the approach, and it— if you start with that constraint, then some approaches are obviously dumb and not going to work, and it forces you to reevaluate. And I think it's a very interesting way of approaching problem solving.”

Consciousness & the universe

2022–2025 · changed view

“And also like the origin of life didn't— was actually fairly fast after formation of Earth. If I remember correctly, just a few hundred million years or something like that after basically when it was possible, life actually arose. And so that makes me feel like that is not the constraint, that is not the limiting variable, and that life should actually be fairly common. And then it, you know, where the drop-offs are is very interesting to think about. I currently think that there's no major drop-offs basically, and so there should be quite a lot of life. And basically, what it— where that brings me to then is the only way to reconcile the fact that we haven't found anyone and so on is that we just can't— we can't see them, we can't observe them.”

Inside the Transformer

2023

“It is what we call a language model because it models the sequence of words or characters or tokens more generally, and it knows how sort of words follow each other in English language. And so from its perspective what it is doing is it is completing the sequence. So I give it the start of a sequence and it completes the sequence with the outcome. And so it's a language model in that sense.”

How LLMs are trained

2025

“In the task of predicting the next token in the sequence, the model has learned a lot about the world, and it has stored all that knowledge in the parameters of the network. So remember that our text looked like this, right, internet web pages, and now all of this is sort of compressed in the weights of the network. So you can think of these 405 billion parameters is a kind of compression of the internet. You can think of the 405 billion parameters is kind of like a zip file, but it's not a lossless compression, it's a lossy compression.”

Reinforcement learning and reasoning

2025

“We are not in a good position to create these token sequences for the LM, and they're useful by imitation to initialize the system, but we really want the LLM to discover the token sequences that work for it. We need to find, it needs to find for itself what token sequence reliably gets to the answer given the prompt, and it needs to discover that in the process of reinforcement learning and of trial and error.”

Neural network fundamentals

2022

“What are neural nets? Neural nets are these mathematical expressions, fairly simple mathematical expressions in the case of multi-layer perceptron, that take input as the data and they take input the weights and the parameters of the neural net. Mathematical expression for the forward pass followed by a loss function, and the loss function tries to measure the accuracy of the predictions, and usually the loss will be low when your predictions are matching your targets, or where the network is basically behaving well. So we we manipulate the loss function so that when the loss is low the network is doing what you want it to do on your problem, and then we backward the loss, use backpropagation to get the gradient, and then we know how to tune all the parameters to decrease the loss locally. But then we have to iterate that process many times in what's called the gradient descent. So we simply follow the gradient information and that minimizes the loss, and the loss is arranged so that when the loss is minimized the network is doing what you want it to do. And yeah, so we just have a blob of neural stuff and we can make it do arbitrary things, and that's what gives neural nets their power.”