Skip to content
Back to the collection

Reflexion: Language Agents with Verbal Reinforcement Learning

Noah Shinn, Federico Cassano, Edward Berman

Show all 6 authors

Ashwin Gopinath, Karthik Narasimhan, Shunyu Yao

2023 · arXiv

Read the paper
HN score
0
Mentions
16
Readers
12
Months
8
What’s in a score?

From the abstract

Large language models (LLMs) have been increasingly used to interact with external environments (e.g., games, compilers, APIs) as goal-driven agents. However, it remains challenging for these language agents to quickly and efficiently learn from trial-and-error as traditional reinforcement learning methods require extensive training samples and expensive model fine-tuning. We propose Reflexion, a novel framework to reinforce language agents not by updating weights, but instead through linguistic feedback. Concretely, Reflexion agents verbally reflect on task feedback signals, then maintain their own reflective text in an episodic memory buffer to induce better decision-making in subsequent trials. Reflexion is flexible enough to incorporate various types (scalar values or free-form language) and sources (external or internally simulated) of feedback signals, and obtains significant improvements over a baseline agent across diverse tasks (sequential decision-making, coding, language reasoning). For example, Reflexion achieves a 91% pass@1 accuracy on the HumanEval coding benchmark, surpassing the previous state-of-the-art GPT-4 that achieves 80%. We also conduct ablation and analysis studies using different feedback signals, feedback incorporation methods, and agent types, and provide insights into how they affect performance.

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

16 selected excerpts · 16 total mentions

ipsum2
Neutral mention · rule
No. CoT has been around for several years (Jan 2022) https://arxiv.org/abs/2201.11903. And so has Reflection (March 2023) https://arxiv.org/abs/2303.11366. This approach that was taken by Reflection is nothing new.
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
avindroth
Neutral mention · rule
Reflexion can serve as good reference here: https://arxiv.org/abs/2303.11366 Essentially, AI’s output is fed into a checker, whose output is fed back into the AI for “reflexion”. Then the AI often corrects (leading to noticeable improvement in GPT-4 perf).
og_kalu
Neutral mention · rule
I don't know how we'd go about comparing reflection to human baselines but GPT-4 can reflect just fine https://arxiv.org/abs/2303.11366 GPT-4's emotional intelligence seems to be very high by the looks of things https://arxiv.org/abs/2304.11490 Empathy =/ Intelligence
lhl
Neutral mention · rule
Since I've been on a AI code-helper kick recently. According to the post, Claude 2 now 71.2%, a significant upgrade from 1.3 (56.0%). It isn't specified whether this is pass@1 or pass@10. For comparison: * GPT-4 claims 85.4 on HumanEval, in a recent paper https://arxiv.org/pdf/2303.11366.pdf GPT-4 was tested at 80.1 pass@1 and 91 pass@1 using their Reflexion technique. They also include MBPP and Leetcode Hard benchmark comparisons * WizardCoder, a StarCoder fine-tune is one of the top open models, scoring a 57.3 pass@1, model card here: https://huggingface.co/WizardLM/WizardCoder-15B-V1.0 * The best open model I know of atm is replit-code-instruct-glaive, a replit-code-3b…
Read the full comment
fine tune, which scores a 63.5% pass@1. An independent developer abacaj has reproduced that announcement as part of code-eval, a repo for getting human-eval results: https://github.com/abacaj/code-eval Those interested in this area may also want to take a look at this repo https://github.com/my-other-github-account/llm-humaneval-ben... that also ranks with Eval+, the CanAiCode Leaderboard https://huggingface.co/spaces/mike-ravkine/can-ai-code-resul... and airate https://github.com/catid/supercharger/tree/main/airate Also, as with all LLM evals, to be taken with a grain of salt... Liu, Jiawei, Chunqiu Steven Xia, Yuyao Wang, and Lingming Zhang. “Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation.” arXiv, June 12, 2023. https://doi.org/10.48550/arXiv.2305.01210.
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.
stevenhuang
Neutral mention · rule
If performance is a concern, just re-prompt GPT if there are any performance concerns, and to propose fixes for them if there are. This is called reflexion and has been found to be an effective way to improve response accuracy and usefulness (also reduces hallucinations). https://arxiv.org/abs/2303.11366
sacred_numbers
Neutral mention · rule
The Reflexion paper (https://arxiv.org/abs/2303.11366) that came out recently shows how this kind of mistake might be overcome. Asking the model to think about the answer after it's generated a first draft greatly improves accuracy. Also, prompt engineering such as copying the generated code, pasting it in a new chat and saying "There's a bug in this code, please find it" can go a long way. There is so much low hanging fruit in harnessing the power of these models that is just being ignored because some even lower hanging fruit (RLHF, system messages, context window size, plugins, etc) is being released seemingly every few days.
Dzugaru
Neutral mention · rule
It was already trained like this, RLHF [0] is a loop that has ways to feed it the information to "move forward" - update its weights. It was fine-tuned like this. It certainly did ignite something - maybe sparks of AGI, maybe just sparks of pretending to be more liked by humans (hence Human Feedback in RLHF). My guess is that loops by itself (Reflexion [1], etc.) won't change much. ChatGPT massive logs - maybe. [0] https://huggingface.co/blog/rlhf [1] https://arxiv.org/abs/2303.11366
isaacfrond
Neutral mention · rule
the paper: https://arxiv.org/pdf/2303.11366.pdf it reminds me of the thinking-fast vs. thinking-slow dichotomy. Current llms are the thinking fast type. Funnily people’s complains about its errors are reminiscent of this. It answers just to quick and only with its instant response neural net. A thinking slow answer would be more akin to a chain of thought answer. Allowing the llm a more flexible platform than CoT promptin might well be the next step. Of course it would als multiply compute cost. So it might not be in your 20$ subscription
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
og_kalu
Neutral mention · rule
>Idk about “above average baseline” That's the minimum. It's far above average for most things. >Maybe, because quite a lot of people aren’t very smart. Lol okay..and ? >But even GPT4 struggles with complex logic problems So does everyone else >and when it makes logic errors it makes ones a human would spot people spot mistakes they're capable of making all the time and so can GPT-4 - https://arxiv.org/abs/2303.11366 https://twitter.com/johnjnay/status/1639362071807549446 >It also has trouble counting letters and words, though that’s largely due to its autoregressive nature. It sees tokens not words or letters and there aren't many instances of counting occurring in text…
Read the full comment
so it doesn't get learnt. >and I really think it’s emergent, but at its core it doesn’t seem very “intelligent” and we're back to the trust me bro argument. It's not intelligent because you say it isn't not because it doesn't perform a great many tasks intelligently. if you say so

Keep following the thread.

More in Machine learning

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