openai-apilangchainfaisssimilarity-searchvectorstore

Kernel crashes when running a FAISS similarity search


I am working with langChain right now and created a FAISS vector store. Since today, my kernel crashes when running a similarity search on my vector store. Has anyone an idea why this is happening?

from langchain_community.document_loaders import PyPDFLoader
from langchain_community.vectorstores import FAISS

f = open('credentials.txt')
OPENAI_API_KEY = f.read()
embeddings_model = OpenAIEmbeddings(api_key=OPENAI_API_KEY)

document_loader = PyPDFLoader('filename.pdf')
text_splitter=RecursiveCharacterTextSplitter()
documents = document_loader.load_and_split(text_splitter)

vectorstore = FAISS.from_documents(documents, embeddings_model)
vectorstore.similarity_search('query')

MacBook Pro intel, python 3.9, jupyter notebook, langchain 0.2.0

Actually, I saved the vector store on my local machine and re-loaded it in later sessions. Since my kernel crashes, I tried to recreate the vector store. I tried to re-install faiss-cpu. I closed all 'heavy' programs on my machine. Unfortunately, I had no success and also couldn't find any help on the internet yet.


Solution

  • What version of faiss-cpu have you installed? I was having the same issue with the latest (faiss-cpu==1.8.0), then I changed to faiss-cpu==1.7.4 and it works just fine. This is my current setup library-wise: faiss-cpu==1.7.4 langchain==0.2.0 langchain-community==0.2.0 langchain-openai==0.1.7 I'm running this on an M1 machine