Pure vector retrieval can miss exact model names, error codes, and abbreviations. Pure keyword search can miss semantic variants. Hybrid retrieval broadens the candidate set first, then uses reranking and business filters to produce the final context.
Core concepts
Keyword search handles exact matches, vector search handles semantic recall, and filters handle tenant and permission boundaries. A reranker may compare only authorized candidates; its result must never bypass access control.
def reciprocal_rank_fusion(*ranked_lists: list[str], k: int = 60) -> list[str]:
scores: dict[str, float] = {}
for items in ranked_lists:
for rank, item in enumerate(items, start=1):
scores[item] = scores.get(item, 0) + 1 / (k + rank)
return [item for item, _ in sorted(scores.items(), key=lambda pair: pair[1], reverse=True)]
assert reciprocal_rank_fusion(['a', 'b'], ['b', 'c'])[0] in {'a', 'b'}
Steps
- Implement keyword and vector retrieval separately and attach document permission tags to every candidate.
- Merge candidates, then apply tenant, role, and document-status filters.
- Rerank or score the remaining candidates, keeping sources and scores for debugging.
- Evaluate exact, ambiguous, and cross-language question sets separately.
When to use it
It suits product search, technical support, and multilingual knowledge bases.
Common questions
Can reranking fix a permission problem? No. Permission filtering must happen before reranking.
How should fusion weights be chosen? Build a fixed baseline first, then adjust with labeled data rather than one example.
What if evidence is insufficient? Return a clear lack-of-evidence state instead of asking the model to invent facts.
Official references
OpenAI Retrieval; Qdrant filtering.
Last checked: 2026-11-16. Use the linked official documentation for current retrieval behavior.
