There are two issues with the code you provided.
First, the k value should be changed. You didn't share the part of your code where you defined k but it appears you are using k = 60. That should be changed to k = 2.
Second, you are initializing the rank at 1, when it should init at 0.
To make these changes take this code:
combined_scores = {}
k = ?????
for rank, point in enumerate(dense_results, start=1):
if point.id not in combined_scores:
combined_scores[point.id] = 0
combined_scores[point.id] += 1 / (k + rank)
for rank, point in enumerate(sparse_results, start=1):
if point.id not in combined_scores:
combined_scores[point.id] = 0
combined_scores[point.id] += 1 / (k + rank)
fused_results = sorted(combined_scores.items(), key=lambda x: x[1], reverse=True)
and change it to this:
combined_scores = {}
k = 2
for rank, point in enumerate(dense_results):
if point.id not in combined_scores:
combined_scores[point.id] = 0
combined_scores[point.id] += 1 / (k + rank)
for rank, point in enumerate(sparse_results):
if point.id not in combined_scores:
combined_scores[point.id] = 0
combined_scores[point.id] += 1 / (k + rank)