From the course: Hands-On AI: RAG using LlamaIndex
Drawbacks of Naive RAG
- [Instructor] I hope you're feeling proud of yourself. I hope you're feeling energized and excited because you've seen end to end what a RAG pipeline looks like. At least you've seen end to end what a Naive RAG pipeline looks like. Just to drive the point home and reiterate, let's talk about the thing that we've repeatedly been doing over the last several lessons just to drive it home one more time. Remember that it's essentially a three step process. We index, retrieve, and generate. So in indexing, we're processing data into manageable, searchable chunks and then indexing them for efficient retrieval. In retrieval, we're using the user's query to search the indexed data and then fetch the most relevant documents. For generation, we're combining the user query with the retrieved context to generate a context aware response. That's great for a Naive RAG pipeline like it works, but it has challenges. So let's talk a little bit about these challenges. One is that there's issues with indexing. For example, you could have incomplete or inaccurate information during extraction. You might be chunking your data in a suboptimal way. There might be some inefficiencies with the indexing techniques that you're using, or there might just be some poor semantic representation of the data that you have embedded. You also can face challenges with retrieval. You can have low precision, so not all the retrieve data is going to match the query, or you might have low recall, and that's where you fail to retrieve all the relevant data. You might have ineffective user queries, right? Your user might not be able to articulate and express themselves that well. You might even have redundant and overlapping information. Generation also has its problems. You can face hallucinations. The LLM might just generate a fictitious response, if we give it a context that is blank, right? We might give the language model context with like nothing in it because there's no relevant data to inject into the context, and it just might make stuff up. There is also difficulty in assessing how relevant that generation is to the user's query and to the context that was retrieved. The language model might actually just kind of over rely on that external information. So rather than synthesizing it into a nice, cohesive, coherent response, it might just pair it and regurgitate what it has retrieved. There also might be some issues with bias or inconsistent or irrelevant responses. So Naive RAG is great, it works to a certain extent. It gets the job done for simple use cases, for Naive use cases, if you will. But we need to address these challenges, and if we don't address these challenges, we will not be able to build a sophisticated and reliable RAG system. And so now what we are going to focus on throughout the remainder of this course is how to improve upon Naive RAG with advanced methods. But first, I need to tell you how to evaluate your system so that you can measure improvements. Now, I want to warn you that in this course, I'm not going to be doing a ton of evaluation. It's not the core of this course. Like I mentioned before, evaluation can be its own entire course unto itself. I've tried many ways to kind of fit evaluation into this course, and each module just ended up becoming a little bit too large for my liking. I was having to rely on a lot of external libraries, and I just wanted to minimize all those distractions. So we're not going to do a comprehensive evaluation of every RAG technique that we're presented with, but what I am going to give you is a framework for how to evaluate your RAG pipelines, and I'll point you to some of the libraries, open source libraries in the ecosystem that you can use to evaluate your RAG system. But just a little bit of forewarning there. I think it is important to talk about RAG evaluation. This course would not be complete without at least discussing it, but I'm not going to go too in depth because we have a lot of ground to cover. So we have covered, again, a lot of ground up until now, and we still have a lot more to go. So again, just thank you so much for sticking with me up until this point. I do hope that you are excited and ready to see more advanced RAG techniques because we are about to go in, my friends. And again, remember, if you haven't already, if you're enjoying this course up until this point, go ahead and leave us a review. Leave me some stars if you would. I'd greatly appreciate that. Feel free to hit me up on LinkedIn if you got any questions. I'm happy to help you. We're about halfway through this course, I'm ready for more. It's just going to get more and more interesting from here on out. All right, my friends, I'll see you in the next lesson.