mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
Removing score threshold parameter of faiss _similarity_search_with_r… (#8093)
Removing score threshold parameter of faiss _similarity_search_with_relevance_scores as the thresholding part is implemented in similarity_search_with_relevance_scores method which calls this method. As this method is supposed to be a private method of faiss.py this will never receive the score threshold parameter as it is popped in the super method similarity_search_with_relevance_scores. @baskaryan @hwchase17
This commit is contained in:
parent
873a80e496
commit
812419d946
@ -727,7 +727,6 @@ class FAISS(VectorStore):
|
|||||||
"""Return docs and their similarity scores on a scale from 0 to 1."""
|
"""Return docs and their similarity scores on a scale from 0 to 1."""
|
||||||
# Pop score threshold so that only relevancy scores, not raw scores, are
|
# Pop score threshold so that only relevancy scores, not raw scores, are
|
||||||
# filtered.
|
# filtered.
|
||||||
score_threshold = kwargs.pop("score_threshold", None)
|
|
||||||
relevance_score_fn = self._select_relevance_score_fn()
|
relevance_score_fn = self._select_relevance_score_fn()
|
||||||
if relevance_score_fn is None:
|
if relevance_score_fn is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
@ -744,10 +743,4 @@ class FAISS(VectorStore):
|
|||||||
docs_and_rel_scores = [
|
docs_and_rel_scores = [
|
||||||
(doc, relevance_score_fn(score)) for doc, score in docs_and_scores
|
(doc, relevance_score_fn(score)) for doc, score in docs_and_scores
|
||||||
]
|
]
|
||||||
if score_threshold is not None:
|
|
||||||
docs_and_rel_scores = [
|
|
||||||
(doc, similarity)
|
|
||||||
for doc, similarity in docs_and_rel_scores
|
|
||||||
if similarity >= score_threshold
|
|
||||||
]
|
|
||||||
return docs_and_rel_scores
|
return docs_and_rel_scores
|
||||||
|
Loading…
Reference in New Issue
Block a user