mirror of
https://github.com/hwchase17/langchain
synced 2024-11-04 06:00:26 +00:00
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:
parent
6092422e10
commit
f5faac8859
@ -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,"
|
||||
|
Loading…
Reference in New Issue
Block a user