Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-412

Reciprocal Rank Fusion Score

Problem

Reciprocal rank fusion contributes 1 / (k + rank) for a document at the given rank, where rank starts at one and k is the smoothing constant.

Given the rank and k, return the contribution.

Hint

The constant damps the influence of very high ranks.

Test cases

case 1
in: [1,60]
expected: 0.01639344262295082
case 2
in: [10,60]
expected: 0.014285714285714285
case 3
in: [3,0]
expected: 0.3333333333333333
Starter codePython
def reciprocal_rank_fusion_score(rank, k):
    # Your code here
    pass

3 test cases · run your code against them in the editor