In real world applications, simple naive RAG systems are rarely used nowadays. To provide correct answers to a user query, we are always adding some agency to the RAG system. However, it is important to ๐ป๐ผ๐ ๐ด๐ฒ๐ ๐น๐ผ๐๐ ๐ถ๐ป ๐๐ต๐ฒ ๐ฏ๐๐๐ ๐ฎ๐ป๐ฑ ๐๐ฒ๐ฟ๐บ๐ถ๐ป๐ผ๐น๐ผ๐ด๐ and understand that there is ๐ป๐ผ ๐๐ถ๐ป๐ด๐น๐ฒ ๐ฏ๐น๐๐ฒ๐ฝ๐ฟ๐ถ๐ป๐ to add the mentioned agency to your RAG system and you should adapt to your use case. My advice is to not get stuck on terminology and think about engineering flows. Letโs explore some of the moving pieces in Agentic RAG: ๐ญ. Analysis of the user query: we pass the original user query to a LLM based Agent for analysis. This is where:
- The original query can be rewritten, sometimes multiple times to create either a single or multiple queries to be passed down the pipeline.
- The agent decides if additional data sources are required to answer the query.
๐ฎ. If additional data is required, the Retrieval step is triggered. In Agentic RAG case, we could have a single or multiple agents responsible for figuring out what data sources should be tapped into, few examples: - Real time user data. This is a pretty cool concept as we might have some real time information like current location available for the user.
- Internal documents that a user might be interested in.
- Data available on the web.
๐ฏ. If there is no need for additional data, we try to compose the answer (or multiple answers) straight via an LLM.
๐ฐ. The answer (or answers) get analyzed, summarized and evaluated for correctness and relevance: - If the Agent decides that the answer is good enough, it gets returned to the user.
- If the Agent decides that the answer needs improvement, we try to rewrite the usr query and repeat the generation loop.
The real power of Agentic RAG lies in its ability to perform additional routing pre and post generation, handle multiple distinct data sources for retrieval if it is needed and recover from failures in generating correct answers. What are your thoughts on Agentic RAG? Let me know in the comments!