1.3254905939102173)]Search via docstore id‚Äãvector_store.index_to_docstore_id    {0: '2d1498a8-a37c-4798-acb9-0016504ed798',     1: '2d30aecc-88e0-4469-9d51-0ef7e9858e6d',     2: '927f1120-985b-4691-b577-ad5cb42e011c',     3: '3056ddcf-a62f-48c8-bd98-b9e57a3dfcae'}some_docstore_id = 0  # texts[0]vector_store.docstore._dict[vector_store.index_to_docstore_id[some_docstore_id]]    Document(page_content='pizza is great', metadata={})# same document has distance 0vector_store.similarity_search_with_score_by_index(some_docstore_id, k=3)    [(Document(page_content='pizza is great', metadata={}), 0.0),     (Document(page_content='I love salad', metadata={}), 1.0734446048736572),     (Document(page_content='my car', metadata={}), 1.2895267009735107)]Save and load‚Äãvector_store.save_local("my_annoy_index_and_docstore")    saving configloaded_vector_store = Annoy.load_local(    "my_annoy_index_and_docstore", embeddings=embeddings_func)# same document has distance 0loaded_vector_store.similarity_search_with_score_by_index(some_docstore_id, k=3)    [(Document(page_content='pizza is great', metadata={}), 0.0),     (Document(page_content='I love salad', metadata={}), 1.0734446048736572),     (Document(page_content='my car', metadata={}), 1.2895267009735107)]Construct from scratch‚Äãimport uuidfrom annoy import AnnoyIndexfrom langchain.docstore.document import Documentfrom langchain.docstore.in_memory import InMemoryDocstoremetadatas = [{"x": "food"}, {"x": "food"}, {"x": "stuff"}, {"x": "animal"}]# embeddingsembeddings = embeddings_func.embed_documents(texts)# embedding dimf = len(embeddings[0])# indexmetric = "angular"index = AnnoyIndex(f, metric=metric)for i, emb in enumerate(embeddings):    index.add_item(i, emb)index.build(10)# docstoredocuments = []for i, text in enumerate(texts):    metadata = metadatas[i] if metadatas else {}    documents.append(Document(page_content=text, metadata=metadata))index_to_docstore_id = {i: str(uuid.uuid4()) for i in
Annoy (Approximate Nearest Neighbors Oh Yeah) is a C++ library with Python bindings to search for points in space that are close to a given query point. It also creates large read-only file-based data structures that are mmapped into memory so that many processes may share the same data.
Annoy (Approximate Nearest Neighbors Oh Yeah) is a C++ library with Python bindings to search for points in space that are close to a given query point. It also creates large read-only file-based data structures that are mmapped into memory so that many processes may share the same data. ->: 1.3254905939102173)]Search via docstore id‚Äãvector_store.index_to_docstore_id    {0: '2d1498a8-a37c-4798-acb9-0016504ed798',     1: '2d30aecc-88e0-4469-9d51-0ef7e9858e6d',     2: '927f1120-985b-4691-b577-ad5cb42e011c',     3: '3056ddcf-a62f-48c8-bd98-b9e57a3dfcae'}some_docstore_id = 0  # texts[0]vector_store.docstore._dict[vector_store.index_to_docstore_id[some_docstore_id]]    Document(page_content='pizza is great', metadata={})# same document has distance 0vector_store.similarity_search_with_score_by_index(some_docstore_id, k=3)    [(Document(page_content='pizza is great', metadata={}), 0.0),     (Document(page_content='I love salad', metadata={}), 1.0734446048736572),     (Document(page_content='my car', metadata={}), 1.2895267009735107)]Save and load‚Äãvector_store.save_local("my_annoy_index_and_docstore")    saving configloaded_vector_store = Annoy.load_local(    "my_annoy_index_and_docstore", embeddings=embeddings_func)# same document has distance 0loaded_vector_store.similarity_search_with_score_by_index(some_docstore_id, k=3)    [(Document(page_content='pizza is great', metadata={}), 0.0),     (Document(page_content='I love salad', metadata={}), 1.0734446048736572),     (Document(page_content='my car', metadata={}), 1.2895267009735107)]Construct from scratch‚Äãimport uuidfrom annoy import AnnoyIndexfrom langchain.docstore.document import Documentfrom langchain.docstore.in_memory import InMemoryDocstoremetadatas = [{"x": "food"}, {"x": "food"}, {"x": "stuff"}, {"x": "animal"}]# embeddingsembeddings = embeddings_func.embed_documents(texts)# embedding dimf = len(embeddings[0])# indexmetric = "angular"index = AnnoyIndex(f, metric=metric)for i, emb in enumerate(embeddings):    index.add_item(i, emb)index.build(10)# docstoredocuments = []for i, text in enumerate(texts):    metadata = metadatas[i] if metadatas else {}    documents.append(Document(page_content=text, metadata=metadata))index_to_docstore_id = {i: str(uuid.uuid4()) for i in