Combining Web Search with RAG
Hybrid retrieval: local vector store + live web search for up-to-date answers.
The Hybrid Retrieval Challenge
Most real-world agents need two types of knowledge: static domain knowledge (company docs, product manuals, policies) and current information (news, live prices, recent events).
A local vector store handles the former; web search handles the latter. Combining both gives the best of both worlds.
Architecture: Local RAG + Web Search
The hybrid system routes each question to the right retrieval source:
- Vector store (RAG) — indexed documents, stable knowledge, private data
- Web search — current events, recent releases, live data
- Both — when the question needs context from docs AND current info
class HybridRetrievalAgent:
def __init__(self, vector_store, search_client):
self.vector_store = vector_store # e.g., ChromaDB or FAISS
self.search_client = search_client # e.g., TavilyClient
def answer(self, question):
route = self.classify_question(question)
if route == 'static':
context = self.vector_store.query(question, n_results=5)
elif route == 'current':
context = self.web_search(question)
else: # 'both'
local = self.vector_store.query(question, n_results=3)
web = self.web_search(question)
context = local + web
return self.generate_answer(question, context)All lessons in this course
- Tavily and SerpAPI for Agent Search
- Ranking and Filtering Search Results
- Deep Research Loop Pattern
- Combining Web Search with RAG