Routing in RAG Driven Applications
Source: https://towardsdatascience.com/routing-in-rag-driven-applications-a685460a7220 Published: 9 May 2024 · Author: Sami Maameri
Summary
A taxonomy of seven router types for RAG applications, framed deliberately plainly: “Routers are essentially just If/Else statements we can use to direct the control flow.”
The Seven Router Types
- LLM completion routers — the model outputs one of a set of predefined words
- LLM function-calling routers — route selection via function calling
- Semantic routers — embeddings and similarity search against example utterances
- Zero-shot classification routers — assign a label from a predefined set
- Language classification routers — detect query language and route accordingly
- Keyword routers — match keywords against route lists
- Logical routers — discrete checks: string length, file names, value comparisons
Implementations Named
LlamaIndex (LLM Selector router, Pydantic Router) · LangChain · semantic-router · Haystack (deepset) (ZeroShotTextRouter, TextClassificationRouter, ConditionalRouter, FileTypeRouter) · OpenAI Encoder · Hugging Face models · langdetect
Related Concepts
- Query Routing — primary topic
- RAG · Query Understanding · Query Classification · Agentic Search