Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix confusing print statement in TranslationEvaluator #1894

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions sentence_transformers/evaluation/TranslationEvaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ def __call__(
if i == max_idx:
correct_src2trg += 1
elif self.print_wrong_matches:
print("i:", i, "j:", max_idx, "INCORRECT" if i != max_idx else "CORRECT")
print("Src:", self.source_sentences[i])
print("Trg:", self.target_sentences[max_idx])
print("Argmax score:", cos_sims[i][max_idx], "vs. correct score:", cos_sims[i][i])
print("\nIncorrect : Source", i, "is most similar to target", max_idx, "instead of target", i)
print("Source :", self.source_sentences[i])
print("Pred Target:", self.target_sentences[max_idx], f"(Score: {cos_sims[i][max_idx]:.4f})")
print("True Target:", self.target_sentences[i], f"(Score: {cos_sims[i][i]:.4f})")

results = zip(range(len(cos_sims[i])), cos_sims[i])
results = enumerate(cos_sims[i])
results = sorted(results, key=lambda x: x[1], reverse=True)
for idx, score in results[0:5]:
print("\t", idx, "(Score: %.4f)" % (score), self.target_sentences[idx])
for idx, score in results[:5]:
print("\t", idx, f"(Score: {score:.4f})", self.target_sentences[idx])

cos_sims = cos_sims.T
for i in range(len(cos_sims)):
Expand Down
Loading