I saved a FAISS index with save_local and loaded it with FAISS.load_local. Now similarity_search fails with an AssertionError (or I get a ValueError about allow_dangerous_deserialization).
Why this happens
A LangChain vector store saves the vectors, but not the embedding model. When you load it, you pass an embedding object, and LangChain uses it for queries. If that object isn't the same model that built the store, the query vectors have a different size, and FAISS raises its dimension assertion. The allow_dangerous_deserialization error is a separate issue: newer LangChain versions refuse to load the pickled metadata file unless you confirm you trust it.
Answer 1: Load with exactly the same embedding model
from langchain_community.vectorstores import FAISS
from langchain_huggingface import HuggingFaceEmbeddings
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
db = FAISS.from_documents(docs, embeddings)
db.save_local("faiss_index")
# later, possibly in another script
db = FAISS.load_local("faiss_index", embeddings,
allow_dangerous_deserialization=True)
db.similarity_search("my question", k=5)
Only set allow_dangerous_deserialization=True for files you created yourself or fully trust, because loading a pickle can run arbitrary code.
