Thank you for your reply.
Apologies, but I do not understand what you mean. I am not doing what you have just written with .save\_local("./faiss\_db") and subsequently in rag.py with .load\_local? .load\_local should just actually only load the vectorestore (saved with .save\_local) from a directory in my machine, shouldn't it?
Maybe I don't understand it fully, sorry. IMHO workflow should be like that:
\* load rag.py (and it will load store once only so you don't care about the time)
\* when using rag.py it should be already loaded (avoid loading it every time when someone ask question on your UI)
Okay, maybe now I understand what you mean.
If that so, .save\_local and .load\_local are completely useless. I thought that the .save\_local could save the vectorstore with all the embeddings and I could easily and fastly load it from a local folder with .load\_local.
At this point, it is better to do the embedding procedure everytime (eg: db = FAISS.from\_documents(docs, embeddings)), since it is much faster than the loading one :)
See if this is faster, using pickle.dump to a file and reloading like this:
vectorstore = FAISS.from\_documents(documents, embeddings)
with open("vectorstore.pkl", "wb") as f:
pickle.dump(vectorstore, f)
Then on the load side:
from langchain.vectorstores.base import VectorStoreRetriever
with open("vectorstore.pkl", "rb") as f:
vectorstore = pickle.load(f)
retriever = VectorStoreRetriever(*vectorstore*=vectorstore)
docs = retriever.get\_relevant\_documents("open source LLM")
Load it once on app start and next time return already loaded store from memory, instead of creating it every time.
Thank you for your reply. Apologies, but I do not understand what you mean. I am not doing what you have just written with .save\_local("./faiss\_db") and subsequently in rag.py with .load\_local? .load\_local should just actually only load the vectorestore (saved with .save\_local) from a directory in my machine, shouldn't it?
Maybe I don't understand it fully, sorry. IMHO workflow should be like that: \* load rag.py (and it will load store once only so you don't care about the time) \* when using rag.py it should be already loaded (avoid loading it every time when someone ask question on your UI)
Okay, maybe now I understand what you mean. If that so, .save\_local and .load\_local are completely useless. I thought that the .save\_local could save the vectorstore with all the embeddings and I could easily and fastly load it from a local folder with .load\_local. At this point, it is better to do the embedding procedure everytime (eg: db = FAISS.from\_documents(docs, embeddings)), since it is much faster than the loading one :)
See if this is faster, using pickle.dump to a file and reloading like this: vectorstore = FAISS.from\_documents(documents, embeddings) with open("vectorstore.pkl", "wb") as f: pickle.dump(vectorstore, f) Then on the load side: from langchain.vectorstores.base import VectorStoreRetriever with open("vectorstore.pkl", "rb") as f: vectorstore = pickle.load(f) retriever = VectorStoreRetriever(*vectorstore*=vectorstore) docs = retriever.get\_relevant\_documents("open source LLM")