Urgent.News

the world's headlines, one feed

Tech

Why Basic RAG Fails in Production and How Adaptive Query Routing Fixes It

Most developers build Retrieval-Augmented Generation (RAG) pipelines assuming every user query needs a vector search. In production, this naive approach fails in three distinct scenarios: Simple Queries: "Hi", "Who created this bot?", or general knowledge queries don't need expensive vector database lookups. Ambiguous Queries: Vague user questions lead to noisy retrieval, diluting the LLM's…

Abstract editorial illustration

Many developers implement Retrieval-Augmented Generation pipelines without realizing not every user query requires searching through expensive vector databases. This basic RAG method breaks down in three key ways in a real-world setting. Simple, straightforward queries like “Who created this bot?” or basic knowledge questions can be answered directly by the language model without any vector database lookups.

Ambiguous or vague questions generate noisy retrieval results, contaminating the model’s context window with irrelevant chunks. When no relevant documents exist in the vector database for out-of-domain queries, naive RAG causes the language model to hallucinate answers based on poor context. To address these issues, Adaptive RAG with Dynamic Query Routing offers a more effective solution.

Rather than always directing requests to vector retrieval, Adaptive RAG serves as an intent-aware orchestrator that classifies queries into one of three categories: general LLM responses, internal vector database searches, or external web searches. The process begins with an intent classifier node that determines the appropriate data source based on the query’s nature.

Relevant documents are retrieved and graded for relevance before being fed into the language model, while a fallback circuit triggers web search or clarification requests when document relevance is low. By structuring the routing with Pydantic for deterministic JSON outputs, implementing a structured query classification node using LLM function calling, and integrating everything into an async FastAPI endpoint, developers can optimize cost, reduce hallucinations, and improve latency.

This approach yields significant benefits including up to 40% cost reduction from filtering out trivial questions, lower hallucination rates, and faster responses in under 300 milliseconds.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written; read the original for the full account.

Read the original at dev.to →

More in Tech

Corrupt Minds Think Alike

Tariq Panja, reporting for The New York Times: The five men should have been in a celebratory mood. FIFA had just pulled off a World Cup that broke records on a number of fronts.