From 8a836248b965ff45fd4ba38afc0a2a48d374d552 Mon Sep 17 00:00:00 2001
From: Nandan Thakur <nandant@gmail.com>
Date: Fri, 22 Oct 2021 22:43:39 +0200
Subject: [PATCH] fix: breaking change in top-k accuracy metric as kindly
 pointed out in issue #45

---
 beir/retrieval/custom_metrics.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/beir/retrieval/custom_metrics.py b/beir/retrieval/custom_metrics.py
index df51452..4b08226 100644
--- a/beir/retrieval/custom_metrics.py
+++ b/beir/retrieval/custom_metrics.py
@@ -100,7 +100,7 @@ def top_k_accuracy(
     logging.info("\n")
     
     for query_id, doc_scores in results.items():
-        top_hits[query_id] = sorted(doc_scores.keys(), key=lambda item: item[1], reverse=True)[0:k_max]   
+        top_hits[query_id] = [item[0] for item in sorted(doc_scores.items(), key=lambda item: item[1], reverse=True)[0:k_max]]
     
     for query_id in qrels:
         query_relevant_docs = set([doc_id for doc_id in qrels[query_id] if qrels[query_id][doc_id] > 0])