Hybrid retrieval and reranking
Hybrid retrieval combines dense vector similarity with sparse keyword signals in Qdrant. Optional Cohere reranking reorders candidates before the engine injects context into the agent prompt. Tuning weights and top_k / top_n balances recall, latency, and token cost.
Pipeline overview: Vector RAG pipeline. Memory types: Memory types.
When to use hybrid
| Scenario | Recommendation |
|---|---|
| Product docs with exact SKUs, error codes | Hybrid (sparse helps exact tokens) |
| Narrative FAQs, conceptual questions | Dense may suffice; hybrid still safe default |
| Short pages, small corpus | Lower top_k, skip rerank |
Hybrid requires retrieval.mode: "hybrid" and ARCFLOW_QDRANT_HYBRID=true at runtime.
Retrieval config
| Field | Role |
|---|---|
mode | "dense" or "hybrid" |
top_k | Candidates fetched from Qdrant before rerank |
dense_weight | Weight for vector score in hybrid fusion |
sparse_weight | Weight for sparse score in hybrid fusion |
rerank.top_n | Final chunks after rerank (≤ top_k) |
Weights should reflect your corpus. Start with 0.65 / 0.35 and adjust using trace chunk_count and answer quality on a fixed eval set.
Environment
Without ARCFLOW_QDRANT_HYBRID=true, the engine may fall back to dense behavior even when config says hybrid. Verify in integration tests.
Dense-only baseline
Compare latency and MemoryRetrieved.total_bytes against hybrid on the same queries before committing weights.
Rerank stage
Cohere rerank receives query + chunk texts server-side (not in trace data policy traces). Config:
| Outcome | Error / trace |
|---|---|
| Success | MemoryRetrieved with lower chunk_count |
| Provider failure | RerankError, HTTP 502 |
| Missing API key | Provider error at rerank call |
Disable rerank during dev to reduce dependencies:
(Omit rerank object entirely.)
Full memory_config example
Tuning workflow
- Ingest representative docs (Knowledge ingestion)
- Run fixed queries with
top_k=12, no rerank; record answers - Enable hybrid; sweep weights in 0.1 steps on eval set
- Add rerank with
top_n=4; compare quality vs latency - Lock config in registry-published chat workflow
Trace metadata to watch:
Lower total_bytes after rerank usually means tighter context and faster provider turns.
Static product note
Site knowledge ingests into site kb_namespace. Published chat agents should use the same namespace in memory_config so browser runs retrieve the operator-ingested corpus. See Workflow registry.