- Brilliant Bytes
- Posts
- Langchain, AutoGPT, and AGI
Langchain, AutoGPT, and AGI
Exploring the Future of AI with Langchain and AutoGPT: Insights into AGI Development
Despite the massive hype and tons of useful applications of large language models like ChatGPT, there are still several issues that need to be addressed. These include hallucinations where the model outputs some text quite confidently, but is completely invalid and inaccurate. Second, models like ChatGPT were trained on data up to a certain point in time, which means they have not seen recent data. Finally, it is not possible for language models to interact with other apps, such as using internet for search, reading wikipedia, doing arithmetic with a calculator, etc.
Today, we are going to talk about the first mainstream solution to address these issues - Langchain, which has taken the AI world by storm. LangChain is a data aware and agentic framework for developing applications powered by language models. Over the last two months, developers have built autonomous tools like AutoGPT, which is a solution built with Langchain-type architecture & uses agents to carry out tasks with the help of language models and external tools. Langchain addresses all aforementioned limitations by:
Introducing prompt templates to remove the need for manually writing long prompts
Introducing vector databases to allow users to build LLM applications on their own data
Introducing agents that can carry out tasks autonomously with the help of external tools
Introducing external tools that allow users to surf the internet, read content from it, do maths, and a lot more stuff.
🦜️🔗 What is Langchain? The backbone of Auto-GPTs
Despite all the hype being around AutoGPT, it’s really Langchain that should be praised since that is the backbone of things like AutoGPT and BabyAGI. Let’s first draw a high level overview of what Langchain is.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/8ae7883e-2ede-48b2-8318-688cc149d868/New_Project_10_.png)
Components of Langchain
Langchain is language models on steroids as it allows us to do a lot more than just prompting a language model for an answer. The figure above illustrates some key components of Langchain and how they interact with each other.
📃 Prompt Templates: It’s hard for users to write full prompts every time they interact with language models. Redundancies in prompts can easily be handled with prompt templates, as they allow us to specify a prompt with specific inputs, which are the only part handled by the user.
Hey ChatGPT, write me a few paragraphs about
{topic}
In the above prompt, topic is the only input required from the user if we’re using a prompt template.
⚡ Models: Models are simply all the large language models that out there. Langchain supports a wide range of LLMs including GPT4, Huggingface, Cohere, etc. These models take as inputs prompts, both from users and agents (will talk about these in a few minutes), and return outputs based on them.
🔗 Chains: Chains are the first thing that starts to make things powerful. Chains allow us to chain together multiple prompts on top of each other. For instance, if we want to summarize a paragraph, and then convert it into another language, and then write an article about it, we can build a three part chain that does the following.
Prompt # 1 → Summarize a paragraph
Prompt # 2 → Take the summary and translate it into another language
Prompt # 3 → Take the translation and write a full length article in the same language
Although we can do these in a single prompt, as our tasks grow bigger, there comes a point of diminishing returns when doing everything in a single prompt, and we must use more prompts and convert them into chains. That’s where chains come in really handy.
🧠 Memory: Now, while we’re building chains and prompts, we typically ignore data in the past when sending new data to the models. Memory allows us to keep past data within the same prompt when sending it to the model. A good example of this is chatbots where you don’t just need the last message from the user in order to build a good response, you need a lot of history of the chat too. Memory allows us to do that.
🤖 Agents: This is where the fun starts. Agents allow you to interact with the world via external tools, get information from them, and use that information to make further decisions. Agents are also language models, but their task is to identify whether to use a tool, use it, and return the required output to main LLM in the chain. Since this is an iterative process, agents work by forming long chains as their output is passed to the next chain or to the user, and the process continues.
🚀 Langchain Tools
Here’s a summary of a few cool tools that are either built right on top of langchain, or use a very similar architecture. This gives you a glimpse of what we can and will be able to do with language models.
AutoGPT - one of the first applications of langchain based architecture that uses the concept of agents to build an autonomous tool.
AgentGPT - Built right on top of langchain, assign the autonomous agent a goal and it does the rest for you.
PDF Chatbot Langchain - You’ll see a ton of startups on chat based interface for files. But you can get all of that for free with this github repository. Let’s you chat with pdf files using langchain.
Chrome GPT - Autonomous agents that take control of your chrome browser, and can carry out tasks.
BabyAGI - AI powered task management, similar to AutoGPT. Their architecture is slightly different and makes use of vector databases directly, but the idea of autonomous agents that can do a wide variety of tasks is still there.
Langflow - A UI tool for Langchain that allows you to build chains on a UI, instead of having to use the framework directly.
This is a very small set of examples of how langchain is being used to build cool open source tools. The possibilities are endless here as we can build huge chains, large number of agents, and complex systems that can carry out complicated tasks autonomously. Our next post will be on how langchain is being used in different domains.
Reply