REACT — Bridging the Gap Between Language and Action in LLM

Li Xing
Nordnet Tech
Published in
4 min readApr 8, 2024

Introduction

LLM stands for Large Language Model, and it refers to a powerful type of AI trained on massive amounts of text data. These models can generate human-quality text, translate languages, write different kinds of creative content, and even answer your questions in an informative way. And on top of that, they are getting better at reasoning and acting.

LLM Reasoning

Chain-of-Thought (CoT) prompting encourages Large Language Models (LLMs) to express their reasoning steps, though the faithfulness, or how closely these steps align with the LLM’s internal thought process, remains under debate. Unlike a simple answer, CoT reveals a breakdown of steps leading to the output, offering a seemingly transparent reasoning process. Recent research, “Measuring Faithfulness in Chain-of-Thought Reasoning,” shows LLMs can be faithful under specific conditions, but the degree of faithfulness varies significantly across different models and tasks.

LLM Acting

LLMs can perform actions by interacting with external tool integration, or LLM-specific action frameworks:

  • WebGPT: This model can interact with the web directly, navigating web pages and extracting information based on user instructions.
  • Public APIs: These allow LLMs to interact with external services, such as weather forecasts, news articles, and more.
  • Your own APIs: These allow LLMs to connect with your own services and databases, accessing information beyond text data.

ReAct: Synergizing Reasoning and Acting

ReAct, proposed by a team at Google AI in 2022, marks a significant step forward in language models (LLMs). Traditionally, these aspects have been studied separately, but ReAct merges them,

Imagine a child learning to ride a bike. First, they understand the concept of balance and pedalling (reasoning). Then, they translate that understanding into physical actions (acting). ReAct follows a similar approach. It prompts the LLM to generate reasoning traces, explaining its thought process, while simultaneously taking actions, such as querying external knowledge bases, to inform its reasoning.

Amazed? Let’s experience it in action.

ReAct in Action

Working at Nordnet gets me to be more and more interested in saving and investment. So, I would like to ask some questions to ReAct about my personal investments.

I created the ReAct Agent on the LangChain framework. The key components of the ReAct Agent are:

  • LLM: Gemini 1.0 Pro on Google Vertex AI
  • Prompting: Chain-of-Thought prompting that can take in my portfolio as input
  • Tools: calculator and public APIs

Here is part of the prompt that emphasise Chain-of-Thought reasoning and action:

ALWAYS use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action:

$JSON_BLOB
Observation: the result of the action
... (this Thought/Action/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question

Begin! Reminder to always use the exact characters `Final Answer` when responding.

Here is how my portfolio is like:

{
"portfolio": [
{
"marketValue": {
"currency": "SEK",
"value": 77420.0
},
"instrumentName": "Ascelia Pharma AB",
"stockTicker": "ACE",
"portfolioLendingPercentage": 5
},
{
"marketValue": {
"currency": "SEK",
"value": 1058210.09724672
},
"instrumentName": "BRUMMER MULTI STRATEGY",
"stockTicker": "BRUMMER MULTI STRAT",
"portfolioLendingPercentage": 62
},
{
"marketValue": {
"currency": "SEK",
"value": 0.0
},
"instrumentName": "CIRCULAR WATER TECH",
"stockTicker": "CIRCULAR WATER TECH",
"portfolioLendingPercentage": 0
},
{
"marketValue": {
"currency": "SEK",
"value": 0.0
},
"instrumentName": "HVR WATER B",
"stockTicker": "HVR B",
"portfolioLendingPercentage": 0
},
{
"marketValue": {
"currency": "SEK",
"value": 35580.0
},
"instrumentName": "Irras AB",
"stockTicker": "IRRAS",
"portfolioLendingPercentage": 0
}
]
}

Question 1: Portfolio Breakdown

I wanted to understand the diversification of my portfolio, meaning how much each investment contributes to the total value. ReAct analyzed my portfolio (which I provided beforehand) and gave me a clear breakdown.

Can you describe the diversification of my portfolio based on market value?
Portfolio Breakdown

Question 2: Diversification Tips

Taking things a step further, I asked ReAct how I could improve my portfolio’s diversification. ReAct analyzed my holdings and offered specific suggestions!

How can I improve the diversification of my portfolio based on market value?
Diversification Tips

This experiment is just a glimpse into the exciting potential of ReAct. The potential of ReAct extends far beyond this very experiment, it could be an AI assistant that not only understands my language but can actually take action based on it.

Conclusions

  • ReAct is a powerful framework that bridges the gap between language and action in LLMs.
  • ReAct improves the transparency of LLMs by revealing their reasoning process.
  • ReAct is a glance into the future of AI, where LLMs aren’t just passive responders but active participants in our world.

References

--

--