Do Agents Think of Electric Sheep? The ReAct Framework
1. Do Agents Think of Electric Sheep? The ReAct Framework
Welcome back! The last lesson showed how agents operate through the thought-action-observation cycle. We also explored how models are responsible for breaking down problems into small, manageable steps.2. The Different Type of Model Thoughts
These steps come in the form of thoughts, underpinning every action and observation an agent takes. There are different types of thoughts a model can have, specifically:3. The Different Type of Model Thoughts
planning thoughts, where models break down a problem into small steps,4. The Different Type of Model Thoughts
analysis thoughts, where models draw insights based on observations,5. The Different Type of Model Thoughts
decision-making thoughts, where models make specific decisions based on inputs,6. The Different Type of Model Thoughts
problem-solving thoughts, where models theorize over what could be the root cause of a problem,7. The Different Type of Model Thoughts
memory integration thoughts, where models remember details stored in their memory,8. The Different Type of Model Thoughts
self-reflection thoughts, where models reflect on the style and quality of their output,9. The Different Type of Model Thoughts
goal-setting thoughts, where models determine important goals for them to be able to solve the presented objective,10. The Different Type of Model Thoughts
And finally, prioritization thoughts, where models determine the priority levels of different tasks.11. The ReAct Framework: Where Thoughts Come From
But how exactly do you arrive at these thoughts? How do models break down problems into small steps systematically? This is where the ReAct framework comes in.12. The ReAct Framework: Reasoning and Acting
ReAct is a prompting framework that combines "Reasoning" and "Acting." It encourages models to break down the problem into thoughts and actions.13. The ReAct Framework: Reasoning and Acting
It helps models better reason by adopting chain-of-thought prompting, which is essentially telling the model to "think step by step,".14. The ReAct Framework: Reasoning and Acting
It helps models take better action, by providing concrete examples showing the types of thoughts, actions, and observations a model can make to solve specific problems.15. ReAct in Action: Simple Arithmetic
Let me show you a simple example of ReAct in action, that you can try right now. Let’s go on ChatGPT, and use the GPT-4o model.16. ReAct in Action: Simple Arithmetic
We ask the same question in two different chat threads: “Calculate the total cost if I buy 3 laptops at $899 each with a 15% discount and 8% sales tax.” Using a calculator, the answer to the question, is $2475.8517. ReAct in Action: Simple Arithmetic
In the first chat, the model is explicitly instructed to just return the answer.18. ReAct in Action: Simple Arithmetic
In the second chat, ChatGPT receives a ReAct-based prompt, with instructions to think step by step, as well as example thoughts, actions, and observations the model is expected to undertake.19. Without ReAct Prompting
As you can see, without ReAct prompting, GPT-4o returns a hallucinated outcome.20. With ReAct Prompting
In the second chat, GPT-4o gets it right. You can try this yourself on any non-reasoning model.21. ReAct as a Way of Thinking
In many agents you interact with, the ReAct approach is embedded in the model’s system prompt, which are the hidden instructions that tell the model how to behave throughout all conversations. This is why most of the time, you do not need to explicitly prompt agentic tools with a ReAct style prompt.22. Reasoning Models and ReAct
Here's an important note, though: The ReAct framework is especially useful on language models like the GPT-series of models. Newer generation reasoning models have been explicitly trained to think step by step, which is why they’re especially useful for agentic use-cases. For these models, you don't need to apply ReAct style prompting.23. How to Spot a Reasoning Model
If you’re unsure whether a model is a reasoning model or not, you can spot it by whether it shows thinking traces when it’s responding.24. Let's Practice!
Now, let's see how you ReAct to the exercises.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.