Week 6 · Enterprise AI

Merge rankings with RRF

0:00 / 3:00

20 seconds

Two lists, one answer.

BM25 and vectors disagree on order. Helix needs one ranked list before the prompt is built.

BM25 ranks1..nVector ranks1..nRRF1/(k+rank)Top kInto prompt
Lesson notesMerge rankings with RRF: the short version+

Week 6 · RAG and evals · about 3 minutes

What you will be able to do

Fuse BM25 and vector hit lists with Reciprocal Rank Fusion so docs found by both rise.

The idea

Reciprocal Rank Fusion scores each document as Σ 1/(k + rank) across lists. Documents that place well in both lists rise without tuning score scales.

k is a small constant (often 60). You do not need to calibrate BM25 scores against cosine similarity.

def rrf(*lists, k: int = 60):
    scores = {}
    for ranking in lists:
        for rank, doc_id in enumerate(ranking, start=1):
            scores[doc_id] = scores.get(doc_id, 0.0) + 1.0 / (k + rank)
    return sorted(scores, key=scores.get, reverse=True)

RRF merges ranks, not raw scores — that is the point.

Key takeaways

  • Score = Σ 1/(k + rank).
  • Agreement across lists wins.
  • No need to rescale BM25 vs cosine.

Part of the Forward Deployed Engineer roadmap. New to the role? Start with what a Forward Deployed Engineer does.