langchain
langchain copied to clipboard
How to pass existing doc embeddings to FAISS ?
I have some existing embeddings created from
doc_embeddings = embeddings.embed_documents(docs)
how to pass doc embeddings to FAISS vector store
from langchain.vectorstores import FAISS
right now FAISS.from_text() only takes an embedding client and not existing embeddings.
@shaktisd I am also facing the same problem. Did you got an answer?
You can use the from_embeddings
method.
texts = [d.page_content for d in docs]
doc_embeddings = embeddings.embed_documents(docs)
text_embedding_pairs = zip(texts, doc_embedding_pairs)
vectorstore = FAISS.from_embeddings(text_embedding_pairs, embeddings)
Hi, @shaktisd! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.
From what I understand, the issue is about how to pass existing document embeddings to the FAISS vector store. Currently, the FAISS.from_text() method only takes an embedding client and not existing embeddings. User Xmaster6y suggested using the from_embeddings
method and even provided an example code snippet.
Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.
Thank you for your contribution!
Thanks for suggesting the solution.
Thank you, @shaktisd, for closing the issue in the LangChain repository! We appreciate your contribution!