AI and Deep Learning Community Question

How can AI Agents solve the "Long Context" problem in RAG?

Posted on 2024-05-20 • In AI and Deep Learning • By Brian Miller

Even with a 128k context window, our RAG system often misses the "needle in a haystack" when we search through 500+ documents. I’ve heard that "Agentic RAG" can solve this by having the agent intelligently decide which sections to read more deeply. How do you implement this "multi-step retrieval" where the agent refines its search based on what it finds in the first pass?

3 Answers 17,585 Views

All answers to this question 3 Answers

Dorothy Martinez Answered on 2024-05-22
Answered

Agentic RAG transforms retrieval from a "one-shot" keyword search into a conversational discovery process. Instead of just pulling the top 5 chunks and hoping for the best, the agent can look at the initial results and say, "I found a mention of the 2022 tax code here, but I need to see the specific amendment from October." It then generates a new search query to find that specific detail. You implement this by giving the agent a "Retriever Tool." The agent's prompt includes a loop where it evaluates if the current context is sufficient to answer the user's question; if not, it calls the retriever again with a more refined query.

Thomas Wilson Answered on 2024-05-23
Answered

Does this significantly slow down the user response time? Doing 3 or 4 retrieval loops must take much longer than a standard RAG call that happens in a single pass.

Brian Miller Commented on 2024-05-25
Commented

Thomas, it definitely adds latency, usually 5-10 seconds per extra loop. However, for "Deep Research" tasks where accuracy is more important than speed, our users are happy to wait for a correct answer rather than getting a fast but wrong one. Dorothy, the "Retriever Tool" idea is brilliant. We’ve started implementing a "Self-Grader" node where the agent checks its own retrieved chunks for relevance before answering. If the score is too low, it automatically triggers a second search with different parameters.

Susan Taylor Answered on 2024-05-26
Answered

You can also use an agent to "Pre-Process" the documents by summarizing each one. The main agent can then scan these summaries first to decide which full documents are worth a deep dive.

Dorothy Martinez Commented on 2024-05-27
Commented

Susan's "summary-first" approach is a great way to save on token costs. It’s like an agent reading the Table of Contents before diving into the chapters.

Write a Comment

Your email address will not be published. Required fields are marked (*)

Join the LearnersEra Community

Ask questions, share knowledge and learn from professionals across technology, project management and certification topics.

Change Country and Nearest City

Select your country and nearest city to see courses available in your region.