Hybrid BM25 and vector search ranking methods
Hybrid BM25 and vector search ranking methods unify lexical precision and dense semantic retrieval to optimize document relevance. Retrieval systems commonly blend these modalities through score-based approaches like Relative Score Fusion and weighted sums, or rank-based methods such as Reciprocal Rank Fusion. Alternatively, pipelines deploy sequential architectures where dense embedding models re-rank candidate documents initially retrieved by BM25.
Key facts
- BM25 evaluates documents using term frequency saturation, document length normalization, and inverse document frequency [1][2][3].
- Full-text search misses relevant documents when wording changes, while vector search can be unreliable when an exact identifier token is the retrieval objective [4].
- Combining retrieval strategies mitigates errors and reduces hallucinations that occur when either approach is used alone, improving overall search reliability [5].
- Reciprocal Rank Fusion calculates document scores using the formula 1/(rank + k), performing best in empirical experiments when k is set to a small constant such as 60 [6][7].
- Relative Score Fusion normalizes scores from each retrieval method to a common range from 0 to 1 before combination to preserve relative importance across differing score distributions [8][9].
- Relevance scores vary in range across methods: BM25 has no upper limit, whereas vector cosine similarity spans 0.333 to 1.00 and Euclidean or dot product spans 0 to 1 [10][11][12].
- Re-ranking BM25 results with embedding APIs is budget-friendly and most effective for English text, while non-English retrieval performs best using a hybrid model with BM25 [13][14].
Core Retrieval Mechanics
Hybrid search combines lexical search and semantic search to produce results that are precise and contextually relevant [15]. Modern full-text search systems frequently use BM25 as the default scoring algorithm, such as in Apache Lucene and MongoDB Atlas Search [16]. BM25 scores documents by balancing three specific factors: term frequency saturation, document length normalization, and inverse document frequency [1][2][3]. Under term frequency saturation, a word appearing 100 times does not score 100 times higher than a single appearance [1]. Document length normalization ensures that longer documents do not automatically win merely because they contain more words [2]. Inverse document frequency ensures that rare terms carry more weight than common terms [3].
In contrast, dense vectors are generated by machine learning models trained on large amounts of data to capture semantic meaning and context [17]. Vector search ranks matches by semantic closeness using distance metrics such as cosine similarity, Euclidean distance, or dot product [12]. While lexical search misses relevant documents when phrasing changes, vector search can be unreliable when an exact identifier token itself is the point [4]. Combining both methods into a hybrid workflow mitigates errors and reduces hallucinations that occur when individual methods operate in isolation [5].
Rank and Score Fusion Methods
Systems employ several ranking techniques to unify disparate result sets into a single ranked list [18][8].
Reciprocal Rank Fusion
Reciprocal Rank Fusion assigns a reciprocal rank score to each document based on its position in rankings generated by multiple retrieval methods [18]. The score for each document in a ranked list is calculated as 1/(rank + k), where rank indicates its position and k is a balancing constant [6]. Setting k to a small value such as 60 yields the best performance in experimental evaluations [7]. The search engine sums the reciprocal rank scores obtained from each retrieval system for each document, sorting the final outputs by this combined score [19].
The upper limit of an RRF score is bounded by the number of queries fused together, with each individual query contributing a maximum of approximately 1/k [20]. In addition, search implementations can assign different weights to search strategies before combining their scores, such as applying a weighting multiplier to vector queries to alter their importance in the hybrid ranking [21][22].
Relative Score Fusion and Linear Combinations
Ranking algorithms vary for each retrieval method, resulting in distinct score ranges and magnitudes [10]. BM25 has no upper limit on relevance scores [11]. Conversely, HNSW vector search produces scores bounded between 0.333 and 1.00 for cosine similarity, or between 0 to 1 for Euclidean distance and dot product [12]. Relative Score Fusion resolves this difference by normalizing scores from each search method to a standard scale from 0 to 1 before merging [8]. This normalization preserves the relative importance of each search strategy even when their original score distributions diverge [9].
Another ranking approach establishes hard constraints using metadata filters before executing full-text and vector searches in parallel, then merges the resulting scores using a weighted sum [23].
Architecture and Re-Ranking Pipelines
Retrieval systems implement hybrid ranking across multiple operational patterns [23][13][24]:
- Parallel Execution and Re-Ranking: In parallel setups, full-text and vector retrievers execute alongside one another, merge via rank fusion, and can subsequently pass results to a semantic ranker that reorders candidates using semantically rich content fields [25].
- Two-Stage Retrieval with BM25: A budget-friendly retrieval pattern uses BM25 as an initial first-stage retriever and re-ranks the returned documents using semantic embedding APIs [13]. On benchmark evaluations, re-ranking BM25 results proves most effective for English text [13]. For non-English retrieval, re-ranking improves performance, but deploying a hybrid model alongside BM25 achieves superior results at higher cost [14].
- Candidate Filtering and Routing: Full-text search can serve to narrow a candidate set by keyword, phrase, or metadata prior to running vector search for semantic ranking inside that subset [24]. Alternatively, systems can run vector search first and fall back to full-text retrieval when confidence is low or when a query resembles an exact identifier [26].
Sources
-
Full-text search for RAG apps: BM25 & hybrid search redis.io
- [1]
Term frequency (TF) saturation: a word appearing 100 times doesn't score 100x higher than one appearance.
- [2]
Document length normalization: longer documents don't automatically win just because they contain more words.
- [3]
Inverse document frequency (IDF): rare terms carry more weight than common ones.
- [4]
Full-text search misses relevant documents when wording changes ("terminate" vs. "cancel"). Vector search can be unreliable for exact identifiers when the token itself is the point
- [23]
Start with metadata filters like tenant ID, product, or document type as hard constraints. Then run full-text search and vector search inside that boundary, and combine the scores with a weighted sum.
- [24]
Use full-text search to narrow the candidate set (by keyword, phrase, or metadata fields). Run vector search inside that smaller set to rank by meaning.
- [26]
Sometimes you run vector search first, but if confidence is low—or the user query looks like an identifier—you fall back to full-text.
- [1]
-
Better RAG Results With Reciprocal Rank Fusion www.mongodb.com
- [5]
This reduces hallucination and mitigates errors that might occur due to the use of individual methods, thus improving performance and reliability of search results.
- [6]
Score = 1/(rank+k)
- [18]
An RRF algorithm assigns a reciprocal rank score based on the document ranks from multiple retrieval methods.
- [21]
In some implementations, different search strategies can be assigned different weights before combining their scores.
- [5]
-
Hybrid Search Scoring (RRF) - Azure AI Search learn.microsoft.com
- [7]
Experiments show the algorithm performs best when you set k to a small value, such as 60.
- [10]
Scores are generated by ranking algorithms that vary for each method. Each algorithm has its own range and magnitude.
- [11]
BM25 algorithm No upper limit.
- [12]
0.333 - 1.00 (Cosine), 0 to 1 for Euclidean and DotProduct.
- [19]
For each document, the engine sums the reciprocal rank scores obtained from each search system, producing a combined score for each document.
- [20]
Upper limit is bounded by the number of queries being fused, with each query contributing a maximum of approximately 1/k to the RRF score
- [22]
You can also weight vector queries to increase or decrease their importance in a hybrid query.
- [25]
Semantic ranking occurs after RRF merging of results.
- [7]
-
Hybrid Search Explained With An In-Depth Guide www.mongodb.com
- [8]
RSF normalizes the scores from each search method, scaling them to a common range (typically 0 to 1), before combining them.
- [9]
This normalization ensures that the relative importance of each search method is preserved, even if their original score distributions differ.
- [15]
Hybrid search combines lexical search and semantic search to deliver results that are both precise and contextually relevant.
- [16]
BM25 is the default scoring algorithm in Apache Lucene and MongoDB Atlas Search.
- [17]
Dense vectors, generated by machine learning models trained on large amounts of data, capture the semantic meaning and context of documents.
- [8]
-
Evaluating Embedding APIs for Information Retrieval aclanthology.org
- [13]
We find that re-ranking BM25 results using the APIs is a budget-friendly approach and is most effective on English, in contrast to the standard practice, i.e., employing them as first-stage retrievers.
- [14]
For non-English retrieval, re-ranking still improves the results, but a hybrid model with BM25 works best albeit at a higher cost.
- [13]