Course contentsShow
← Machine Learning and Deep Learning
Lesson 2051 of 3,53843. Retrieval-Augmented Generation: Advanced TechniquesFree lesson

Routing to Multiple Knowledge Sources

Selecting which vector stores, databases, or APIs to query based on the question domain.

Routing to Multiple Knowledge Sources

What You'll Learn

You'll learn how to intelligently direct questions to the right knowledge sources (vector stores, databases, or APIs) based on the question's domain or type.


The Core Idea

Imagine you're a librarian who needs to answer questions from patrons. Some questions require the science section, others need historical archives, and some need current newspapers. You wouldn't search every section for every question—you'd route each question to the most relevant source.

In advanced RAG systems, you often have multiple knowledge sources: a vector database for documents, a SQL database for structured data, a code repository, an API for real-time information, or domain-specific stores (medical, legal, technical). Routing means using the question itself to decide which source(s) to query.

How It Works

The routing process typically involves:

  1. Analyzing the question to determine its domain, intent, or required data type
  2. Classifying or scoring the question against available sources
  3. Selecting one or more sources to query
  4. Potentially adjusting the query format for each source (vector search for one, SQL for another)

You can use simple keyword matching, trained classifiers, or even an LLM to make routing decisions. For example:

  • "What's the current stock price?" → Route to real-time API
  • "Explain photosynthesis" → Route to scientific document vector store
  • "How many users signed up last month?" → Route to SQL database

This builds on query routing concepts you learned earlier, but now extends to orchestrating multiple heterogeneous data sources rather than just different retrieval methods on the same store.

Key Takeaway: Routing to multiple knowledge sources means intelligently selecting which databases, vector stores, or APIs to query based on the question's domain, ensuring efficient and accurate retrieval across heterogeneous data sources.