addition of cosine distance function for faiss (#9939)

- Description: added the _cosine_relevance_score_fn to
_select_relevance_score_fn of faiss.py to enable the use of cosine
distance for similarity for this vector store and to comply with the
Error Message, that implies, that cosine should be a valid distance
strategy
- Issue: no relevant Issue found, but needed this function myself and
tested it in a private repo
  - Dependencies: none
This commit is contained in:
Jan-Luca Barthel 2023-08-29 19:29:51 +02:00 committed by GitHub
parent 6092422e10
commit f5faac8859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -736,6 +736,8 @@ class FAISS(VectorStore):
elif self.distance_strategy == DistanceStrategy.EUCLIDEAN_DISTANCE:
# Default behavior is to use euclidean distance relevancy
return self._euclidean_relevance_score_fn
elif self.distance_strategy == DistanceStrategy.COSINE:
return self._cosine_relevance_score_fn
else:
raise ValueError(
"Unknown distance strategy, must be cosine, max_inner_product,"