Skip to content
Back to the collection

ReAct: Synergizing Reasoning and Acting in Language Models

Shunyu Yao, Jeffrey Zhao, Dian Yu

Show all 7 authors

Nan Du, Izhak Shafran, Karthik Narasimhan, Yuan Cao

2022 · arXiv

Read the paper
HN score
0
Mentions
18
Readers
15
Months
9
What’s in a score?

From the abstract

While large language models (LLMs) have demonstrated impressive capabilities across tasks in language understanding and interactive decision making, their abilities for reasoning (e.g. chain-of-thought prompting) and acting (e.g. action plan generation) have primarily been studied as separate topics. In this paper, we explore the use of LLMs to generate both reasoning traces and task-specific actions in an interleaved manner, allowing for greater synergy between the two: reasoning traces help the model induce, track, and update action plans as well as handle exceptions, while actions allow it to interface with external sources, such as knowledge bases or environments, to gather additional information. We apply our approach, named ReAct, to a diverse set of language and decision making tasks and demonstrate its effectiveness over state-of-the-art baselines, as well as improved human interpretability and trustworthiness over methods without reasoning or acting components. Concretely, on question answering (HotpotQA) and fact verification (Fever), ReAct overcomes issues of hallucination and error propagation prevalent in chain-of-thought reasoning by interacting with a simple Wikipedia API, and generates human-like task-solving trajectories that are more interpretable than baselines without reasoning traces. On two interactive decision making benchmarks (ALFWorld and WebShop), ReAct outperforms imitation and reinforcement learning methods by an absolute success rate of 34% and 10% respectively, while being prompted with only one or two in-context examples. Project site with code: https://react-lm.github.io

Metadata: arXiv. Abstracts retain their original authors’ rights.

In the conversation

Original HN comments, with labels from simple text rules. A label describes the whole comment and may miss context or irony. Read the discussion to make up your own mind. About the labels

18 selected excerpts · 18 total mentions

