liveBook · Manning

Reciprocal rank fusion

As explained in AI Agents and Applications

Reciprocal Rank Fusion is a result-merging method that scores documents by summing reciprocal rank contributions across multiple ranked lists.

Reciprocal Rank Fusion (RRF) merges ranked results from multiple searches. Each document receives a reciprocal-rank score from every list, and documents recurring across lists rise in the final ranking. section 9.6 section 10.7.4

In retrieval-augmented generation, generate several query variations, retrieve results for each, accumulate scores, rerank the combined documents, and send only the top results to the language model. section 10.7.4

The practical RRF workflow is:

  • Generate three to five alternative queries that express different phrasings or perspectives on the user’s question. section 9.6
  • Retrieve a ranked result list for each generated query. section 10.7.4
  • Add 1 / (rank + k) for each document occurrence, using k=60 as the typical smoothing value. section 9.6
  • Sort by cumulative score and pass the selected top results into the final RAG prompt. section 10.7.4

A multi-query RAG chain

A LangChain pipeline can map a retriever over generated questions, apply reciprocal_rank_fusion, keep the top three documents, and inject them into an answer prompt. A question about a trip to Brighton then produces a synthesized list of travel tips.

How AI Agents and Applications covers it

How deep it goes
Explains the scoring formula, cumulative reranking, Python implementation, LangChain composition, and final prompt integration.
Examples
Demonstrates five query variations, vector-store retrieval, top-three selection, and a Brighton travel question answered through a RAG chain.
What it assumes
Assumes multi-query generation and ranked retrieval, while teaching RRF scoring and its insertion into a larger RAG chain.
What you can do after
Build RAG fusion with LangChain by generating queries, retrieving results, applying RRF, selecting top documents, and synthesizing an answer.
How it connects
Connects multi-query retrieval, vector stores, hybrid search, BM25, query routing, and retrieval-augmented generation.

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 and Applications. The section links point to the parts of the book it draws on.