From 3ae11b7582fb30b5524abc06fe9126ead90cb27d Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 5 Jul 2023 15:56:40 -0400 Subject: [PATCH] Handle kwargs in FAISS.load_local() (#6987) - Description: This allows parameters such as `relevance_score_fn` to be passed to the `FAISS` constructor via the `load_local()` class method. - Tag maintainer: @rlancemartin @eyurtsev --- langchain/vectorstores/faiss.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/langchain/vectorstores/faiss.py b/langchain/vectorstores/faiss.py index e92c7eb8ac2..bd5eca018e2 100644 --- a/langchain/vectorstores/faiss.py +++ b/langchain/vectorstores/faiss.py @@ -618,7 +618,11 @@ class FAISS(VectorStore): @classmethod def load_local( - cls, folder_path: str, embeddings: Embeddings, index_name: str = "index" + cls, + folder_path: str, + embeddings: Embeddings, + index_name: str = "index", + **kwargs: Any, ) -> FAISS: """Load FAISS index, docstore, and index_to_docstore_id from disk. @@ -638,7 +642,9 @@ class FAISS(VectorStore): # load docstore and index_to_docstore_id with open(path / "{index_name}.pkl".format(index_name=index_name), "rb") as f: docstore, index_to_docstore_id = pickle.load(f) - return cls(embeddings.embed_query, index, docstore, index_to_docstore_id) + return cls( + embeddings.embed_query, index, docstore, index_to_docstore_id, **kwargs + ) def _similarity_search_with_relevance_scores( self,