Reciprocal rank fusion (RRF)
Definition
A way to merge ranked result lists into one by scoring each document on its positions in the lists, not their raw scores.
In more detail
Each list a document appears in adds 1 / (k + rank) to its score, where rank starts at 1 and k is a constant, 60 by default in Elasticsearch. A document ranked second by keyword search and fifth by vector search beats one that tops a single list and is missing from the other.
It is the usual way to combine BM25 and embedding search in hybrid search, because the two produce scores on different scales that cannot be added directly. It needs no tuning, which is its appeal; a reranker can still reorder the fused top results.
Related terms
BM25
A classic keyword relevance function that scores documents by term frequency and rarity, adjusted for document length. Still a strong baseline.
Embedding
A vector representation of text or other data that places items with similar meaning close together, so they can be searched by similarity.
Hybrid search
Combining keyword search, such as BM25, with vector search and merging the results into one ranking, often with reciprocal rank fusion.
Reranking
Re-scoring an initial set of retrieved results with a slower, more accurate model before passing only the best few on to the LLM.
Read more about Reciprocal rank fusion (RRF)
- Hybrid search and reranking in Postgres
Combine Postgres full-text search and pgvector with reciprocal rank fusion in one SQL query, rerank the top results with a cross-encoder, and measure the gain.
- Embeddings and vector search
Turning text into vectors to find similar items, alone or with keywords.
- Hybrid search
Combining keyword search, such as BM25, with vector search and merging the results into one ranking, often with reciprocal rank fusion.