langchain icon indicating copy to clipboard operation
langchain copied to clipboard

How to pass existing doc embeddings to FAISS ?

Open shaktisd opened this issue 2 years ago • 2 comments

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 avatar Feb 22 '23 14:02 shaktisd

@shaktisd I am also facing the same problem. Did you got an answer?

hetthummar avatar Mar 05 '23 02:03 hetthummar

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)

Xmaster6y avatar Apr 20 '23 14:04 Xmaster6y

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!

dosubot[bot] avatar Sep 10 '23 16:09 dosubot[bot]

Thanks for suggesting the solution.

shaktisd avatar Sep 11 '23 03:09 shaktisd

Thank you, @shaktisd, for closing the issue in the LangChain repository! We appreciate your contribution!

dosubot[bot] avatar Sep 11 '23 03:09 dosubot[bot]