One of our nation‚Äôs top legal minds, who will continue Justice Breyer‚Äôs legacy of excellence.', metadata={'source': '../../../state_of_the_union.txt'})Serializing and De-Serializing to bytesyou can pickle the FAISS Index by these functions. If you use embeddings model which is of 90 mb (sentence-transformers/all-MiniLM-L6-v2 or any other model), the resultant pickle size would be more than 90 mb. the size of the model is also included in the overall size. To overcome this, use the below functions. These functions only serializes FAISS index and size would be much lesser. this can be helpful if you wish to store the index in database like sql.pkl = db.serialize_to_bytes() # serializes the faiss indexembeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")db = FAISS.deserialize_from_bytes(embeddings = embeddings, serialized = pkl) # Load the indexMerging‚ÄãYou can also merge two FAISS vectorstoresdb1 = FAISS.from_texts(["foo"], embeddings)db2 = FAISS.from_texts(["bar"], embeddings)db1.docstore._dict    {'068c473b-d420-487a-806b-fb0ccea7f711': Document(page_content='foo', metadata={})}db2.docstore._dict    {'807e0c63-13f6-4070-9774-5c6f0fbb9866': Document(page_content='bar', metadata={})}db1.merge_from(db2)db1.docstore._dict    {'068c473b-d420-487a-806b-fb0ccea7f711': Document(page_content='foo', metadata={}),     '807e0c63-13f6-4070-9774-5c6f0fbb9866': Document(page_content='bar', metadata={})}Similarity Search with filtering‚ÄãFAISS vectorstore can also support filtering, since the FAISS does not natively support filtering we have to do it manually. This is done by first fetching more results than k and then filtering them. You can filter the documents based on metadata. You can also set the fetch_k parameter when calling any search method to set how many documents you want to fetch before filtering. Here is a small example:from langchain.schema import Documentlist_of_documents = [    Document(page_content="foo", metadata=dict(page=1)),
Facebook AI Similarity Search (Faiss) is a library for efficient similarity search and clustering of dense vectors. It contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM. It also contains supporting code for evaluation and parameter tuning.
Facebook AI Similarity Search (Faiss) is a library for efficient similarity search and clustering of dense vectors. It contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM. It also contains supporting code for evaluation and parameter tuning. ->: One of our nation‚Äôs top legal minds, who will continue Justice Breyer‚Äôs legacy of excellence.', metadata={'source': '../../../state_of_the_union.txt'})Serializing and De-Serializing to bytesyou can pickle the FAISS Index by these functions. If you use embeddings model which is of 90 mb (sentence-transformers/all-MiniLM-L6-v2 or any other model), the resultant pickle size would be more than 90 mb. the size of the model is also included in the overall size. To overcome this, use the below functions. These functions only serializes FAISS index and size would be much lesser. this can be helpful if you wish to store the index in database like sql.pkl = db.serialize_to_bytes() # serializes the faiss indexembeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")db = FAISS.deserialize_from_bytes(embeddings = embeddings, serialized = pkl) # Load the indexMerging‚ÄãYou can also merge two FAISS vectorstoresdb1 = FAISS.from_texts(["foo"], embeddings)db2 = FAISS.from_texts(["bar"], embeddings)db1.docstore._dict    {'068c473b-d420-487a-806b-fb0ccea7f711': Document(page_content='foo', metadata={})}db2.docstore._dict    {'807e0c63-13f6-4070-9774-5c6f0fbb9866': Document(page_content='bar', metadata={})}db1.merge_from(db2)db1.docstore._dict    {'068c473b-d420-487a-806b-fb0ccea7f711': Document(page_content='foo', metadata={}),     '807e0c63-13f6-4070-9774-5c6f0fbb9866': Document(page_content='bar', metadata={})}Similarity Search with filtering‚ÄãFAISS vectorstore can also support filtering, since the FAISS does not natively support filtering we have to do it manually. This is done by first fetching more results than k and then filtering them. You can filter the documents based on metadata. You can also set the fetch_k parameter when calling any search method to set how many documents you want to fetch before filtering. Here is a small example:from langchain.schema import Documentlist_of_documents = [    Document(page_content="foo", metadata=dict(page=1)),