In the previous section, we explored what RAG is and why it is important.
In this section, we will take a closer look at different types of RAG systems and compare RAG with other techniques.
There is no single official classification for RAG systems. However, they are commonly categorized based on their complexity and approach:
Naive RAG is the simplest approach.
When a user asks a question, the system searches for relevant information and passes the retrieved content to the LLM, which then generates an answer.
Because there is little or no optimization involved, this approach can lead to several problems:
Advanced RAG improves retrieval quality by introducing additional optimization steps, such as:
Modular RAG is a more flexible approach that allows each part of the system to be customized independently.
For example, you can:
You might be wondering:
Isn’t retrieving external information and giving it to an LLM basically the same thing as Function Calling?
Yes! Both RAG and Function Calling are different approaches to extending the capabilities of an LLM.
However, they are designed for different types of problems.
In real-world applications, you will often combine RAG and Function Calling to take advantage of both approaches.
For example, we can combine them to build a product-support chatbot.
We can use Function Calling to determine which function should be called, such as:
search_productget_shopping_cartget_order_historyThese functions can retrieve product information, shopping cart contents, or order history from the application.
After searching for the relevant products, we can retrieve the most relevant product information and pass it to the LLM to generate a response.
Here, Function Calling is useful for interacting with the product system, while RAG can be used to retrieve additional product-related information.
We can use RAG to retrieve the most relevant documentation, such as:
The retrieved information is then passed to the LLM to generate the final response.