Reasoning and Search with Deep Nets
Transcript
So now we're going to talk about something related to agents, really, which is reasoning and search with deep nets. The common theme here is, again, we're building up that tech stack, that once you have really powerful foundation models and large language models and generative AI, then what can you do on top of that? What can those systems support? How can you build that into something that will start to do multi-step inference and analysis of data? And it might be an agent or something that looks agentic that's doing that. But it also could be a more kind of classical algorithm that's just going to do what we might call search, like a search tree, for example. And that's what we'll talk about in this lecture. And the kind of payoff of this lecture is I'm going to tell you how these models that you've probably seen in some headlines recently work. So if you saw this big thing about deep seek, this new model from a lab in China has made the headlines yesterday.
And I'll tell you how that works. And there's another model called 01 and another one called 03. These are the latest, greatest models from OpenAI. This will be how those work as well. So this is bringing us right up to the very current thing that's happening. OK cool. So what has changed in the last five years of AI? So, suppose you have a question that you want an AI to answer. We have our chatbots that can answer. We had them in 2020 as well, some earlier versions.
One was called GPT3 in 2020. And essentially, these language models in 2020, what they would do is they would give you not the correct answer to your question, but they would give you what a random person on the internet might say in response to your question. That's how they're trained, right? I think Ewan talked about this earlier, that large language models, you download a big corpus of data, usually a lot of websites, a lot of text on the internet. And they're trained just to predict what would somebody say next. What would the next word be on that internet? So they give you a random answer where random means a random person, how they would reply on the internet. OK, but AI in 2025 is quite different. Instead, it gives you a good answer, not a random answer. And by good, we mean it might be the correct answer or an accurate answer, an unbiased answer, or a fair answer, good in certain ways. Now, it's not perfect, but it's better than it was in 2020.
So what made the difference? And this lecture is about the technology that made that difference that went from 2020 to 2025. OK, so in particular in this lecture, I'll talk about two different paradigms. One is called learning. That's what we've seen mostly so far, although Antonio's talk definitely got a little bit into the more reasoning and agentic style of things. And learning is about learning-- or it's about finding or estimating the distribution of your data.
From examples of how people talk online, come up with a model of how people talk online, a model of the distribution of all the different ways that they could talk, so the distribution of random answers that are randomly sampled person might give. So today now, we're going to talk about reasoning, which is trying to find not the distribution or random answer but the best answer. OK, so that's the key difference. OK, so here's kind of a chart of my own kind of mental map of learning versus reasoning and all the subcomponents in this space. There's a lot of different ways of parsing this. A lot of you might have different backgrounds, from different fields. These words are highly, highly overloaded. So don't think that they have a precise definition. They do not. OK, so the word inference, for example, in statistics means what in my language in most of kind of modern machine learning language is referred to as learning.
So going from data to a model of the data, statisticians might call that statistical inference. I would call that machine learning. Other people might call that amortized inference. So there's different names for the same thing. So it's really a little tricky to get around these naming issues. There's a lot of conflicts and debates in the field about people just using the same word to mean two different things and thinking they're talking about two different things, but they're not. So try to get below the surface. I can give some synonyms here. So learning goes from a data like the internet to a model of the internet, a model of the distribution of data. And this is really related to what Chi Ming talked about with generative modeling being trying to fit the-- identify or fit a distribution to data. From finite samples, find the distribution that explains all the samples. OK, reasoning on the other side is there's different ways again
of characterizing this, but I'll characterize it as going from a distribution or model to a decision or a prediction. So now that I have all the random things somebody might say online, can I find the best thing they said, what an expert would say, what is actually correct? OK, and reasoning might go under different names-- inference prediction, thinking cognition control. These are all related to reasoning. But the spectrum is essentially, now in modern systems, being broken down pretty clearly into the different phases of training a model. So we have the pre-training phase. This is the fitting the language model to predict the next word in your corpus that you mostly talked about. And then you have what's called the post-training phase. And now at companies, there's these teams that call themselves post-training or mid-training or retrain. Like, they just start having different phases of training. But basically, there's a gray area.
I'll talk about that in a minute. And at the other end of the spectrum is the kind of reasoning or deployment phase, which I'll also refer to as search. I'm using a lot of different terminology here, but they all link together. OK, so pre-training mean is usually generative modeling or representation learning where you have a lot of data. You train a base model to just model the data, predict the next token given the previous tokens. Now that gives you this base model of the internet if you're training a chatbot. OK, then you can do some adaptation in the middle. But at the other end of the spectrum is how are you going to actually use this in practice. So when you deploy this on your phone and you ask your phone a question, what's the weather today, and tell me where I should go, have a picnic, it will do something. And up until 2020 or so, the thing that it would do in deep learning was very, very simple. It would do just a forward pass through
this autoregressive model. So it would do a forward pass, predict the next token, sample that token, repeat. And that was all it did. That was the deployment phase. The search was this really, really simple greedy process OK, but now-- well, I'm exaggerating. Like, 2020, of course, people had other ideas too, but that was roughly how these systems worked. Now they work a little bit differently, and that's starting to change. OK, now we can instead take our system at test time, at deployment time, and query it multiple times and try to say, here's the 10 different answers we would give. Now, can I pick the best of those 10 answers somehow or ensemble the answers and come up with a better prediction? And then in between there's all these other phases which are kind of a blur-- there's a blurry line between this pre-training, the base model, and at deployment time, searching and reasoning on top of it. And those include methods like taking a model and updating it,
so transfer learning and fine tuning. Or at deployment time, you can also update the model. You can say do these things like in-context learning, where at deployment time, you provide some context to help guide what the model will do. So the model's behavior is being manipulated and updated by that context. But that context is provided at test time, not at training time. So this is the pipeline. There's teams of these companies pre-trained the base model, fine tune the base model to be better on the type of data you care about, and then deploy it and let users prompt and add context and do continual updates at test time and, finally, do classical search algorithms on the very top. OK, so we're mostly going to focus on this very top part. And then there's this interesting connection that comes in, which is that there's something called reinforcement learning down here. So what is reinforcement learning? Reinforcement learning is updating
the model, changing kind of the learning process, by doing search. So you're going to search for good solutions. If you find a good solution, you will update the model to do that thing that was good. You get a reward for finding a good solution, so you should do more things that are like that good solution. So we'll talk about that at the end. OK, so I think there's this very important essay in AI from a few years ago called The Bitter Lesson, many of you might have heard of it, which says
that for all our cleverness, most of the AI methods that have driven progress have come down to simple methods that scale well. And that's really been one of the dominant stories of the last decade or so of AI is these kind of scaling laws, like, come up with a simple method that can absorb data and compute to do better and better and don't try to overengineer or be too clever about how you do it. And what Rich Sutton, who wrote this essay, pointed out is that there's two simple algorithms that seem to scale arbitrarily in this way. And one was learning, and that was kind of the story of the last-- decade deep learning and making bigger networks trained on more data. But he actually mentioned this other one, search. And so he already identified that 10 years ago or 5 years ago as being the other big component, and it's just in the last year or so that it's become a big component in kind of deployed systems that we're all starting to use.
OK, here's a blog post from OpenAI from about six months ago on their 01 model, and they were just pointing out Rich Sutton's bitter lesson. Again they were saying there's kind of two scaling laws that they've identified. One is the learning scaling law. So train on more data, you get better performance. And the other is the search scaling law, which is, at test time, do more thinking, more inference at test time, and you'll get better performance. So the first is training time compute, and the second is test time compute. The first goes under the name learning, the second goes under the name search. OK, so what is search? OK, so search is basically the more classical approach to AI, which we used to do before machine learning became dominant. So, search can be used to describe how Deep Blue the IBM chess playing computer, worked. What it did is it would look forward over the tree of all the possible moves that could make. So it could say, if I move my pawn up,
then Garry Kasparov, who I'm playing against, might do this. And if he does that, then I'll do this. If he does that, I'll do this. If he does that, I'll do this. You keep going, right? And you do that for all possible paths through the game. And then at the end you find, OK, this set of moves will guarantee a victory by doing that search, or it will make it likely that I have a victory. OK, so that's how Deep Blue works. There wasn't really any deep net involved. There wasn't any learning per se involved. It was just-- it would expand the game tree of all possibilities some number of steps into the future and pick the best initial move along that tree. OK, that worked. That beat Garry Kasparov. Search was also a huge component in other game playing landmarks in AI, like AlphaGo. So AlphaGo actually had both the learning and the search components. But the search was this tree search, again, where you kind of do exactly what Deep Blue was doing.
You kind of imagine all the possible moves that you could make and all the opponents' responses. And then once you get to the-- you search a few steps ahead. But once you get to the-- oh, there we go. OK. Once you get to a leaf of that search tree, then you have a neural net that looks at that leaf and says, is it good or bad? So you combine this neural net with this search tree. So already, people were thinking about combining search and learning back then. OK, so let's introduce a few equations. I won't make it too technical, but we're going to have a little bit of math. So what I mean by learning, I already told you. It's fitting a distribution to data.
But in particular, we usually think of it as fitting a probability model p that will say I'm going to have learned that my data can be well-explained as samples from probability model p over x's and y's. I'll think of y's as being the kind of outputs and x's as being the inputs to my system. OK, so inference is saying now, once I have that model, I'm going to observe some input x, and I want to not output just what's the probability of y or make a random prediction. I want to take the max.
I want to say what is the most probable y given x. OK, so this argmax is inference or search. So search more generally might be taking a scoring function. It doesn't have to be a normalized probability. It could be any kind of score function that just says-- it's a scaler that says how good is this xy combination. And then take an observation x and try to find the y that will make that score the highest. That's the general idea of search. And this maximization, taking the max, that is the search. That's looking for that max of that distribution or that score. OK, so let's see a few methods that people use in practice right now. I'll talk about best of n, beam search, and chain of thought. OK, so again, reminder about Yun's lecture-- we have autoregressive language models. And what those do is they just predict the next word in a sequence. OK, so once upon, and then we will make a prediction.
We'll actually get a whole set of possibilities. We'll say it could be once upon the lake, but no. Instead we're going to say it's once upon a. It's more probable that it's a. So we'll sample that, and we'll keep on repeating. So this is how autoregressive models generate language. OK, and so, yeah, right. We don't want to just tell a random story. We want to find the argmax, the best story, or the most probable answer to my query. And the observation here is that the underlying probability model of autoregressive models is this-- the joint distribution of all the words in some kind answer to a query is equal to the product of the probability of the first word times the probability of the second word given the previous word times the probability of the next word given all the previous words. That's the underlying probability model behind autoregressive large language models. And if you want to find the best configuration, so you want to find the answer to your question
x, which is the best set of words to answer that question, so the argmax of that distribution mean, meaning let's say I'm trying to model expert data here. So I really want to find what is the most likely thing the expert would say. That does not equal the argmax of each of these individual terms. OK, so the best configuration, the most likely-- according to a probability model, the most likely output is not the same as what you'd get if you just do this autoregressive greedy sampling where you just take the argmax of what's the best first word in the sentence and the argmax of the next word in the sentence and so forth. So this way that we usually in 2020 would decode from a language model is just a crummy way of maximizing the probability. And we have better ways of doing it. OK, so one of the better ways turns out to be extremely simple. It's called best of n sampling. And this just says run your language model n times.
And it will give you n different sentences or answers to your query. If it's like, you ask it a question, it gives you n different answers. And you just simply evaluate under the probability model that is given by the autoregressive model which one is the most likely. And you say that that's the best. OK, so let me just make it-- so here, we have the x's and the y's again. The x is meant to be like your question. The y is the answer. So I ask a question, I want to find the best answer.
I want to find the most probable answer. I can evaluate the probability of any string. But how do I generate the string that maximizes that probability? I can't just sample the argmax step by step. Instead, I will sample n sequences, evaluate the probability of these n sequences, and take the best. OK, so I'll sample-- let's say my question is what is coffee. So the answer might be a stimulant that enhances cognitive function, and the model will say that has 0.7 probability.
It might be a stimulant that improves thinking, 0.5 probability. A chemical that makes you feel more awake, 0.8 probability under some probability model, this autoregressive model that's been fit to data. And so I will say that this is the sentence I'll have sampled three times, and the best of the three samples will be this one. And that's the one that I can output. OK, so this is a very simple search procedure through an autoregressive model. We can also do something a little bit more sophisticated, which is called tree search, and a particular variant called beam search. And that is we're not going to just search for three independent different strings, but we will construct our search in a tree fashion, kind of AlphaGo or Deep Blue. So what we'll do is we'll first take the-- sorry. We will first take the first word, and then we'll say there's the language model, the autoregressive model, says there's two likely next words.
And given if I go up this branch, the next words that are likely are these two words. But I'm not going to just take the best one. I'll expand this tree of possibilities. And then once I've expanded the tree to some depth, I can look at which path through the tree has the highest probability according to the probability model. OK, so that's kind of Deep blue looking through the game tree and saying which path through the tree led to me winning. And in this case, a mild stimulant was the best one. OK, sample multiple sequences and pick the sequence with highest likelihood at the end and sample them in this tree structured fashion, expanding the tree only on the high likelihood paths.
OK, so then a really interesting thing happened, which is that, yeah, people kind of thought we need to have these search algorithms in order to decode from these powerful models and make them better. But the bitter lesson of machine learning comes back again in multiple ways. It says, well, maybe we can't be too-- maybe humans are not clever enough to come up with the right search algorithm. So what if we could just ask the model to do search? Maybe somehow from the data on the internet, there are enough examples of search-like behavior that the model has internalized a representation of what it would mean to intelligently solve a search problem? And then rather than explicitly ask coding that will do tree search through the model, we can just tell the model, hey, I want you to do tree search, and maybe it will just work because it's been fit to data that exemplifies tree search. And this is the big discovery that went under the name Chain of Thought from a few years ago.
It says that if I just ask the model-- like, let's say I want to solve the problem what is 4 times 5 plus 10. If I ask the model to do that, it might make the wrong answer. It might get a bad sample of what a random person online would say. But if instead, I say, I want you to think really hard-- and I can in particular here say, I want you to use beam search. So we know how to do beam search over this model. But we just tell it, just prompt it, hey, I want you to do beam search. It turns out, it knows what beam search is, and the dot dot dot here indicates that this is the ChatGPT model. And there's a whole sequence of thoughts before it gets to this point. But I just cropped it. And it basically says, oh, OK, you want me to do beam search? So the way I would do that is first I'd break the problem into these two parts, and then I'd make a search tree, and then I'd go da da da da da. And it actually writes out that whole procedure.
It is doing beam search in its natural language output. So it's kind of an emergent or learned version of beam search. And it doesn't have to be beam search. I could ask it to do best event search. I could ask it to do Monte Carlo tree search. I could ask it all these things. It will know something about those. Your mileage will vary because it only knows whatever existed in its training data on the internet. But this kind of works. And in fact, you can even just ask it, hey, I want you to solve this problem. I'm not going to tell you how, but I want you to think really hard and think really long about it. The famous line was you prompt the model with let's think step by step, and then it just starts doing this emergent reasoning process that doesn't have a name. It's not beam search. It's not tree search. It's whatever kind emergent thing it associates with the phrase let's think step by step. And sometimes, that might even outperform
classical known search algorithms. OK, so this emergent search, the trade off here is it can be more powerful than what humans-- and more clever than what humans were able to discover by their own theory. But it doesn't have the same guarantees we have on classical algorithms where we've proven things about them and we really know how they work. This is just the model discovered its own stuff, and we're using methods like Antonio's interpretability methods to try to understand is the model actually reasoning correctly or incorrectly. We don't really know. That's an ongoing part of science. We're just-- it's like an alien creature that has discovered something that humans don't know how to fully characterize. So that's the trade off. This is a little bit less safe, less robust, but can potentially be more powerful. OK, so the really cool thing about this search perspective is you don't just have to stick with probability as the thing you care about.
You don't just have to say, I want to find the argmax of the data distribution. You can actually search for strings that maximize other functions. Any kind of scalar reward function that looks at a string and says, is it good or bad, you can optimize that with search. OK, so here's a case. Let's say I want to say give me a description of caffeine, but I don't want you to output what the internet thinks is the most likely description. I want you to output what some model of funness thinks is the most fun statement. Let's just say I have-- It doesn't matter what the score is. The score is just something that takes a string as input and outputs a number, a scalar, a score. And there's a lot of these. It could be a cat versus dog classifier. In this case. I'm just saying we have trained some other model that will say, how fun does this sound, right? So it says, no, that's not very fun. Nature's tiny cheerleader jumping into your bloodstream with pom poms, OK?
I asked a language model to make that for me. I didn't come up with that. And that's more fun. And then maybe emojis are the best. And so that the thing that optimizes the funs is the set of emojis and I can do best event sampling, sample n different possibilities, and then say, oh, the best one with the highest score is this one. OK, I could do scientific accuracy, maybe I have a model of what would somebody in a journal paper, how would they describe this? If I have a verifier or a score function that can measure how scientifically accurate this statement is, then maybe you'll get a different answer that maximizes that function. And in particular, the scores that are really working well right now, we don't quite have great scores for scientific accuracy or for funness, but we do have really, really good scores for formal languages and proofs. So for math and for programming, we have what are called verifiers.
So a verifier is something-- like in math, it would be a proof checker. So it's very hard to prove a theorem, but it's often very easy to check that a proof is correct. You probably did this in math classes. You probably read a theorem, and you're like, oh, I can check that's correct. But how did they come up with it? It's impossible. Or you have to be really smart. In programming, we have the same thing. It might be really hard to write a function to output the Fibonacci-- I mean, this isn't a hard one, but this is just an example. It might be somewhat challenging to come up with a function that outputs the Fibonacci sequence. But maybe you can check the Fibonacci sequence quite easily by just checking if each next number is equal to the sum of the previous two numbers. OK, so write me a Python code to compute the Fibonacci sequence. The way that the verifier will work is the LLM will output two possibilities where n different possibilities--
it could be best of n sampling-- one of them turns out to compile and be correct. And I have a verifier which will check the syntax right. We know how to check syntax for code. That's what compilers do. They'll throw syntax error, and then I'll say, that was incorrect. Or maybe it's a logic error, and the verifier could check the logic. It could be a proof checker or a formal verification system. And this one turns out to be the wrong code, and this is the right code. And so I'll simply select this. I'll put a box around that. And my model when I query it online, when I talk to Gemini or ChatGPT or any of these things, this is what the latest systems are doing under the hood. They're trying multiple completions, multiple-- if I ask it to code for me, it will try multiple things. It will check which one is correct. So different systems work in different ways, but this is one of the ways that some systems work. OK, the key idea here, actually, if you
have a background in CS theory, you might remember that there's this fundamental idea that for a lot of problems, verification is fundamentally easier than generation. So there's this class of problems, the NP class of problems, where they are efficient to verify, but people think they're not efficient to generate the solution. So you can solve a problem like the traveling salesman problem. I can solve that, but it's really hard. It might take exponential time to find this path
through all the cities to maximize my profits as a salesman. But once I have found the path, checking it is really easy. I can do that in what's called polynomial time. OK, so verification is fundamentally easier than generation for a lot of problems, and whenever that's the case, then this strategy is a good idea. You use a verifier to guide the generation. OK, I'm not going to fully explain this. This is a snippet from a paper. But I've given all these examples of language models that are autoregressive, outputting the next character or the next token given the previous ones. But I want to mention that all the other generative models or many of the other generative models that are popular today, like diffusion models and VAEs, you can do similar things with. If I have a diffusion model, which is what this diagram is showing, I can do the same search procedures but not through the autoregressive sequence of words, but through the denoising steps.
Did Kaiming talk about diffusion models? Somebody? Yeah, he did. So you saw that. And it's like in diffusion models, you start with a noisy image, and you make it less and less noisy. But you normally do that by this-- just like in autoregressive models, in 2020, you did that by just kind of greedily remove-- estimate how to remove the noise and just make that decision and then estimate how to remove more noise and make that decision. But instead, you could search over all the different paths through this denoising space and find the best path that will lead to the most likely output. And so you can do these same types of search with diffusion models just like you can with autoregressive models. So don't worry if you're more of an image processing person. The same ideas apply. Most of them were developed first in autoregressive language models. Oh, and sorry. Here's the paper if you're interested in reading more about that.
OK, so, so far, I've only talked about discrete search because I was focusing on language models, which are discrete models. But you can often also do continuous search. So what is continuous search? I'll give just-- I'll give an example from some of my work from a few years ago. So this is going to be an example of trying to take a continuous model which maps from some underlying latent variables z to imagery. And then we will take the output. So everything is continuous here.
Pixels are continuous valued-- it's a continuous valued function. So the nice thing about continuous valued functions and variables is I can do my search not by looking over, like, discrete trees of possibilities and what we might really want to call reasoning and thinking but instead just with gradient descent. So it turns out that search with continuous models can be done with just the same old vanilla machinery that we used for a lot of deep learning, which is gradient descent. OK, so here's my image generation process. And then I'll take that output, and I'll put it into a model of a human's preferences. So I have a model of a human. This is another continuous function I'll get a score. And so I'm just going to try to change the latent variables, the input to my generative model, to make an image that humans like, in some sense, or that optimizes human preferences. So this is related to what's now become famous as reinforcement learning from human feedback.
But I'm going to show you an application, a slightly different application, which was not trying to make an image which humans give an upvote to or downvote to. But instead, we're going to have a model of human memory. And we had this model of human memory because some years ago we ran these experiments where we would see what images people tend to remember and what images people tend to forget. And we ran these psychophysical experiments. So people watched online sequences of images. And now and then, they would repeat. And when they would repeat, the person was instructed to press a key. And we found that some images were just really, really easy to recognize when they repeated this way. So we called them very memorable. In fact, this guy, right? I'm sorry to show you this photo, because you're never going to be able to get out of your head. This is the most memorable photo that we ever found. So you should remember that photo. Come back in a year and we can chat.
OK, so here are some memorable photos. Here's the most memorable guy, and here are some forgettable photos. It turned out that people, everybody just remembers people. That was the main conclusion of this work. OK, but we revisited this in this Kind of-- can we do search over the variables in a generative model to optimize memorability, to see what it looks like for an image to become more memorable? OK, so we're just going to manipulate my generative model to make outputs that a model of memorability will think causes the image to be memorable. This is work with Laura and Alex. OK, so here is an input photo, and here's the model. The details don't matter too much, but basically, we tried to manipulate the inputs that control the appearance of the image so that the generative model called BigGAN here would output something that a neural net, which was called MemNet, a memorability assessor here, would think is memorable.
So we simply would find how to tune this model to make more memorable images. And if we tune it up, the dog zooms in and becomes really cute. And if we tune it down, it becomes kind of blurry and hard to recognize and is predicted to be less memorable. You can run this in a new psychophysical experiment and find out that indeed, people remember this photo a lot better than that photo. OK, you can do this for aesthetics or emotional valence or other-- whatever type of human perception or score function you want. And that's kind of the point is once you have a good generative model, you can search the model to produce images or sentences that maximize whatever score function you want. So here's just some more fun examples. Here's the original images. And then this is making them less memorable, more memorable. The snake becomes kind of like a perfect circle when it's more memorable. This is making it less aesthetic, more aesthetic. So the dog-- the saturation goes way up.
It's related to memorability but not identical. And this is emotional valence. This is like a sad dog and a happy dog. So you can kind of get a probe into human perception. That was how we pitched the paper back in 2019. But now more recently, this type of technology is very commonly used in language models under the name RLHF for optimizing toward what sentences, what answers humans would find positive or negative. OK, so you can do continuous search by gradient descent if you have a continuous model. Another thing you can do is what I told you about, chain of thought. And what is chain of thought? It's like emergent search. It's just ask for search. So chain of thought is like just ask for symbolic search. Hey, let's think step by step. Hey, I want you to do reasoning. I want you to do tree search. You can just ask the model to do that. And if the data distribution exemplifies that type of thinking, it will know how to do that.
If the data distribution does not exemplify that kind of thinking, then it might not. Could we just ask for continuous reward? Can we just ask-- just do gradient descent to optimize for human preferences? OK, so here's just a-- this is not really a formal experiment, just a kind of fun playing around with some of these models a few years ago. So here, I'm just-- I'm asking for a painting of a waterfall, and it's OK, right? But let's say-- can I just ask it to be a higher reward painting? So I'm going to say no, no, I don't want to say higher reward. Maybe it doesn't know how to interpret that, but I'll just say I want a beautiful painting of a waterfall. It's a little more beautiful. OK, what if I say I want a very beautiful? OK, I'm asking it for an even higher reward. It's a little more beautiful. What if I want a very, very? It's starting to get pretty good. A very, very, very, very, very, very beautiful painting of a waterfall. This is like 20 varies now.
And that was about the max that it got to. So people have continued to play with things like this. There's a fun kind of meme one of these, which is called make it more. You just-- you take an image, and you say, make it more. And then it will just, like, exaggerate the things in the image. You can just repeat this process. It's like, just asking it to do this reward optimization or beauty optimization in this particular case. OK, so the last section of this talk will be on reinforcement learning. OK, reinforcement learning is a huge field. So I'm not going to do everything. But I just want to give you the gist of it. So what is reinforcement learning in the context of reasoning and language models and modern AI? I think of it like this. I think it's using search to feed back into training. So remember, we had the verifier that checks if my program is syntactically correct and logically correct.
And that can help me to pick the correct output to my language model. But there was a problem with this verification approach, which is that I had to run the language model twice to rule out the bad, incorrect answer. And in general, I might have to run it many, many times to do search over all the possibilities of outputs to find the best one. So how can we make it so that it will just directly output the right answer and not have to run it many, many times during the deployment of the system? And so reinforcement learning does that. It first does search, right? So what is the idea of reinforcement learning? The basic idea is you try some random thing. If it works, you do it again. If it doesn't work, you move on and try a different random thing. That's the basic idea of reinforcement learning. So reinforcement learning is try some random thing and try a few different random things. So search for all the different random things that might be good or bad.
Find the one that's good and then reinforce that and remember the one that's good. So what is remembering or reinforcing the one that's good? That's training the model to preferentially output the one that was good. So you simply search for random different possibilities, try to find a good solution. Once you found a good one, you bake that back into the LLM's weights itself. You do training to preferentially output the good one and not the bad one directly. OK, so after you have found the good solution, you just do supervised learning. That's the learning phase of reinforcement learning is just supervised learning. You found a good behavior. You output the behaviors, output this correct code. And you simply supervise that whenever I see an x, my LLM should output the correct good behavior y. OK, so reinforcement learning is not that fancy. It's just adding some search, finding good solutions,
and then reinforcing them with basic supervised learning. Antonio also talked about this. He called it synthetic data. It's just a different name for the same thing. This is like good synthetic data that was generated by search. Again, you see that all the concepts are related. They just go under different names. Reinforcement learning, synthetic data-- to me, they're two names for the same thing OK, so using search to improve learning. But then you can also use learning to improve search. Once you've updated the model to make it more powerful and more directly output good solutions, then I can guide my tree search. I can guide my search process. It's going to be trying random things that are more likely to be correct, and that I can repeat and refine the process. OK, so this is making it a little closer to what you might have seen if you've ever taken a reinforcement learning class. It's usually applied to games, gameplay, and you have this game Mario.
I want to find the policy that will win the game. Mario. So I trained my network pi to output jump when I'm next to this tube here. OK, so reinforcement learning is search for random action sequences that lead to high reward and then train a network of policy that will tend to do those winning moves. And three, repeat-- guide the search process using the policy not to try random things now but to try things that it thought were pretty good and search intelligently. OK, that's like the beam search, right? We're expanding the tree not just in all directions but preferentially toward the things that we think are the right direction, the highest likelihood branches. OK. OK, so this reinforcement learning loop with search and learning-- search, learn, search, learn-- that loop has now become-- that's the big innovation in O1R1, this latest crop of models that are coming out. One of the papers that really popularized this is called star.
So it's an old idea, of course. Rich Sutton, he was writing about this in the 1980s or whenever. But the model that popularized this recently is called star. And so this is a diagram. I won't fully describe it, but basically, you have a question. The language model will generate an answer, but it will also generate like a chain of thought that led to that answer. And if the answer is correct, then I'll discard it. Ignore the hint part. That's kind of a detail. If the answer is-- sorry.

Ask anything
We've read this whole study set, so questions about it get the best answers.