What Is an AI Agent?
Everyone is talking about "LLM agents". Here's the simple pattern underneath them, and why it matters so much.
You have probably been seeing lots of talk and activity around "LLM agents" this year — so let's dive into what this technology is and why it's so important.
Most people at this point are very familiar with using ChatGPT to either generate new text ("Help me write this code") or to answer questions. Both of these are based on the core LLM feature of "text completion". But increasingly ChatGPT is able to do more complicated things like:
- Research an answer from the internet, or
- analyze a spreadsheet and answer questions based on the analysis
So how does this work, since these tasks require more than "text completion"? Well back in Oct 2022 (20 months ago!) some researchers created what they called the ReAct pattern ("Reasoning" + "Acting") of LLM prompting. They observed that LLMs could do a few things based on text completion:
- Instead of returning a single answer to a question, they could create a plan to answer the question ("chain of thought" reasoning)
- If, when you prompted the LLM, you gave it a set of "actions" that it could use in its answer, then it could select the appropriate action to take based on your question
By combining these ideas, they created the ReAct pattern. So each time you query the LLM, it follows these steps:
- Creates a "plan" to answer the query
- Chooses an "action" to take to help create the answer
- Makes an "observation" where it examines the result of the action and uses it to inform the answer
Now the clever part is providing "actions" to the LLM. What we do is just describe, in English, a set of possible actions. The LLM generates a text completion like "ACT: <action>", and then we parse that bit and return the result of the action to the LLM:
ACT: <websearch for 'WWII'>
Result: WWII was called "The Great War" …
Now imagine that we build a nice set of "actions" (or "tools") for the LLM to use, like:
- "search the web"
- "read the text of this spreadsheet"
- "evaluate this python code"
And now we run this ReAct pattern in a loop. Each time through the loop we ask the LLM "Observe your action results, and if you have solved the original query then return the answer". The result is a "semi-autonomous" agent that can take intelligent action to solve a problem!
So far most of the examples you have seen of this "agentic" behavior are pretty simple: do a web search, read a document, etc. But the potential of this pattern is immense. What if you gave the LLM lots and lots of tools to use and asked it to perform complex reasoning along the way to accomplishing its task? Well, then you can have agents that can book a flight for you, and the hotel room, and make dinner reservations on your behalf. Or you can have assistants at work which accomplish dreary report reading or data analysis tasks all by themselves.
We have only gotten a glimpse of where "AI agents" are going to take us, but there is a lot, lot more coming soon.
Originally published on LinkedIn.