liveBook · Manning

Reciprocal rank fusion

As explained in Designing AI Systems

Reciprocal rank fusion is a rank-aggregation algorithm that combines result lists using the reciprocal positions of items rather than their scores.

Reciprocal Rank Fusion (RRF) combines independently ranked result lists by position rather than raw scores. For each result, it adds 1/(k + rank), typically using k=60. This avoids comparing incompatible vector-similarity and keyword-ranking scales: items appearing near the top of both lists receive the strongest combined ranking. section 5.5.3

Use RRF when a retrieval service must merge heterogeneous search paths:

  • Run vector and keyword searches independently, preserving each path's ranked list. section 5.5.4
  • Retrieve more candidates than the caller requests; fetching twice top_k lets results ranked outside either short list compete after fusion. section 5.5.4
  • Prefer RRF over weighted score averages when score distributions vary across retrieval methods or datasets; weighted normalization can distort rankings and requires fragile tuning. section 5.5.3
  • Keep both retrieval methods behind a common result interface so callers receive the same SearchResult shape and can switch between vector and hybrid search. section 5.5.4 section 5.7

Hybrid search flow

A caller submits a text query to hybrid_search. The vector path embeds it and performs cosine-similarity retrieval; the keyword path converts it to a tsquery and applies PostgreSQL full-text ranking. RRF merges both ranked lists, and the service returns one result list ordered by combined relevance. section 5.5.4

Figure 5.8 Hybrid search in the Data Service. A text query enters the search method and follows two parallel paths. The vector path embeds the query through the Model Service and runs a cosine similarity search against stored vectors. The keyword path converts the query into a tsquery and runs a full-text search with ts_rank scoring against the same chunks table. Both paths return ranked result lists, which Reciprocal Rank Fusion merges into a single ranked list by combining positional scores. The fused results are returned to the calling workflow.

Trace the two retrieval paths from one query through candidate ranking, RRF merging, and the final result returned to the calling workflow. section 5.5.4

How Designing AI Systems covers it

How deep it goes
Defines the reciprocal-rank formula, explains its rationale, and applies it in orchestration without training or score normalization internals.
Examples
Uses parallel vector and PostgreSQL keyword searches, doubled candidate retrieval, and a fused SearchResult list.
What it assumes
Assumes independently ranked vector and keyword searches, while treating their incompatible score scales as the problem to avoid.
What you can do after
Apply it via hybrid_search to merge vector and keyword results without tuning score scales.
How it connects
Connects hybrid search with vector search, keyword search, cosine similarity, full-text search, and score normalization.

Also explained in

Compare how 6 books explain reciprocal rank fusion →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.