I explain LLMs, RAG, and AI agents in the simplest terms: an LLM is a language model trained on broad data, RAG grounds it in your own real-time data, and an agent is an LLM with tools it calls in a loop until a task is done. I break RAG into retrieval of relevant data, augmentation by injecting that data into the prompt, and generation of a response from the new context. I show how an agent uses ordinary functions like search, file reads and writes, and custom APIs to complete something like writing an SEO-optimized article, then reports back. My take is that these are the fundamental mental models: default LLMs won't know your specific dataset, RAG fixes that, and agents extend an LLM with tools.
Before we start this video, I feel it is important to tell you that I haven't slept all night. I don't know why you need to know that. I just felt it was relevant to share before we actually begin.
We're going to talk about LLMs, RAG, and AI agents. And I'm going to give you the simplest and shortest explanation of all three of these things. Let's begin.
So, first of all, LLMs. LLMs are basically large language models. These are simply AI models that are trained on human language, and they can basically just produce language, right? You can ask them anything, and they can give you an answer in natural human language.
So when you look at stuff like ChatGPT or Claude or whatever, these are simply LLMs. You can give them a prompt, and they will give you some sort of output in natural human language, and they don't have any capability beyond that.
And the thing with LLMs is that they are trained on a huge amount of data. They're trained on basically the entire internet, right? Which is a ton of training data. But the problem is that this is not something that's specific to your use case.
If you want to train an LLM on your specific data, and you want to make sure that the LLM only responds from your dataset, then you need to use something called RAG. And RAG is basically just the power of LLMs augmented with real-time data, right?
So think something like maybe an LLM trained on your product documentation. Let's say this is a document that's not going to be something that the LLM is trained on by default, right? And so, in order to train the LLM on this particular dataset, right, your own particular unique dataset, you're going to want to use something called RAG.
This basically stands for Retrieval Augmented Generation. Let me explain what all of those things mean.
So the first step is retrieval, right? And during retrieval, you're going to retrieve relevant data from your dataset that is relevant to the user's query, right? Once you do that, you're going to pass that into the augmentation stage, and you're going to pass this, pass the relevant data that you just got into the LLM's prompt.
And once you've done that, you're going to move on to the generation stage, where you're going to give the LLM all of that new context, all the new real-time data that you just got, and ask it to generate a response to the user's query based on all of that real-time information.
And on a very high level, that's basically how RAG works. So if you want a question-answering machine like ChatGPT or something that is trained on your particular dataset, you need to use RAG.
Now, lastly, AI agents. This is the most fascinating part of the entire video and arguably the most fascinating piece of technology in all three of these.
An AI agent is basically when you have an LLM that's going to be connected to a big bunch of tools. And these tools are just functions, right? So think just regular functions inside your code, right? That's what a tool is in this context.
And what these basically do is they enhance the LLM's functionality by just giving it more tools in its arsenal that it can use to solve your problems for you, right?
So let's say, for instance, we could have a files tool that could allow the LLM to read and write files and folders on your computer, right? We could pass in functions like read file, and then it would pass in a file path over here or something. Or we could have something like write file, the file path and the file content. We could have something like that.
And again, these are just basic functions that you write in normal programs. But you basically give the LLM access to these functions so that it can call them anytime it wants.
You could have a search tool that's going to search Google for any query that the LLM wants to get real-time information on. You could have some custom API, I don't know, for any integration or something that you need to do and you want the LLM to have access to it. You can have any of these things over here, right?
And now the way this is going to work is you have an LLM that's basically the brain of the AI agent, and then you have a bunch of tools connected to it that it can call as needed, right?
So we're going to have a little user over here, and that user is going to pass in some sort of a query to the LLM, right? Like, for instance, let's say the query is something like, "Write an SEO-optimized article on AI agents." Let's say we have a query like that.
So the LLM is going to go over to the search tool, and it's going to find out all of the latest information on AI agents that it can. It's going to read all the articles that you return over here in this function.
It's going to use the files tool to make sure that there isn't any article like this that already exists or something. It might use this third-party API, depending on whatever it is, to get some more information or whatever, or do some sort of task, right?
And then it's going to use the files tool again to write the file to your system. And then it's going to just notify you that, "Hey, this is done. You can check it out," right?
And once all of this work is done, it's going to respond back to the user over here.
So essentially, that's how AI agents work. You give them a task to do, and they use the tools that are within their grasp to complete that task for you, and then they're just going to notify you that, "Hey, this is done."
Obviously, you can expand this functionality to include memory, past conversation history, and other kinds of features, right? But that gets pretty advanced.
At a fundamental level, this is what AI agents are. They're an LLM that has access to a bunch of tools, and the LLM is going to call these tools in a loop until the task that you give it is completely done.
So that's a quick explanation of LLMs, RAG, and AI agents and how each of these things work.