TechnologyMarch 17, 2026·8 min read

Smart Routing: Automatic Knowledge Base Selection with Embeddings

Citai Team

March 17, 2026 · 8 min read

What is Smart Routing?

When you have multiple knowledge bases — for example, one for “Product”, another for “Technical Support”, and another for “Billing” — how does the chatbot know which one to search? Smart Routing solves this automatically, selecting the most relevant KBs for each question without user intervention.

What is a centroid? A centroid is the average vector of all embeddings (document fragments) in a knowledge base. It represents the "thematic center" of that KB in a 384-dimensional space. If a question is close to a KB's centroid, that KB likely has the answer.

How Does It Work?

The Smart Routing process follows these steps:

  1. Query embedding — the user’s question is converted into a 384-dimensional vector
  2. Centroid loading — precalculated centroids for each KB are retrieved (cached in Redis for 24 hours)
  3. Cosine similarity — similarity is calculated between the query vector and each centroid
  4. Top-3 selection — the 3 KBs with highest similarity are selected
  5. Minimum threshold — only KBs with similarity >= 0.15 are included (avoids completely irrelevant KBs)
  6. Search in selected KBs — the RAG pipeline searches only in the chosen KBs
384dembedding space dimensions
Top 3knowledge bases selected per query
24hcentroid cache in Redis

Complete Flow

User question → Embedding (384d) → Centroid comparison → Top 3 KBs → RAG Pipeline (Hybrid Search → Rerank → MMR) → Response with sources

Practical Example

Imagine a tenant with 3 KBs:

  • Product KB: Feature documentation, usage guides
  • Support KB: Troubleshooting, known errors, procedures
  • Billing KB: Plans, pricing, invoices, payments

If the user asks “how do I change my plan?”, the Billing centroid will have the highest similarity, followed possibly by Product. The Support KB will be excluded or have low relevance.

Centroid Cache in Redis

Recalculating centroids for every question would be expensive. That’s why Citai caches centroids in Redis:

  • 24-hour TTL — centroids are recalculated once a day
  • Automatic invalidation — when uploading a new document or reprocessing chunks, the cache is invalidated
  • Efficient calculation — average of all embedding vectors in the KB
When should you split your KBs?
  • Split when you have clearly separated topics (product, support, sales)
  • Don't split by format (not one KB for PDFs and another for DOCX)
  • Use the KB Health Score to verify each KB has sufficient content
  • If a KB has a low score, consider merging it with a related one

Smart Routing vs Manual Selection

Aspect Smart Routing Manual selection
User experience Transparent Requires choosing KB
Accuracy High (based on semantic similarity) Depends on the user
Multi-KB Searches Top 3 automatically Only searches the selected one
Configuration Automatic Requires selection UI
Ideal for Public widget, APIs Internal panel, Playground

Activation in Citai

  • Internal chat: “Auto” button that activates Smart Routing. If you manually select a KB, automatic routing is deactivated
  • Widget: When an API key has access to multiple KBs, Smart Routing is enabled by default
  • Playground: Always manual selection (for debug and testing)

Conclusion

Smart Routing eliminates the friction of choosing knowledge bases manually. Using embedding centroids and cosine similarity, Citai routes each question to the most relevant KBs automatically — improving response accuracy and simplifying the user experience.


Let AI choose the best knowledge base for you. Try Smart Routing in Citai →

Try Citai for free

Create your intelligent knowledge base in minutes. No credit card required.

Create free account