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
2025-12-31 21:48:31 +01:00
committed by GitHub
parent 4f918e7aa4
commit 431632d530
2 changed files with 14 additions and 0 deletions

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
####################################