Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaarsen committed Jun 3, 2024
2 parents 5d1856f + cb35f0d commit 4f38caf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,15 @@ def __call__(
fOut.write("\n")
fOut.close()

if self.main_score_function is None:
score_function = max(
[(name, scores[name]["map@k"][max(self.map_at_k)]) for name in self.score_function_names],
key=lambda x: x[1],
)[0]
self.primary_metric = f"{score_function}_map@{max(self.map_at_k)}"
else:
self.primary_metric = f"{self.main_score_function.value}_map@{max(self.map_at_k)}"
if not self.primary_metric:
if self.main_score_function is None:
score_function = max(
[(name, scores[name]["map@k"][max(self.map_at_k)]) for name in self.score_function_names],
key=lambda x: x[1],
)[0]
self.primary_metric = f"{score_function}_map@{max(self.map_at_k)}"
else:
self.primary_metric = f"{self.main_score_function.value}_map@{max(self.map_at_k)}"

metrics = {
f"{score_function}_{metric_name.replace('@k', '@' + str(k))}": value
Expand Down
4 changes: 2 additions & 2 deletions sentence_transformers/evaluation/SequentialEvaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def __call__(
scores.append(evaluation)
evaluation = {f"evaluator_{evaluator_idx}": evaluation}
else:
if hasattr(evaluation, "primary_metric"):
scores.append(evaluation[evaluation.primary_metric])
if hasattr(evaluator, "primary_metric"):
scores.append(evaluation[evaluator.primary_metric])
else:
scores.append(evaluation[list(evaluation.keys())[0]])

Expand Down

0 comments on commit 4f38caf

Please sign in to comment.