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:
Sidchat95 2023-08-03 23:31:43 -05:00 committed by GitHub
parent 873a80e496
commit 812419d946
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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