Dependency Injection, Contextual Relevancy, and Evaluation - The Overlooked Essentials for Building Agentic RAG Systems
We’ve talked about Retrieval-augmented generation (RAG) a lot in this newsletter and on our channel. It has become a popular technique for enhancing large language models with access to external knowledge. However, basic RAG approaches have limitations.
In this post, we'll explore how to build more intelligent AI tools using agentic RAG and the Pydantic AI framework. Our new video will give a detailed walkthrough of this approach.
The Limitations of Basic RAG
Standard RAG typically involves retrieving relevant passages from a knowledge base and providing them as context to an LLM. While this can work well for many use cases, it falls short when:
The knowledge base doesn't contain relevant information
The query requires synthesizing information from multiple sources
The system needs to make decisions about how to handle different types of queries
This is where agentic RAG comes in.
As we wrap up this year, I want to take a moment to thank you for your support and readership for MLnotes. Your engagement has made this journey incredibly rewarding, and we are excited to bring you even more insights in the coming year.
🎄 Merry Christmas and a Happy New Year! 🎉
Take care, and we will see you in 2025 with more valuable content and ideas to share!
What is Agentic RAG?
Agentic RAG enhances the basic RAG workflow by incorporating decision-making capabilities and multiple specialized agents. Rather than blindly retrieving and generating, an agentic system can:
Determine whether to search a vector database, the web, or use other tools
Dynamically adjust retrieval and generation strategies
Combine information from multiple sources
Handle out-of-domain queries gracefully
A Multi-Agent Architecture for Agentic RAG
In the approach we’ve used, we use three main agents:
Router Agent: Decides how to handle each query
Retrieval Agent: Searches vector database and generates responses from retrieved context
Web Search Agent: Performs web searches and synthesizes responses
This architecture allows for more intelligent and flexible query handling. Let's look at how we can implement this using Pydantic AI.
…
Curious to learn more?
Join Professor Mehdi and myself for a discussion about this topic below:
What you’ll learn🤓:
🔎 Explain the example multi-agent architecture with router, retrieval, and web search agents
🚀 Walk through key code examples for implementing the agents and decision-making logic
🪄Discuss benefits like improved accuracy and ability to handle out-of-domain queries
👇
🛠️✨ Happy practicing and happy building! 🚀🌟
Thanks for reading our newsletter. You can follow us here: Angelina Linkedin or Twitter and Mehdi Linkedin or Twitter.
🌈 Our RAG course: https://maven.com/angelina-yang/mastering-rag-systems-a-hands-on-guide-to-production-ready-ai
📚 Also if you'd like to learn more about RAG systems, check out our book on the RAG system: You can download for free on the course site:
https://maven.com/angelina-yang/mastering-rag-systems-a-hands-on-guide-to-production-ready-ai
Source of images: Weaviate Blog
🦄 Any specific contents you wish to learn from us? Sign up here: https://noteforms.com/forms/twosetai-youtube-content-sqezrz
🧰 Our video editing tool is this one!: https://get.descript.com/nf5cum9nj1m8
📽️ Our RAG videos: https://www.youtube.com/@TwoSetAI
📬 Don't miss out on the latest updates - Subscribe to our newsletter: