You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SASEvaluator returns negative scores when no cross encoder score in the batch is above 1 #13243
Describe the bug
For Cross Encoders that return raw logits, SASEvaluator only applies a sigmoid if at least one score in the batch is above 1. So the same answer gets a different score depending on the other answers in the batch, and a batch of only wrong answers returns negative scores. This happens with cross-encoder/ms-marco-MiniLM-L-6-v2, the model from the SASEvaluator docstring example.
Error message
No error. The scores are just wrong.
Expected behavior
A pair should get the same score in every batch, and scores should stay between 0 and 1.
Wrong answers have negative logits, so a batch without a good answer never passes > 1 and the raw logits are returned.
History: the > 1 check was added in #6877 and kept when the evaluator was rewritten in #7428. Haystack 1.x used the raw model output without it. A reviewer already questioned this line on #6877 (comment) and suggested abs(similarity_scores) > 1, but that would still depend on the batch, for example when all logits are between -1 and 1.
A possible fix is to decide based on the model instead: apply the sigmoid when the Cross Encoder's activation_fn is Identity. I'll open a PR with this fix and tests.
Activity