fix: normalize local CrossEncoder reranking scores for relevance threshold (#20228)

* Update utils.py

* Update retrieval.py

* Update utils.py

* Update retrieval.py

* add env var

* rename to SENTENCE_TRANSFORMERS_CROSS_ENCODER_SIGMOID_ACTIVATION_FUNCTION
This commit is contained in:
Classic298 authored and GitHub committed 2025-12-31 15:48:31 -05:00
1 parent 4f918e7aa4
commit 431632d530
2 files changed
+14

No files matched your search

+7
View File
@@ -762,6 +762,13 @@ else:
except Exception:
SENTENCE_TRANSFORMERS_CROSS_ENCODER_MODEL_KWARGS = None
# Whether to apply sigmoid normalization to CrossEncoder reranking scores.
# When enabled (default), scores are normalized to 0-1 range for proper
# relevance threshold behavior with MS MARCO models.
SENTENCE_TRANSFORMERS_CROSS_ENCODER_SIGMOID_ACTIVATION_FUNCTION = (
os.environ.get("SENTENCE_TRANSFORMERS_CROSS_ENCODER_SIGMOID_ACTIVATION_FUNCTION", "True").lower() == "true"
)
####################################
# OFFLINE_MODE
####################################