brianshaler
Neutral mention · rule
For anyone like me that wondered if "ReAct webapp" was a weird way of capitalizing the React webapp Javascript framework, it appears to be about a Reasoning and Acting methodology[0] with LLMs. Maybe obvious for anyone with more of a pulse on the latest in the LLM space, but it was new to me and took some digging to get more context. [0] https://arxiv.org/abs/2210.03629
unoti
Neutral mention · rule
I think you're 100% on the right track here. The key is memory, loops, and maybe a few other things like external interfaces which are just plain code and not deep learning voodoo. Many things do indeed run LLM's in a loop and attach external sources. See for example AutoGPT, the ReAct paper[1], and the Reflexion paper[2]. ReAct one line summary: This is about giving the machine tools that are external interfaces, integrating those with the llm and teaching it how to use those tools with a few examples, and then letting it run the show to fulfill the user's ask/question and using the tools available to do it. Reflexion one line summary: This builds on the ideas of ReAct,…
Read the full comment
and when it detects something has gone wrong, it stops and asks itself what it might do better next time. Then the results of that are added into the prompt and it starts over on the same ask. It repeats this N times. This simple expedient increased its performance a ridiculously unexpected amount. As a quick aside, one thing I hear even from AI engineers is "the machine has no volition, and it has no agency." Implementing the ideas in the ReAct paper, which I have done, is enough to give an AI volition and agency, for any useful definition of the terms. These things always devolve into impractical philosophical discussions though, and I usually step out of the conversation at that point and get back to coding. [1] ReAct https://arxiv.org/pdf/2210.03629.pdf [2] Reflexion https://arxiv.org/pdf/2303.11366.pdf
thedayisntgray
Neutral mention · rule
I've been frustrated by the fact that people still believe that python is some sort of magical default to build LLM apps. It's not. English is the new programming language. White paper for reference: https://arxiv.org/abs/2210.03629 Notice how the prompt used in Langchain (python) https://github.com/langchain-ai/langchain/blob/d21a494a27639... Is the same as it is in Langchain.rb (ruby) https://github.com/andreibondarev/langchainrb/blob/6fc2b962c...
krychu
Neutral mention · rule
Chain of thought: https://arxiv.org/abs/2201.11903 ReAct: https://arxiv.org/abs/2210.03629 Reflexion: https://arxiv.org/abs/2303.11366 Tree of thoughts: https://arxiv.org/abs/2305.10601 Good video on "Tree of thoughts" which also reviews / puts it in the context of other methods: https://www.youtube.com/watch?v=ut5kp56wW_4 Completion vs conversational interface is something you can read about in the OpenAI API documentation. For the remaining things I don't have single specific pointer at hand.
og_kalu
Neutral mention · rule
>GPT cannot function in any environment on its own. Except in response to a direct instruction it cannot plan, it cannot take action, it cannot learn, it cannot adjust to changing circumstance. Sure it can. It's not default behavior sure but it's fairly trivial to set up, just expensive. Gpt-4 can loop on its "thoughts" and reflect, it can take actions in the real world. https://tidybot.cs.princeton.edu/ https://arxiv.org/abs/2304.03442 https://arxiv.org/abs/2210.03629 https://arxiv.org/abs/2303.11366
flakiness
Neutral mention · rule
Note that the repo author != the paper author. The research itself [1] seems legit. The paper author also wrote a paper called ReAct [2], which is one of the core components of the langchain framework. * [1] https://arxiv.org/abs/2305.10601 * [2] https://arxiv.org/abs/2210.03629
Veen
Neutral mention · rule
It's problematic for the same reason other injection attacks are. It allows an attacker to get their "code" running in what should be a privileged environment where you should be in control. In this case, the "code" is a prompt, but the principle applies. Think about what would happen if an app scraped a web page into which someone has placed instructions for an LLM. The app then passes that instruction as context to the LLM, which is using the REACT model [0] so it can run code, communicate with other apps, etc. It's dangerous even if the LLM is just instructed to output JSON which the app uses for some other purpose [0]: https://arxiv.org/abs/2210.03629
jasonjmcghee
Neutral mention · rule
Yes- being able to reflect on its own thoughts. You could argue being able to observe and think about what was just said aligns with ReAct (https://arxiv.org/pdf/2210.03629.pdf) - maybe a tweak to directly assessing a previous thought, and modifying output / thought process based on the assessment accordingly would help, but I'm not sure that's quite enough. If it can't ask "why" and step back through why it thinks something, I think we'll keep having the confident hallucination problem- rather than "I don't know". But maybe that's touching on the quality of AGI. Is "reasoning" a necessity for the base definition?
cube2222
Neutral mention · rule
Cool stuff. I think agents are the most promising and potentially revolutionary part of the current LLM developments. Moreover, they're quite easy to write yourself, you don't need something like Langchain, the prompt structure is simple and it's a bit of text templating (it's all based on the ReAct paper[0]). That said, the bit about "The trick to avoid hallucination" in the attached blog post is a very neat idea. Obvious in hindsight, as it often is: > So the trick is that we send a stop pattern which in this case is when we see Observation: in it’s output, because then it has created a Thought, an Action and used a tool and hallucinates the Observation: itself :D >…
Read the full comment
This stop parameter is a normal parameter of the OpenAI API by the way, so nothing special to implement there. In general, it's magical when you put these things in a feedback loop. The way they can automatically respond to errors and adjust their actions is really cool - take a look at the last gif here[1]. [0]: https://arxiv.org/abs/2210.03629 [1]: https://github.com/cube2222/duckgpt
kcorbitt
Neutral mention · rule
Hey HN! My brother Arctic_fly and I spent the last two weeks since the GPT-4 launch building Taxy, an open source Chrome extension that lets you automate arbitrary tasks in your browser using GPT-4. You can see a few demos in the Github README, but basically it works like this: 1. You open the extension and write the task you'd like done (eg. "schedule a meeting with David tomorrow at 2"). 2. Taxy pulls the DOM of the current page, puts it through a pipeline to remove all non-semantic information, hidden elements, etc and sends it to GPT-4 along with your text instructions. 3. GPT-4 tries to figure out what action to take. In our prompt we give it the option to either…
Read the full comment
click an element or set an input's value. We use the ReAct paradigm (https://arxiv.org/abs/2210.03629) so it explains what it's trying to do before taking an action, which both makes it more accurate and helps with debugging. 4. Taxy parses GPT-4's response and performs the action requested on the page. It then goes back to step (2) and asks GPT-4 for the next action to take with the updated page DOM. It also sends the list of actions already taken as part of the current task so GPT-4 can detect if it's getting stuck in a loop and abort. :) 5. Once GPT-4 has decided the task is done or it can't make any more progress, it responds with a special action indicating it's done. Right now there are a lot of limitations, and this is more a "research preview" than a finished product. That said, I've found it surprisingly capable for a number of tasks, and I think it's in a stable enough place we can share. Happy to answer any questions!
cs702
Neutral mention · rule
LLMs will eventually make a lot of simpler machine-learning models obsolete. Imagine feeding a prompt akin to the one below to GPT5, GPT6, etc.: prompt = f"The guidelines for recommending products are: {guidelines}. The following recommendations led to incremental sales: {sample_successes}. The following recommendations had no measurable impact: {sample_failures}. Please make product recommendations for these customers: {customer_histories}. Write a short note explaining your decision for each recommendation." product_recommendations = LLM(prompt) To me, this kind of use of LLMs looks... inevitable, because it will give nontechnical execs something they have…
Read the full comment
always wanted: the ability to "read and understand" the machine's "reasoning." There's growing evidence that you can get LLMs to write chain-of-thought explanations that are consistent with the instructions in the given text. For example, take a look at the ReAct paper: https://arxiv.org/abs/2210.03629 and some of the LangChain tutorials that use it, e.g.: https://langchain.readthedocs.io/en/latest/modules/agents/ge... and https://langchain.readthedocs.io/en/latest/modules/agents/im... . See also https://news.ycombinator.com/item?id=35110998 .
iandanforth
Neutral mention · rule
This feels like it owes more to LangChain than a link at the bottom of the page. Compare their prompt: https://github.com/microsoft/visual-chatgpt/blob/main/visual... With that of the LangChain ReAct conversational agent: https://github.com/hwchase17/langchain/blob/master/langchain... Also it seems appropriate to cite the original ReAct paper (from Google mainly) https://arxiv.org/abs/2210.03629
cs702
Neutral mention · rule
There's evidence that you can get LLMs to write chain-of-thought explanations that are consistent with the instructions in the given text, including quantitative data, cohort performance, governance imperatives, qualitative considerations, etc. The models can even be given directions to write conditional approvals if necessary. To get a sense of what is and will be possible, take a look at the ReAct paper: https://arxiv.org/abs/2210.03629 and some of the LangChain tutorials that use it: https://langchain.readthedocs.io/en/latest/modules/agents/ge... https://langchain.readthedocs.io/en/latest/modules/agents/im...
cs702
Neutral mention · rule
> Is there any evidence or reason to suspect that this would result in the desired effect? Yes. There's evidence that you can get these models to write chain-of-thought explanations that are consistent with the instructions in the given text. For example, take a look at the ReAct paper: https://arxiv.org/abs/2210.03629 and some of the LangChain tutorials that use it: https://langchain.readthedocs.io/en/latest/modules/agents/ge... https://langchain.readthedocs.io/en/latest/modules/agents/im...

Keep following the thread.

More in Psychology

More from the same topics.

2018arXiv

Talent vs Luck: the role of randomness in success and failure

A. Pluchino. A. E. Biondo, A. Rapisarda

The largely dominant meritocratic paradigm of highly competitive Western cultures is rooted on the belief that success is due mainly, if not exclusively, to personal qualities such as talent, intelligence, skills, efforts or risk taking.

16 mentions14 months
2.5HN score