Skip to content

Commit

Permalink
Avoid backwards incompatibility due to main_distance_function
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaarsen committed Nov 26, 2024
1 parent 629cdc2 commit d8f4c3d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sentence_transformers/evaluation/TripletEvaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(
write_csv: bool = True,
truncate_dim: int | None = None,
similarity_fn_names: list[Literal["cosine", "dot", "euclidean", "manhattan"]] | None = None,
main_distance_function: str | SimilarityFunction | None = "deprecated",
):
"""
Initializes a TripletEvaluator object.
Expand Down Expand Up @@ -107,6 +108,13 @@ def __init__(
assert len(self.anchors) == len(self.positives)
assert len(self.anchors) == len(self.negatives)

if main_distance_function != "deprecated" and main_similarity_function is None:
main_similarity_function = main_distance_function
logger.warning(
"The 'main_distance_function' parameter is deprecated. Please use 'main_similarity_function' instead. "
"'main_distance_function' will be removed in a future release."
)

self.main_similarity_function = (
SimilarityFunction(main_similarity_function) if main_similarity_function else None
)
Expand Down

0 comments on commit d8f4c3d

Please sign in to comment.