Skip to content

Commit 9641080

Browse files
committed
Change recall computation to be as ann-benchmarks'
1 parent a1ba1b1 commit 9641080

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

engine/base_client/search.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,17 @@ def _search_one(cls, query, top: Optional[int] = None):
5050

5151
precision = 1.0
5252
if query.expected_result:
53-
ids = set(x[0] for x in search_res)
54-
precision = len(ids.intersection(query.expected_result[:top])) / top
55-
53+
# This was Qdrant original recall calculation
54+
# ids = set(x[0] for x in search_res)
55+
# precision = len(ids.intersection(query.expected_result[:top])) / top
56+
# This is ann-benchmark recall calculation
57+
epsilon = 1e-3
58+
threshold = query.expected_scores[top - 1] + epsilon
59+
actual = 0.0
60+
for cand_res in search_res[:top]:
61+
if cand_res[1] <= threshold:
62+
actual += 1
63+
precision = actual/top
5664
return precision, end - start
5765

5866
def search_all(

0 commit comments

Comments
 (0)