Skip to content

Commit

Permalink
fix: add logging for RetrievalEvaluator NaN values for similarity sco…
Browse files Browse the repository at this point in the history
…res (#1398)

Fixes #1389
  • Loading branch information
KennethEnevoldsen authored Nov 11, 2024
1 parent 9681eb3 commit cc7a106
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,5 @@ sb.ipynb
tests/create_meta/model_card.md

# removed results from mteb repo they are now available at: https://github.com/embeddings-benchmark/results
results/
results/
uv.lock
7 changes: 6 additions & 1 deletion mteb/evaluation/evaluators/RetrievalEvaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ def search(
cos_scores = self.score_functions[score_function](
query_embeddings, sub_corpus_embeddings
)
cos_scores[torch.isnan(cos_scores)] = -1
is_nan = torch.isnan(cos_scores)
if is_nan.sum() > 0:
logger.warning(
f"Found {is_nan.sum()} NaN values in the similarity scores. Replacing NaN values with -1."
)
cos_scores[is_nan] = -1

# Get top-k values
cos_scores_top_k_values, cos_scores_top_k_idx = torch.topk(
Expand Down

0 comments on commit cc7a106

Please sign in to comment.