id stringlengths 14 16 | text stringlengths 36 2.73k | source stringlengths 49 117 |
|---|---|---|
5d44bb7ab407-1 | docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
Create a dataset locally at ./deeplake/, then run similiarity search. The Deeplake+LangChain integration uses Deep Lake datasets under the hood, so dataset and vector store are used interchangeably. To create a dataset in your own cloud, or... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-2 | text text (42, 1) str None
print(docs[0].page_content)
Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections.
Tonight, I’d like to honor someone who has... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-3 | text text (42, 1) str None
Deep Lake, for now, is single writer and multiple reader. Setting read_only=True helps to avoid acquring the writer lock.
Retrieval Question/Answering#
from langchain.chains import RetrievalQA
from langchain.llms import OpenAIChat
qa = RetrievalQA.from_chain_type(llm=Open... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-4 | tensor htype shape dtype compression
------- ------- ------- ------- -------
embedding generic (4, 1536) float32 None
ids text (4, 1) str None
metadata json (4, 1) str None
text text (4, 1) str None
db.similarity_search... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-5 | Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-6 | [Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justic... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-7 | Document(page_content='A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-8 | Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-9 | Document(page_content='Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-10 | [Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justic... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-11 | Document(page_content='Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-12 | Document(page_content='A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-13 | Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-14 | username = "<username>" # your username on app.activeloop.ai
dataset_path = f"hub://{username}/langchain_test" # could be also ./local/path (much faster locally), s3://bucket/path/to/dataset, gcs://path/to/dataset, etc.
embedding = OpenAIEmbeddings()
db = DeepLake(dataset_path=dataset_path, embedding_function=embedd... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-15 | 'd6d6ccb7-e187-11ed-b66d-41c5f7b85421']
query = "What did the president say about Ketanji Brown Jackson"
docs = db.similarity_search(query)
print(docs[0].page_content)
Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-16 | })
s3://hub-2.0-datasets-n/langchain_test loaded successfully.
Evaluating ingest: 100%|██████████| 1/1 [00:10<00:00
\
Dataset(path='s3://hub-2.0-datasets-n/langchain_test', tensors=['embedding', 'ids', 'metadata', 'text'])
tensor htype shape dtype compression
------- ------- ------- ------- ----... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-17 | username = "davitbun" # your username on app.activeloop.ai
source = f"hub://{username}/langchain_test" # could be local, s3, gcs, etc.
destination = f"hub://{username}/langchain_test_copy" # could be local, s3, gcs, etc.
deeplake.deepcopy(src=source, dest=destination, overwrite=True)
Copying dataset: 100%|██████████... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
5d44bb7ab407-18 | metadata json (4, 1) str None
text text (4, 1) str None
Evaluating ingest: 100%|██████████| 1/1 [00:31<00:00
-
Dataset(path='hub://davitbun/langchain_test_copy', tensors=['embedding', 'ids', 'metadata', 'text'])
tensor htype shape dtype compression
------- -... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
0392cb48af08-0 | .ipynb
.pdf
Vectara
Contents
Connecting to Vectara from LangChain
Similarity search
Similarity search with score
Vectara as a Retriever
Vectara#
Vectara is a API platform for building LLM-powered applications. It provides a simple to use API for document indexing and query that is managed by Vectara and is optimized ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/vectara.html |
0392cb48af08-1 | found_docs = vectara.similarity_search(query)
print(found_docs[0].page_content)
Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/vectara.html |
0392cb48af08-2 | Score: 1.0046461
Vectara as a Retriever#
Vectara, as all the other vector stores, is a LangChain Retriever, by using cosine similarity.
retriever = vectara.as_retriever()
retriever
VectorStoreRetriever(vectorstore=<langchain.vectorstores.vectara.Vectara object at 0x156d3e830>, search_type='similarity', search_kwargs={}... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/vectara.html |
ac29e0cac9c2-0 | .ipynb
.pdf
Atlas
Atlas#
Atlas is a platform for interacting with both small and internet scale unstructured datasets by Nomic.
This notebook shows you how to use functionality related to the AtlasDB vectorstore.
!pip install spacy
!python3 -m spacy download en_core_web_sm
!pip install nomic
import time
from langchain.... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html |
ac29e0cac9c2-1 | Hide embedded project
Explore on atlas.nomic.ai
previous
Annoy
next
Chroma
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html |
dfe8381c54e7-0 | .ipynb
.pdf
Weaviate
Contents
Weaviate
Similarity search with score
Persistance
Retriever options
Retriever options
MMR
Question Answering with Sources
Weaviate#
Weaviate is an open-source vector database. It allows you to store data objects and vector embeddings from your favorite ML-models, and scale seamlessly int... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-1 | Requirement already satisfied: charset-normalizer<4,>=2 in /workspaces/langchain/.venv/lib/python3.9/site-packages (from requests<2.29.0,>=2.28.0->weaviate-client) (3.1.0)
Requirement already satisfied: idna<4,>=2.5 in /workspaces/langchain/.venv/lib/python3.9/site-packages (from requests<2.29.0,>=2.28.0->weaviate-clie... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-2 | Requirement already satisfied: pycparser in /workspaces/langchain/.venv/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=3.2->authlib>=1.1.0->weaviate-client) (2.21)
We want to use OpenAIEmbeddings so we have to get the OpenAI API Key.
import os
import getpass
os.environ["OPENAI_API_KEY"] = getpass.getpass("... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-3 | Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service.
One of the most serious constitutional responsibilities a President h... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-4 | (Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justic... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-5 | 0.0080104275, -0.0010217049, -0.022327352, -0.0055002323, 0.018958665, 0.0020548347, -0.0044393567, -0.021609223, -0.013709779, -0.004543812, 0.025722157, 0.01821442, 0.031728342, -0.031388864, -0.01051083, -0.029978717, 0.011555385, 0.0009751897, 0.014675993, -0.02102166, 0.0301354, -0.031754456, 0.013526983, -0.03392... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-6 | -0.0063293483, -0.01081114, -0.0084282495, 0.003025944, -0.010210521, 0.008780787, 0.014793505, -0.006486031, 0.011966679, 0.01774437, -0.006985459, -0.015459408, 0.01625588, -0.016007798, 0.01706541, 0.035567082, 0.0029900377, 0.021543937, -0.0068483613, 0.040868197, -0.010909067, -0.03339963, 0.010954766, -0.01468904... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-7 | -0.0318328, -0.0094989175, -0.00897664, 0.004736402, 0.0046482678, 0.0023241339, -0.005826656, 0.0072531262, 0.015498579, -0.0077819317, -0.011953622, -0.028934162, -0.033974137, -0.01574666, 0.0086306315, -0.029299757, 0.030213742, -0.0033148287, 0.013448641, -0.013474754, 0.015851116, 0.0076578907, -0.037421167, -0.0... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-8 | -0.007559964, -0.01991182, -0.005268472, -0.008650217, -0.008702445, 0.027550127, 0.0018296026, 0.0018589807, -0.033295177, 0.0036265631, -0.0060290387, 0.014349569, 0.019898765, 0.00023339267, 0.0034568228, -0.018958665, 0.012031963, 0.005186866, 0.020747464, -0.03817847, 0.028202975, -0.01340947, 0.00091643346, 0.014... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-9 | 0.013892576, -0.019977106, 0.029952602, 0.0012004217, -0.015211326, -0.008708973, -0.017809656, 0.008578404, -0.01612531, 0.022614606, -0.022327352, -0.032616217, 0.0050693536, -0.020629952, -0.01357921, 0.011477043, 0.0013938275, -0.0052390937, 0.0142581705, -0.013200559, 0.013252786, -0.033582427, 0.030579336, -0.011... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-10 | 0.016020855, -0.00067284, 0.013461698, -0.0065904865, -0.017809656, -0.014741276, 0.016582303, -0.0088526, 0.0046482678, 0.037473395, -0.02237958, 0.010112594, 0.022549322, 9.680491e-05, -0.0059082615, 0.020747464, -0.026923396, 0.01162067, -0.0074816225, 0.00024277734, 0.011842638, 0.016921783, -0.019285088, 0.0055655... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-11 | 0.02318911, -0.031754456, -0.018188305, -0.031441092, -0.030579336, 0.0011832844, 0.0065023527, -0.027053965, 0.009198609, 0.022079272, -0.027785152, 0.005846241, 0.013500868, 0.016699815, 0.010445545, -0.025265165, -0.004396922, 0.0076774764, 0.014597651, -0.009851455, -0.03637661, 0.0004745379, -0.010112594, -0.00920... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-12 | 0.0027974476, -0.009577259, -0.023815846, 0.024847344, 0.014675993, -0.019454828, -0.013670608, 0.011059221, -0.005438212, 0.0406854, 0.0006218364, -0.024494806, -0.041259903, 0.022013986, -0.0040019494, -0.0052097156, 0.015798887, 0.016190596, 0.0003794671, -0.017444061, 0.012325744, 0.024769, 0.029482553, -0.00465479... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-13 | -0.008715502, 0.006776548, 0.01825359, -0.014480138, -0.014427911, -0.017600743, -0.030004831, 0.0145845935, 0.013762007, -0.013226673, 0.004168425, 0.0047951583, -0.026923396, 0.014675993, 0.0055851024, 0.015616091, -0.012306159, 0.007670948, 0.038439605, -0.015759716, 0.00016178355, 0.01076544, -0.008232395, -0.00994... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-14 | 0.030527107, -0.0003027576, 0.025082368, 0.0405026, 0.03867463, 0.0014117807, -0.024076983, 0.003933401, -0.009812284, 0.00829768, -0.0074293944, 0.0061530797, -0.016647588, -0.008147526, -0.015629148, 0.02055161, 0.000504324, 0.03157166, 0.010112594, -0.009009283, 0.026557801, -0.013997031, -0.0071878415, 0.009414048,... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-15 | -0.0030226798, -0.00074261305, 0.030892702, -0.026218321, 0.0062803845, -0.018031623, -0.021504767, -0.012834964, 0.009009283, -0.0029198565, -0.014349569, -0.020434098, 0.009838398, -0.005993132, -0.013618381, -0.031597774, -0.019206747, 0.00086583785, 0.15835446, 0.033765227, 0.00893747, 0.015119928, -0.019128405, 0.... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-16 | -0.004073763, 0.0032544404, -0.0025983294, -0.020943318, 0.019650683, -0.0074424515, -0.0030977572, 0.0073379963, -0.00012455089, 0.010230106, -0.0007254758, -0.0025052987, -0.009681715, 0.03439196, -0.035123147, -0.0028806855, 0.012828437, 0.00018646932, 0.0066133365, 0.025539361, -0.00055736775, -0.025356563, -0.0045... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-17 | 0.011333417, -0.011548856, -0.0059049972, -0.025186824, 0.0069789304, -0.010993936, -0.0009066408, 0.0002619547, 0.01727432, -0.008082241, -0.018645298, 0.024507863, 0.0030895968, -0.0014656406, 0.011137563, -0.025513247, -0.022967143, -0.002033617, 0.006887532, 0.016621474, -0.019337315, -0.0030618508, 0.0014697209, -... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-18 | 0.005947433, 0.020799693, 0.014702106, 0.03272067, 0.026701428, -0.015550806, -0.036193814, -0.021126116, -0.005412098, -0.013076518, 0.027080078, 0.012900249, -0.0073379963, -0.015119928, -0.019781252, 0.0062346854, -0.03266844, 0.025278222, -0.022797402, -0.0028415148, 0.021452539, -0.023162996, 0.005170545, -0.02231... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-19 | -0.01357921, -0.01110492, -0.014845733, -0.035384286, -0.02550019, 0.008154054, -0.0058331843, -0.008702445, -0.007311882, -0.006525202, 0.03817847, 0.00372449, 0.022914914, -0.0018981516, 0.031545546, -0.01051083, 0.013801178, -0.006296706, -0.00025052988, -0.01795328, -0.026296662, 0.0017659501, 0.021883417, 0.002893... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-20 | 0.02277129, -0.006972402, -0.029769806, 0.034862008, 0.01217559, -0.0037179615, 0.0008666539, 0.008924413, -0.026296662, -0.012678281, 0.014480138, 0.020734407, -0.012103776, -0.037499506, 0.022131499, 0.015028529, -0.033843566, 0.00020187242, 0.002650557, -0.0015113399, 0.021570051, -0.008284623, -0.003793039, -0.0134... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-21 | -0.002678303, -0.0047984226, -0.012182118, -0.001512972, 0.013931747, -0.009642544, 0.012652168, -0.012932892, -0.027759038, -0.01085031, 0.0050236546, -0.009675186, -0.00893747, -0.0051770736, 0.036011018, 0.003528636, -0.001008648, -0.015811944, -0.008865656, 0.012364916, 0.016621474, -0.01340947, 0.03219839, 0.03295... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-22 | -0.025095424, -0.010621814, 0.013207087, 0.013944804, -0.0070899143, -0.022183727, -0.0028088724, -0.011424815, 0.026087752, -0.0058625625, -0.020186016, -0.010217049, 0.015315781, -0.012580355, 0.01374895, 0.004948577, -0.0021854038, 0.023215225, 0.00207442, 0.029639237, 0.01391869, -0.015811944, -0.005356606, -0.0223... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-23 | -0.013957861, 0.0049094064, 0.033556316, 0.005167281, 0.0176138, 0.014140658, -0.0043708077, -0.0095446175, 0.012952477, 0.007853745, -0.01034109, 0.01804468, 0.0038322096, -0.04959023, 0.0023078127, 0.0053794556, -0.015106871, -0.03225062, -0.010073422, 0.007285768, 0.0056079524, -0.009002754, -0.014362626, 0.01090906... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-24 | -0.0006761042, -0.029038617, 0.004367544, -0.012293102, 0.0017528932, -0.023358852, 0.02217067, 0.012606468, -0.008160583, -0.0104912445, -0.0034894652, 0.011078807, 0.00050922035, 0.015759716, 0.23774062, -0.0019291617, 0.006218364, 0.013762007, -0.029900376, 0.018188305, 0.0092965355, 0.0040574414, -0.014976301, -0.0... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-25 | -0.013879519, 0.0011849166, -0.0016925049, 0.009753528, 0.008349908, -0.008245452, 0.033007924, -0.0035873922, -0.025461018, 0.016791213, 0.05410793, -0.005950697, -0.011672897, -0.0072335405, 0.013814235, -0.0593307, -0.008624103, 0.021400312, 0.034235276, 0.015642203, -0.020068504, 0.03136275, 0.012567298, -0.0104194... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-26 | -0.03219839, 0.0058233915, -0.0056405943, -0.009381405, 0.0064044255, 0.013905633, -0.011228961, -0.0013481282, -0.014023146, 0.00016239559, -0.0051901303, 0.0025265163, 0.023619989, -0.021517823, 0.024703717, -0.025643816, 0.040189236, 0.016295051, -0.0040411204, -0.0113595305, 0.0029981981, -0.015589978, 0.026479458,... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-27 | -0.0036200345, -0.021596165, -0.003949722, -0.0006034751, 0.007305354, -0.023424136, 0.004834329, -0.008833014, -0.013435584, 0.0026097542, -0.0012240873, -0.0028349862, -0.01706541, 0.027863493, -0.026414175, -0.011783881, 0.014075373, -0.005634066, -0.006313027, -0.004638475, -0.012495484, 0.022836573, -0.022719061, ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-28 | -0.0024840813, -0.022444865, 0.0055687814, 0.0037767177, 0.0033915383, 0.0301354, -0.012227817, 0.0021854038, -0.042878963, 0.021517823, -0.010419431, -0.0051183174, 0.01659536, 0.0017333078, -0.00727924, -0.0020026069, -0.0012493852, 0.031441092, 0.0017431005, 0.008702445, -0.0072335405, -0.020081561, -0.012423672, -0... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-29 | 0.004971427, -0.017835768, 0.025017083, -0.021792019, 0.013657551, -0.01872364, 0.009100681, -0.0079582, -0.011640254, -0.01093518, -0.0147543335, -0.005000805, 0.02345025, -0.028908048, 0.0104912445, -0.00753385, 0.017561574, -0.012025435, 0.042670052, -0.0041978033, 0.0013056932, -0.009263893, -0.010941708, -0.004471... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-30 | 0.027706811, 0.03047488, 0.02047327, 0.0019258976, -0.0068940604, -0.0014990991, 0.013305014, -0.007690533, 0.058808424, -0.0016859764, -0.0044622063, -0.0037734534, 0.01578583, -0.0018459238, -0.1196015, -0.0007075225, 0.0030341048, 0.012306159, -0.0068483613, 0.01851473, 0.015315781, 0.031388864, -0.015563863, 0.0477... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-31 | -0.013814235, -0.0004365912, -0.023606932, -0.020186016, 0.025330449, -0.00991674, -0.0048278007, -0.019350372, 0.015433294, -0.0056144805, -0.0034927295, -0.00043455104, 0.008611047, 0.025748271, 0.022353467, -0.020747464, -0.015759716, 0.029038617, -0.000377631, -0.028725252, 0.018109964, -0.0016125311, -0.022719061,... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-32 | -0.03230285, 0.023646105, 0.0111114485, -0.015172156, 0.0257091, 0.0045699263, -0.00919208, 0.021517823, 0.037838988, 0.00787333, -0.007755818, -0.028281316, 0.011170205, -0.005412098, -0.016321165, 0.009929797, 0.004609097, -0.03047488, 0.002688096, -0.07264877, 0.024455635, -0.020930262, -0.015381066, -0.0033148287, ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-33 | -0.002087477, 0.010791554, 0.022288183, 0.0048604426, -0.032590102, 0.013709779, 0.004922463, 0.020055447, -0.0150677, -0.0057222005, -0.036246043, 0.0021364405, 0.021387255, -0.013435584, 0.010732798, 0.0075534354, -0.00061612396, -0.002018928, -0.004432828, -0.032746784, 0.025513247, -0.0025852725, 0.014467081, -0.00... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-34 | -0.018540842, 0.0025722156, 0.0110331075, -0.003992157, 0.020930262, 0.008487006, 0.0016557822, -0.0009882465, 0.0062640635, -0.016242823, -0.0007785196, -0.0007213955, 0.018971723, 0.021687564, 0.0039464575, -0.01574666, 0.011783881, -0.0019797573, -0.013383356, -0.002706049, 0.0037734534, 0.020394927, -0.00021931567,... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-35 | 0.007135614, -0.0113595305, -0.04387129, 0.016308108, -0.008186696, -0.013370299, -0.014297341, 0.017431004, -0.022666834, 0.039458048, 0.0032005806, -0.02081275, 0.008526176, -0.0019307939, 0.024024757, 0.009068039, 0.00953156, 0.010608757, 0.013801178, 0.035932675, -0.015185213, -0.0038322096, -0.012462842, -0.036559... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-36 | -0.01472822, -0.025735214, -0.03313849, 0.0033817457, 0.028855821, -0.016033912, 0.0050791465, -0.01808385]}, 'source': '../../../state_of_the_union.txt'}), | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-37 | 0.8154189703772676)
Persistance#
Anything uploaded to weaviate is automatically persistent into the database. You do not need to call any specific method or pass any param for this to happen.
Retriever options#
Retriever options#
This section goes over different options for how to use Weaviate as a retriever.
MMR#
In a... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
dfe8381c54e7-38 | from langchain.chains import RetrievalQAWithSourcesChain
from langchain import OpenAI
with open("../../../state_of_the_union.txt") as f:
state_of_the_union = f.read()
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
texts = text_splitter.split_text(state_of_the_union)
docsearch = Weaviate.fro... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
a4e90702277b-0 | .ipynb
.pdf
Qdrant
Contents
Connecting to Qdrant from LangChain
Local mode
In-memory
On-disk storage
On-premise server deployment
Qdrant Cloud
Reusing the same collection
Similarity search
Similarity search with score
Maximum marginal relevance search (MMR)
Qdrant as a Retriever
Customizing Qdrant
Qdrant#
Qdrant (rea... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
a4e90702277b-1 | docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
Connecting to Qdrant from LangChain#
Local mode#
Python client allows you to run the same code in local mode without running the Qdrant server. That’s great for testing things out and debugging or if you plan to store just a small amount of... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
a4e90702277b-2 | collection_name="my_documents",
)
Qdrant Cloud#
If you prefer not to keep yourself busy with managing the infrastructure, you can choose to set up a fully-managed Qdrant cluster on Qdrant Cloud. There is a free forever 1GB cluster included for trying out. The main difference with using a managed version of Qdrant is th... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
a4e90702277b-3 | found_docs = qdrant.similarity_search(query)
print(found_docs[0].page_content)
Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections.
Tonight, I’d like to honor someone who ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
a4e90702277b-4 | One of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court.
And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
a4e90702277b-5 | 2. We can’t change how divided we’ve been. But we can change how we move forward—on COVID-19 and other issues we must face together.
I recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera.
They were responding to a 9-1-1 call when a... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
a4e90702277b-6 | query = "What did the president say about Ketanji Brown Jackson"
retriever.get_relevant_documents(query)[0]
Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
a4e90702277b-7 | location=":memory:",
collection_name="my_documents_2",
content_payload_key="my_page_content_key",
metadata_payload_key="my_meta",
)
<langchain.vectorstores.qdrant.Qdrant at 0x7fc4e2baa230>
previous
Pinecone
next
Redis
Contents
Connecting to Qdrant from LangChain
Local mode
In-memory
On-disk storage
On-p... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
36542fb8eb84-0 | .ipynb
.pdf
Tair
Tair#
Tair is a cloud native in-memory database service developed by Alibaba Cloud.
It provides rich data models and enterprise-grade capabilities to support your real-time online scenarios while maintaining full compatibility with open source Redis. Tair also introduces persistent memory-optimized ins... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/tair.html |
36542fb8eb84-1 | docs = vector_store.similarity_search(query)
docs[0]
Document(page_content='We’re going after the criminals who stole billions in relief money meant for small businesses and millions of Americans. \n\nAnd tonight, I’m announcing that the Justice Department will name a chief prosecutor for pandemic fraud. \n\nBy the en... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/tair.html |
9ec48d771ae7-0 | .ipynb
.pdf
Annoy
Contents
Create VectorStore from texts
Create VectorStore from docs
Create VectorStore via existing embeddings
Search via embeddings
Search via docstore id
Save and load
Construct from scratch
Annoy#
Annoy (Approximate Nearest Neighbors Oh Yeah) is a C++ library with Python bindings to search for po... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
9ec48d771ae7-1 | # the score is a distance metric, so lower is better
vector_store.similarity_search_with_score("food", k=3)
[(Document(page_content='pizza is great', metadata={}), 1.0944390296936035),
(Document(page_content='I love salad', metadata={}), 1.1273186206817627),
(Document(page_content='my car', metadata={}), 1.1580758094... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
9ec48d771ae7-2 | docs = text_splitter.split_documents(documents)
docs[:5]
[Document(page_content='Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \n\nLast year COVID-19 kept us apart. This year we are finally together aga... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
9ec48d771ae7-3 | Document(page_content='Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. \n\nIn this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the Unit... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
9ec48d771ae7-4 | Document(page_content='Putin’s latest attack on Ukraine was premeditated and unprovoked. \n\nHe rejected repeated efforts at diplomacy. \n\nHe thought the West and NATO wouldn’t respond. And he thought he could divide us at home. Putin was wrong. We were ready. Here is what we did. \n\nWe prepared extensively and ca... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
9ec48d771ae7-5 | Document(page_content='We are inflicting pain on Russia and supporting the people of Ukraine. Putin is now isolated from the world more than ever. \n\nTogether with our allies –we are right now enforcing powerful economic sanctions. \n\nWe are cutting off Russia’s largest banks from the international financial system. ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
9ec48d771ae7-6 | Document(page_content='And tonight I am announcing that we will join our allies in closing off American air space to all Russian flights – further isolating Russia – and adding an additional squeeze –on their economy. The Ruble has lost 30% of its value. \n\nThe Russian stock market has lost 40% of its value and tradin... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
9ec48d771ae7-7 | (Document(page_content='I love salad', metadata={}), 1.1273186206817627),
(Document(page_content='my car', metadata={}), 1.1580758094787598)]
Search via embeddings#
motorbike_emb = embeddings_func.embed_query("motorbike")
vector_store.similarity_search_by_vector(motorbike_emb, k=3)
[Document(page_content='my car', met... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
9ec48d771ae7-8 | Document(page_content='pizza is great', metadata={})
# same document has distance 0
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='... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
9ec48d771ae7-9 | index.build(10)
# docstore
documents = []
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 range(len(documents))}
docstore = InMemoryDocstore(
{index_to_docstor... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
7519718bc315-0 | .ipynb
.pdf
Pinecone
Pinecone#
Pinecone is a vector database with broad functionality.
This notebook shows how to use functionality related to the Pinecone vector database.
To use Pinecone, you must have an API key.
Here are the installation instructions.
!pip install pinecone-client
import os
import getpass
PINECONE_A... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pinecone.html |
7519718bc315-1 | docs = docsearch.similarity_search(query)
print(docs[0].page_content)
previous
PGVector
next
Qdrant
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pinecone.html |
097c10fea152-0 | .ipynb
.pdf
PGVector
Contents
Similarity search with score
Similarity Search with Euclidean Distance (Default)
Working with vectorstore in PG
Uploading a vectorstore in PG
Retrieving a vectorstore in PG
PGVector#
PGVector is an open-source vector similarity search for Postgres
It supports:
exact and approximate neare... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
097c10fea152-1 | port=int(os.environ.get("PGVECTOR_PORT", "5432")),
database=os.environ.get("PGVECTOR_DATABASE", "postgres"),
user=os.environ.get("PGVECTOR_USER", "postgres"),
password=os.environ.get("PGVECTOR_PASSWORD", "postgres"),
)
## Example
# postgresql+psycopg2://username:password@localhost:5432/database_name
Similar... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
097c10fea152-2 | One of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court.
And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
097c10fea152-3 | And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.
--------------------------------------------------------------------------------
-----------------------------------------------... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
097c10fea152-4 | previous
OpenSearch
next
Pinecone
Contents
Similarity search with score
Similarity Search with Euclidean Distance (Default)
Working with vectorstore in PG
Uploading a vectorstore in PG
Retrieving a vectorstore in PG
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
a4844781a96e-0 | .ipynb
.pdf
DocArrayHnswSearch
Contents
Setup
Using DocArrayHnswSearch
Similarity search
Similarity search with score
DocArrayHnswSearch#
DocArrayHnswSearch is a lightweight Document Index implementation provided by Docarray that runs fully locally and is best suited for small- to medium-sized datasets. It stores vec... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/docarray_hnsw.html |
a4844781a96e-1 | docs = db.similarity_search(query)
print(docs[0].page_content)
Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections.
Tonight, I’d like to honor someone who has dedicated hi... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/docarray_hnsw.html |
a4844781a96e-2 | 0.36962226)
import shutil
# delete the dir
shutil.rmtree('hnswlib_store')
previous
Deep Lake
next
DocArrayInMemorySearch
Contents
Setup
Using DocArrayHnswSearch
Similarity search
Similarity search with score
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/docarray_hnsw.html |
f71e5e9965b3-0 | .ipynb
.pdf
VectorStore
Contents
Maximum Marginal Relevance Retrieval
Similarity Score Threshold Retrieval
Specifying top k
VectorStore#
The index - and therefore the retriever - that LangChain has the most support for is the VectorStoreRetriever. As the name suggests, this retriever is backed heavily by a VectorStor... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vectorstore.html |
f71e5e9965b3-1 | docs = retriever.get_relevant_documents("what did he say abotu ketanji brown jackson")
Specifying top k#
You can also specify search kwargs like k to use when doing retrieval.
retriever = db.as_retriever(search_kwargs={"k": 1})
docs = retriever.get_relevant_documents("what did he say abotu ketanji brown jackson")
len(d... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vectorstore.html |
9840691c0f53-0 | .ipynb
.pdf
Weaviate Hybrid Search
Weaviate Hybrid Search#
Weaviate is an open source vector database.
Hybrid search is a technique that combines multiple search algorithms to improve the accuracy and relevance of search results. It uses the best features of both keyword-based search algorithms with vector search techn... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html |
9840691c0f53-1 | )
Add some data:
docs = [
Document(
metadata={
"title": "Embracing The Future: AI Unveiled",
"author": "Dr. Rebecca Simmons",
},
page_content="A comprehensive analysis of the evolution of artificial intelligence, from its inception to its future prospects. Dr. Simmons... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html |
9840691c0f53-2 | "author": "Prof. Jonathan K. Sterling",
},
page_content="In his follow-up to 'Symbiosis', Prof. Sterling takes a look at the subtle, unnoticed presence and influence of AI in our everyday lives. It reveals how AI has become woven into our routines, often without our explicit realization.",
),
]
retr... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html |
9840691c0f53-3 | Document(page_content='Prof. Sterling explores the potential for harmonious coexistence between humans and artificial intelligence. The book discusses how AI can be integrated into society in a beneficial and non-disruptive manner.', metadata={})]
Do a hybrid search with where filter:
retriever.get_relevant_documents(
... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html |
41208ea6f041-0 | .ipynb
.pdf
Zep Memory
Contents
Retriever Example
Initialize the Zep Chat Message History Class and add a chat message history to the memory store
Use the Zep Retriever to vector search over the Zep memory
Zep Memory#
Retriever Example#
This notebook demonstrates how to search historical chat message histories using ... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html |
41208ea6f041-1 | session_id = str(uuid4()) # This is a unique identifier for the user/session
# Set up Zep Chat History. We'll use this to add chat histories to the memory store
zep_chat_history = ZepChatMessageHistory(
session_id=session_id,
url=ZEP_API_URL,
)
# Preload some messages into the memory. The default message windo... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.