Hybrid search for RAG: BM25 plus vectors, merged with reciprocal rank fusion
Hybrid search runs two retrievers on every query, BM25 keyword search and vector (embedding) search, and merges their results. It fixes the best-known weakness of embeddings: they capture meaning but blur exact tokens, so a query for invoice INV-20931 , error ECONNRESET or a person's name can return documents that are merely about invoices, network errors or people. The usual way to merge the two…
Hybrid search combines two retrievers: BM25 keyword search and vector (embedding) search, merging their results to address the weaknesses of each method. BM25 excels at capturing meaning but struggles with exact tokens, while embeddings excel at exact terms but lose context. Reciprocal rank fusion (RRF) merges the rankings by using ranks instead of scores, adding 1 / (k + rank) for each document in the two lists and summing the results.
The constant k is typically set to 60, requiring no score normalization or training. The hybrid search implementation is provided in plain Python.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.