Stanford CS329A Self-Improving AI Agents | Part 5 | Planning and Multi-Step Reasoning
Overview
The lecture compares three approaches to multi-step reasoning: LATS uses Monte Carlo Tree Search to combine language-model reasoning, actions, environmental feedback, and reflection; SPRINT teaches models to identify independent reasoning steps and execute them in parallel; and SWiRL uses offline-generated, step-labeled trajectories to train multi-step tool use with reinforcement learning. Across HotPotQA, WebShop, MATH, and GSM8K, the methods show how test-time search, parallel execution, and process-level training can improve solutions or efficiency, while also exposing costs, task dependencies, and data-filtering tradeoffs.
Key takeaways
- LATS combines MCTS selection, action-outcome evaluation, simulation, backpropagation, and reflection to turn additional test-time compute into stronger multi-step solutions on HotPotQA and WebShop.
- LATS's state evaluation combines an LLM judge's 0-to-1 estimate with self-consistency based on action-sampling frequency, while UCT balances value and exploration through visit counts.
- SPRINT uses GPT-4o-annotated reasoning traces and dependency DAGs to teach DeepSeek-R1-Distill-Qwen-7B to expose independent plans for concurrent execution, reducing sequential generation while improving reported accuracy.
- SPRINT's speedups depend on available task parallelism: short traces offer little benefit, and long-running branches can become stragglers that delay later planning.
- SWiRL assigns rewards to proposed reasoning and tool-use steps using offline-generated trajectories, avoiding tool execution during reinforcement-learning updates.
- SWiRL's process-filtered training can outperform outcome-only filtering in RL and transfer between calculator-based GSM8K training and search-based HotPotQA evaluation.
Chapters
- Trip planning illustrates the three components: reason about constraints such as budget, act by browsing or searching, and revise plans using gathered information.
- The lecture frames a core limitation of language models as difficulty exploring diverse solution paths and optimizing a sequence of decisions.
- LATS applies ideas from reinforcement learning and Monte Carlo Tree Search to language-model reasoning and action trajectories.
- For a Hawaii trip prompt, LATS can sample actions such as asking friends or searching Reddit, score their outcomes, and expand promising branches.
- Multiple actions can run in parallel, while the search balances exploration of alternative plans with exploitation of high-scoring paths.
- Unlike Math-Shepherd, which uses a verifier to score reasoning traces, LATS evaluates action outcomes and incorporates environmental observations and model reflection.
- LATS extends ReAct with explicit planning, tree search, and reflection on prior trajectories.
- The maze example begins in a dimly lit room with left and right doors; selection chooses a node to expand using UCT.
- Expansion samples actions such as opening the left door, opening the right door, or inspecting the room, then executes them in the environment.
- Each action's observation is added to context, creating candidate states such as a dark corridor with paintings.
- Evaluation combines an LLM-as-a-Judge score from 0 to 1 with a self-consistency score based on how frequently an action was sampled.
- Simulation follows a selected branch until success, failure, or an expansion budget limit, as in the maze path that reaches a marked exit.
- UCT combines a state's value with an exploration term based on parent and child visit counts, encouraging less-visited branches.
- Backpropagation updates each visited state's value using the trajectory return and visit count.
- After an outcome, model-generated reflection records what led to success or failure and informs later search.
- On HotPotQA, which requires retrieval from at least two Wikipedia pages, more sampled trajectories improve performance, and reflection adds further gains.
- On WebShop product-search tasks, LATS achieves strong test-time results without fine-tuning, approaching human-expert performance in the reported example.
- The method converts additional test-time compute into better multi-step solutions, but tree expansion and backpropagation add substantial cost.
- The paper leaves open how to handle irreversible actions such as purchasing a service; discussion also notes that other exploration strategies could replace UCT.
- SPRINT starts from the observation that reasoning models such as DeepSeek-R1 often produce longer responses as their accuracy improves.
- Many reasoning steps are independent, including alternative approaches, decomposed subtasks, and verification, so sequential token generation can waste time.
- SPRINT trains a planner to produce plans and executors to carry them out in parallel, alternating planning and execution across multiple rounds.
- The goal is to reduce sequential inference time while retaining the benefits of extended reasoning.
- DeepSeek-R1 reasoning traces are decomposed into steps by GPT-4o, which labels planning text and execution text within each step.
- A model then identifies dependencies among steps and represents them as a directed acyclic graph, or DAG.
- Independent steps, such as steps 2 and 4 that both depend on step 1, can be packed for parallel execution.
- The resulting annotated traces are used for supervised fine-tuning so a model learns to emit explicit plan and execution tags.
- At inference, the fine-tuned model emits independent plans before waiting for their results, allowing executions such as Python calculations to run concurrently.
- The execution outputs are returned to the model's context, which then generates the next planning and execution stage.
- SPRINT's training recipe creates about 6,000 MATH reasoning trajectories, selects those with more parallelism, and fine-tunes DeepSeek-R1-Distill-Qwen-7B.
- The reported 7B model gains about 3.5 percentage points over its baseline and uses fewer sequential tokens than a 32B comparison model.
- Training on MATH also improves results on out-of-domain tasks such as Countdown and GPQA Diamond, despite no training on those benchmarks.
- The lecture reports sequential-token reductions of up to about 40% in some comparisons, with larger savings on problems that require more reasoning.
- Parallel branches represent different steps toward one solution, and the model must synthesize their results and resolve contradictions before answering.
- Task width, branch duration, and stragglers limit speedups; merging very small executions into larger chunks is one possible optimization.
- SPRINT still generates plans autoregressively; the speedup comes from parallel execution of independent plans, not parallel token prediction.
- Problems with short reasoning traces may offer little parallelism, while harder problems with more independent work can benefit more.
- A straggling branch can delay the next planning round, even though parallel execution avoids adding the runtimes of all branches.
- Potential extensions include reinforcement learning such as GRPO, broader tool overlap, and measuring realized wall-clock speed rather than token counts alone.
- SWiRL targets tasks such as multi-hop search, mathematics, software projects, trip planning, and data analysis, where errors can compound across steps.
- Its goals include teaching models when to call a tool, how to formulate queries, how to recover from errors, and when to stop and answer.
- To avoid slow or unreliable tools during training, the method creates trajectories offline by prompting a model iteratively with the original question and prior actions and observations.
- An LLM judge assigns step-level process scores, and trajectories can be filtered by process quality, final outcome, both, or neither.
- For an age-comparison question, the example trajectory searches for each person's age in separate steps, then produces a final answer.
- During reinforcement learning, the model proposes the next action given previous context, but the tool call is not executed again.
- The judge scores the proposed action, such as whether a search query is appropriate, rather than judging an unseen search result.
- SWiRL optimizes expected reward for each action conditioned on the preceding states and actions, using tool outputs collected during offline annotation.
- At inference, the model uses explicit tool-call and answer tags, receives a calculator result, and iteratively decides whether to continue or answer.
- Gemma 2 27B generates synthetic trajectories from HotPotQA and GSM8K; the study creates roughly 50,000 examples with different filtering strategies.
- Process-filtered data can outperform outcome-only filtering for reinforcement learning: useful reasoning actions may teach new behaviors even when the original final answer is wrong.
- Training on GSM8K with a calculator or SymPy improves HotPotQA accuracy from about 65% to 71%; HotPotQA training with search raises it to about 73%.
- Increasing HotPotQA synthetic training data from 100 to 10,000 examples also improves performance on GSM8K and MATH, despite the different tasks and tools.
- After reinforcement learning, average process reward per step rises on both in-distribution HotPotQA and out-of-distribution GSM8K.
- Multi-step reinforcement learning outperforms supervised fine-tuning; SFT benefits more from trajectories filtered for both process quality and correct outcomes.
- The lecture concludes that SWiRL's gains come from better multi-step behavior that can transfer across datasets and tools, not merely memorizing one tool's interface.
Transcript excerpt
0:05 So today's lecture is going to be about planning and multi-step reasoning. So today's lecture, we are going to cover three papers on multi-step reasoning and planning. Let's start with this paper from ICML of last year. So the title of the paper is Language Agent Tree Search Unifies Reasoning Acting and Planning in Language Models. So the types of applications that we want to target in multi-step tasks are tasks that we not only need to reason about things, but also need to act through those reasoning steps
0:54 and search our trajectories, or optimize trajectories and how we get to a final correct answer. So in the reasoning step, the model needs to think about what needs to be done? For example, what the budget is, where the plan is. These are the reasoning steps for a trip or vacation planning prompt. The act is OK. Now that you have certain types of reasoning or thinking, how do you gather more information, or act on these reasoning steps? For example, the action could be a browsing the web, generating a query to search, read Reddit, or a travel blog, and so on. And then another step is search.
1:45 Given these feedback, or the information that's gathered online, how can we refine our plan so far? Maybe we can consider alternative destinations, search new things to do while we are there, and so on. So there are a series of reasoning, action, and search steps that needs to be done to solve this problem of, for example, planning a trip. So the problem, or the challenge that this paper specifically wanted to address was the following. The goal here was, let's go from the LLM, generate a plan, and executing on that plan, to really try to encourage diversification and exploration of different types
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, Stanford Online.