Oct 20, 2023
What Are LLM Agents?
A practical explanation of LLM chains, agents, tools, memory, and why autonomous planning changes how LLM apps behave.
LLM agents have gained popularity not only in technical and scientific communities but also in everyday discussions. But what exactly is an LLM agent?
First, let's start by understanding LLM chains.
LLM Chains
An LLM chain is like a pipeline that shows how data flows through the LLM system. The basic chain is inputting text and getting output text. However, chains can have additional steps, like querying a vector database or using an external API.
An example of a chain that connects LLM with our newsletter would be: sending a request (input text e.g. "Can you summarize the contents of the latest The Keygen news?") → Calling the calendar API to check the date → Downloading relevant text through designated API and combining it with the input → Passing the concatenated text to the LLM (prompt + newsletter content) → Getting the prediction (summary).
But, instead of downloading a text (or using a vector knowledge base), we could also employ an external API for a different purpose, e.g. to talk about weather. Then we could use an external weather API to check the current weather mentioned in the prompt.
If we want to design an LLM app that will allow a user to ask both for the weather and to retrieve information depending on the prompt, we possibly would not want to unnecessarily send requests to weather API. Especially when we would only want to retrieve data from the knowledge base. This is when agents come in handy.
Agents
Agents are autonomous LLMs that can query external APIs or models when needed, in addition to having a memory (e.g. vector knowledge base). The LLM first analyzes the input and plans the necessary steps to achieve the desired outcome. Then, it executes the plan step by step. This flexible and robust approach allows the agent to break the problem into smaller actionable steps instead of following a predefined chain of actions like in the example above.
This planning process is often repeated after every action, successful or not, allowing for self-reflection on its own actions.
Takeaway
In my opinion, using LLMs to build agents has great potential. However, it can be challenging to determine what an agent should be capable of and how to perfect it. Without a very strong LLM, utilizing it effectively remains a challenge.
- Reading: We've covered the definition of chains and agents in LLMs, but if you're interested in learning more, check out Lilian Weng's blog post on LLM-powered autonomous agents.
- Libraries: Common Agent libraries include LangChain, Agents, AutoGen, or Haystack, but there are many others. Check Awesome AI Agents repository to learn more.
Let us know if you are interested in learning more about agents!