Skip to main content

Corpus-coupled, drift-free routing for multi-collection RAG.

Project description

Master Assistant Query Routing (MAA)

Drift-free query routing for multi-collection RAG via parallel corpus probing.

Given a natural-language query, MAA decides which document collection(s) it belongs to — by probing every configured vector-store collection in parallel, scoring each from the actual retrieved chunks, and asking a routing LLM to read those chunks and return a structured JSON decision. The routing signal is the live corpus itself, so re-indexing your data updates routing automatically — there is no description or utterance list to keep in sync.

Paper: https://doi.org/10.5281/zenodo.20348330

Install

# everything — all providers (Gemini, OpenAI, Anthropic, Ollama) + Qdrant
pip install "master-assistant-query-routing[all]"

# or install only what you need
pip install "master-assistant-query-routing[openai,qdrant]"

Usage

import asyncio
from maa import route_query, Config
from maa.providers.openai import OpenAIEmbedder, OpenAIRoutingLLM
from maa.stores.qdrant import QdrantVectorStore

async def main():
    embedder = OpenAIEmbedder(api_key="sk-...", model="text-embedding-3-large")
    llm      = OpenAIRoutingLLM(api_key="sk-...", model="gpt-5.4-mini")
    store    = QdrantVectorStore(host="localhost", port=6333)

    cfg = Config(collections=["billing", "technical", "accounts"])

    result = await route_query(
        "why was I charged twice this month",
        cfg, embedder=embedder, llm=llm, store=store,
    )
    print(result["collections"])   # e.g. ['billing']

asyncio.run(main())

Returns a dict with collections (the routing decision), analysis (per-collection confidence + evidence), and reasoning. Pass verbose=True to also include the raw probe scores and retrieved chunks.

License

Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

master_assistant_query_routing-0.2.0.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

master_assistant_query_routing-0.2.0-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file master_assistant_query_routing-0.2.0.tar.gz.

File metadata

File hashes

Hashes for master_assistant_query_routing-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3efb3db0a933c92e28b4777bc02aab4be29867150c9610d8ba3674e14ff00c92
MD5 e7411d2d867b494768c4575189fe8b49
BLAKE2b-256 b27855b2f800b59124842057292076a3844fced810d6041eebdb4ee24d169968

See more details on using hashes here.

File details

Details for the file master_assistant_query_routing-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for master_assistant_query_routing-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 069295aa110c91c45fa81c0a59c1bee5bed12f391552c58831e053f0c24c7873
MD5 2a5d95bea29a1f7fee55ef7cef9a241b
BLAKE2b-256 dda9d0523cb0b8d0bec38a47d9976395d4439aa918d75d0f7bcacb9e8a3df0ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page