AI engineering paper · 2023

ReAct

Yao, Zhao, Yu, Du, Shafran, Narasimhan and Cao · ICLR 2023

How ReAct lets a language model alternate between thinking and acting, so it can look things up, check its work and recover from dead ends.

One ReAct loop. The model writes the thought and the action; the program runs the action and pastes the result back in. The loop ends when the model writes Finish.

You’ll learn to

  • Explain how ReAct interleaves thoughts, actions and observations, and what the program around the model has to do.
  • Trace a ReAct run step by step, including a dead end, and say what each thought contributed.
  • Compare ReAct with thinking-only and acting-only prompts on the paper’s four benchmarks, and say where it won and where it lost.
  • Name what changed after the paper: built-in tool calling, thinking between tool calls and fine-tuning on trajectories.

The idea in short

A language model that only thinks out loud can state wrong facts with full confidence, and nothing stops it. A model that only acts, by calling a search or clicking a button, has no plan and loses its place. ReAct lets one model do both in a single loop: write a thought, take an action, read what came back, and repeat.

The thoughts keep the plan and notice when something went wrong. The actions bring in real information from outside the model. The paper showed this with no training at all, just a few written examples in the prompt, and it became the basic shape of the agents engineers build today.

The problem

This guide covers “ReAct: Synergizing Reasoning and Acting in Language Models” (Yao and six co-authors, 2022). By then, large could do two separate things well, and each had a flaw.

The first was reasoning in words. With , you show the model a few examples where the answer comes with the steps that lead to it, and the model then writes out its own steps before answering. This raised accuracy on maths and logic questions. But the model only has what is stored in its weights, the numbers it learned in training. If it half-remembers a fact, it writes the wrong fact as part of step one, builds on it, and ends in a confident, wrong answer. The paper calls this and : a mistake early in the chain carries through every later step.

The second was acting. Other work used language models to choose actions in a game, a website or a robot simulator, one step at a time. These models got real information back from the world, but they did not say why they chose an action. They had no plan to check progress against, no way to say “that did not work, try something else”, and no way to keep track of sub-goals over a long task.

Yao and co-authors saw that these were two halves of how people solve problems. Thinking guides the doing, and the doing changes the thinking.

So the question the paper asks is: can one language model be prompted to reason and act together, in one loop, without any training?

The design choices

The paper’s name for the method is , short for reasoning plus acting. It rests on a few choices.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan

About the paper

ReAct: Synergizing Reasoning and Acting in Language Models by Yao, Zhao, Yu, Du, Shafran, Narasimhan and Cao, ICLR 2023.

Read the original paper

More AI engineering papers

All papers