mirror of
https://github.com/hwchase17/langchain
synced 2024-11-02 09:40:22 +00:00
Fix from_embeddings method examples (#3174)
Fix examples for `from_embeddings` method for annoy and faiss vectorstores
This commit is contained in:
parent
f19b3890c9
commit
c03a65c6dc
@ -367,7 +367,9 @@ class Annoy(VectorStore):
|
||||
from langchain import Annoy
|
||||
from langchain.embeddings import OpenAIEmbeddings
|
||||
embeddings = OpenAIEmbeddings()
|
||||
db = Annoy.from_texts(texts, embeddings)
|
||||
text_embeddings = embeddings.embed_documents(texts)
|
||||
text_embedding_pairs = list(zip(texts, text_embeddings))
|
||||
db = Annoy.from_embeddings(text_embedding_pairs, embeddings)
|
||||
"""
|
||||
texts = [t[0] for t in text_embeddings]
|
||||
embeddings = [t[1] for t in text_embeddings]
|
||||
|
@ -396,7 +396,9 @@ class FAISS(VectorStore):
|
||||
from langchain import FAISS
|
||||
from langchain.embeddings import OpenAIEmbeddings
|
||||
embeddings = OpenAIEmbeddings()
|
||||
faiss = FAISS.from_texts(texts, embeddings)
|
||||
text_embeddings = embeddings.embed_documents(texts)
|
||||
text_embedding_pairs = list(zip(texts, text_embeddings))
|
||||
faiss = FAISS.from_embeddings(text_embedding_pairs, embeddings)
|
||||
"""
|
||||
texts = [t[0] for t in text_embeddings]
|
||||
embeddings = [t[1] for t in text_embeddings]
|
||||
|
Loading…
Reference in New Issue
Block a user