liveBook · Manning

Reciprocal rank fusion

As explained in AI Agents in Action, Second Edition

Reciprocal rank fusion combines ranked result lists by summing the reciprocal of each result's rank offset across the lists.

Reciprocal Rank Fusion (RRF) combines ranked result lists by ignoring raw scores and summing each result’s reciprocal rank offset. It is commonly used when hybrid search joins vector results with keyword results whose scores use incompatible scales. section 6.3.3

Use this mental model when merging search results:

  • Run vector and keyword searches in parallel, producing one ranked list from each method. section 6.3.3
  • Score each document with the sum of 1/(k + rank) across the lists, typically using k = 60. section 6.3.3
  • Favor documents that appear near the top of both lists; a document ranked first in both receives the strongest fused position. section 6.3.3
  • Avoid calibrating BM25, cosine-similarity, or other backend scores because RRF depends only on rank positions. section 6.3.3

Hybrid search for grounded answers

A query can be decomposed into semantic meaning and exact keywords. A hybrid search service runs both searches, applies RRF internally, and returns one reranked context. An agent can instead call vector and keyword tools separately, judge their relevance, and answer using the returned passages with exact references. section 6.3.3

Figure 6.7 The top of the figure shows how a user query could be converted to a hybrid search by decomposing the query into keywords and semantic meaning. The bottom of the figure shows how an agent could use the same search mechanism as a set of tools to perform a semantic (vector) and keyword query.

Compare service-managed hybrid search with an agent that invokes semantic and keyword searches as separate tools. section 6.3.3

How AI Agents in Action, Second Edition covers it

How deep it goes
Defines the rank-only formula, explains its score-independence, and stops short of implementation code for the fusion function.
Examples
Uses parallel vector and keyword result lists, a typical constant of 60, and an agent selecting separate search tools.
What it assumes
Assumes familiarity with ranked search results and distinguishes vector similarity from exact keyword retrieval.
What you can do after
Apply it via hybrid search to merge incompatible ranked outputs into grounded, comprehensive retrieval context.
How it connects
Connects hybrid search with vector search, keyword search, BM25, cosine similarity, reranking, and retrieval-augmented agents.

Also explained in

Compare how 3 books explain reciprocal rank fusion →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents in Action, Second Edition. The section links point to the parts of the book it draws on.