Big picture of ReAct:
AI doesn't just answer immediately, it goes through stages.
think -> plan -> action -> observe -> output(total 5 steps)
ReAct = Forcing the AI to show its work step by step before arriving at a conclusion, just like how a student arrives to the solution of a math problem step by step.
Here is the simplest mental model for ReAct:
┌──────────────────────────────┐ ┌──────────────────────────────┐ ┌──────────────────────────────┐
│ Current State / User Question│ → │ Reason about current state │ → │ Need more action? │
└──────────────────────────────┘ └──────────────────────────────┘ └──────────────┬───────────────┘
│
┌───────────┴───────────┐
│ │
Yes No
│ │
v v
┌──────────────────────────────┐ ┌──────────────────────────────┐
│ Choose tool / perform action │ │ Return final answer │
└──────────────┬───────────────┘ └──────────────────────────────┘
│
v
┌──────────────────────────────┐
│ Observe result │
└──────────────┬───────────────┘
│
└──── back to "Reason about current state"
Comparing Chain of Thought(another prompting technique) vs ReAct:
CoT - In this technique, the LLM is instructed to generate its intermediate reasoning steps as part of the output, instead of jumping straight to the final answer.
ReAct - CoT only thinks, ReAct thinks and does stuffs.
Here is the code
Top comments (0)