In older RAG systems, topic routing was used to narrow down area to be searched for similarity. Today it has been largely become redundant due to popular use of hierarchical clustering techniques. But still when you progress to RAG systems with huge, multidomain datasets as inputs, topic routing can be of immense help. In any retrieval pipeline, topic routing will be come high in the hierarchy, typically it will be the second step, even before chunking.
Essence: Instead of searching all knowledge, route the query to the right retriever.
Example:
User Query:
"How many PTO days do employees get?"
Router decides:
→ HR retriever
Another query:
"How do Kubernetes taints work?"
Router decides:
→ Engineering retrieverAlgorithms for Topic Routing
A. Classification Models
Train a classifier:
query → topic labelAlgorithms:
- Logistic Regression
- SVM
- Random Forest
- small transformer classifiers
- BERT classifiers
Example:
"leave policy"
→ HR
"invoice tax"
→ Finance
B. Embedding-based Routing
No classifier needed.
You maintain topic embeddings:
HR centroid
Finance centroid
Engineering centroidThen:
query embedding
↓
nearest topic centroidThis is lightweight and common.
C. LLM Routing
Modern systems use an LLM itself:
Classify this query into:
- HR
- Legal
- Engineering
- FinanceThis is flexible but slower and costlier.
No comments:
Post a Comment