id stringlengths 14 16 | text stringlengths 29 2.73k | source stringlengths 49 117 |
|---|---|---|
6a0a6b348249-21 | 0.005826656, 0.012188647, -0.020394927, -0.0013024289, -0.027315103, -0.017000126, -0.0010600596, -0.0019014158, 0.016712872, 0.0012673384, 0.02966535, 0.02911696, -0.03081436, 0.025552418, 0.0014215735, -0.02510848, 0.020277414, -0.02672754, 0.01829276, 0.03381745, -0.013957861, 0.0049094064, 0.033556316, 0.005167281,... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-22 | 0.014179829, 0.010321504, 0.0053337566, -0.017156808, -0.010439017, 0.034444187, -0.010393318, -0.006042096, -0.018566957, 0.004517698, -0.011228961, -0.009015812, -0.02089109, 0.022484036, 0.0029867734, -0.029064732, -0.010236635, -0.0006761042, -0.029038617, 0.004367544, -0.012293102, 0.0017528932, -0.023358852, 0.02... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-23 | 0.0047135525, -0.011294246, 0.011477043, 0.015485522, 0.03426139, 0.014323455, 0.011052692, -0.008362965, -0.037969556, -0.00252162, -0.013709779, -0.0030292084, -0.016569246, -0.013879519, 0.0011849166, -0.0016925049, 0.009753528, 0.008349908, -0.008245452, 0.033007924, -0.0035873922, -0.025461018, 0.016791213, 0.0541... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-24 | 0.029743692, 0.021857304, 0.01438874, 0.00014128008, -0.006156344, -0.006691678, 0.01672593, -0.012821908, -0.0024367499, -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... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-25 | -0.012325744, -0.021348083, 0.0036461484, 0.0063228197, 0.00028970066, -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... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-26 | -0.0018573486, -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, -... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-27 | -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.004471999, 0.01008648, -0.002578744, -0.013931... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-28 | -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.04776226, -0.008199753, -0.02591801, 0.00546759, -0.004915935, 0.0050824108, 0.0027011528, -0.0092... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-29 | -0.00043455104, 0.008611047, 0.025748271, 0.022353467, -0.020747464, -0.015759716, 0.029038617, -0.000377631, -0.028725252, 0.018109964, -0.0016125311, -0.022719061, -0.009133324, -0.033060152, 0.011248547, -0.0019797573, -0.007181313, 0.0018867267, 0.0070899143, 0.004077027, 0.0055328747, -0.014245113, -0.021217514, -... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-30 | 0.009929797, 0.004609097, -0.03047488, 0.002688096, -0.07264877, 0.024455635, -0.020930262, -0.015381066, -0.0033148287, 0.027236762, 0.0014501355, -0.014101488, -0.024076983, 0.026218321, -0.009009283, 0.019624569, 0.0020646274, -0.009081096, -0.01565526, -0.003358896, 0.048571788, -0.004857179, 0.022444865, 0.0241814... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-31 | -0.004432828, -0.032746784, 0.025513247, -0.0025852725, 0.014467081, -0.008617575, -0.019755138, 0.003966043, -0.0033915383, 0.0004088452, -0.025173767, 0.02796795, 0.0023763615, 0.0052358294, 0.017796598, 0.014806561, 0.0150024155, -0.005859298, 0.01259994, 0.021726735, -0.026466403, -0.017457118, -0.0025493659, 0.007... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-32 | 0.0037734534, 0.020394927, -0.00021931567, 0.0041814824, 0.025121538, -0.036246043, -0.019428715, -0.023802789, 0.014845733, 0.015420238, 0.019650683, 0.008186696, 0.025304336, -0.03204171, 0.01774437, 0.0021233836, -0.008434778, -0.0059441687, 0.038335152, 0.022653777, -0.0066002794, 0.02149171, 0.015093814, 0.0253826... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-33 | 0.0013946436, 0.00025726235, 0.008016956, -0.0042565595, 0.008447835, 0.0038191527, -0.014702106, 0.02196176, 0.0052097156, -0.010869896, 0.0051640165, 0.030840475, -0.041468814, 0.009250836, -0.018997835, 0.020107675, 0.008421721, -0.016373392, 0.004602568, 0.0327729, -0.00812794, 0.001581521, 0.019350372, 0.016112253... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
6a0a6b348249-34 | 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 |
6a0a6b348249-35 | 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 |
c91ccdeecb7a-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 |
c91ccdeecb7a-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 |
c91ccdeecb7a-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 |
c91ccdeecb7a-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 |
c91ccdeecb7a-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 |
c91ccdeecb7a-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 |
c91ccdeecb7a-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 |
c91ccdeecb7a-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 |
c91ccdeecb7a-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 |
c91ccdeecb7a-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 |
b238414f7cae-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 |
b238414f7cae-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 |
b238414f7cae-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 |
b238414f7cae-3 | 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 |
b238414f7cae-4 | collection_name=collection_name,
distance_strategy=DistanceStrategy.COSINE
)
retriever = store.as_retriever()
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 vect... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
3668ec17b46b-0 | .ipynb
.pdf
Zilliz
Zilliz#
Zilliz Cloud is a fully managed service on cloud for LF AI Milvus®,
This notebook shows how to use functionality related to the Zilliz Cloud managed vector database.
To run, you should have a Zilliz Cloud instance up and running. Here are the installation instructions
!pip install pymilvus
We... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/zilliz.html |
3668ec17b46b-1 | "password": ZILLIZ_CLOUD_PASSWORD,
"secure": True
}
)
query = "What did the president say about Ketanji Brown Jackson"
docs = vector_db.similarity_search(query)
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... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/zilliz.html |
ada93fda9cca-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
Metadata filtering
Maximum marginal relevance search (MMR)
Qdrant as a Retriever
Customizing Qdrant
... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
ada93fda9cca-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 |
ada93fda9cca-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 |
ada93fda9cca-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 |
ada93fda9cca-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 |
ada93fda9cca-5 | 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/qdrant.html |
ada93fda9cca-6 | retriever = qdrant.as_retriever()
retriever
VectorStoreRetriever(vectorstore=<langchain.vectorstores.qdrant.Qdrant object at 0x7fc4e5720a00>, search_type='similarity', search_kwargs={})
It might be also specified to use MMR as a search strategy, instead of similarity.
retriever = qdrant.as_retriever(search_type="mmr")
... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
ada93fda9cca-7 | Customizing Qdrant#
Qdrant stores your vector embeddings along with the optional JSON-like payload. Payloads are optional, but since LangChain assumes the embeddings are generated from the documents, we keep the context data, so you can extract the original texts as well.
By default, your document is going to be stored... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
c210d563b8ef-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 |
c210d563b8ef-1 | 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 service. One of the most serious constitution... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/vectara.html |
c210d563b8ef-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 |
1655734ce45a-0 | .ipynb
.pdf
FAISS
Contents
Similarity Search with score
Saving and loading
Merging
FAISS#
Facebook AI Similarity Search (Faiss) is a library for efficient similarity search and clustering of dense vectors. It contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM. I... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
1655734ce45a-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/faiss.html |
1655734ce45a-2 | docs_and_scores = db.similarity_search_with_score(query)
docs_and_scores[0]
(Document(page_content='In state after state, new laws have been passed, not only to suppress the vote, but to subvert entire elections. \n\nWe cannot let this happen. \n\nTonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
1655734ce45a-3 | docs = new_db.similarity_search(query)
docs[0]
Document(page_content='In state after state, new laws have been passed, not only to suppress the vote, but to subvert entire elections. \n\nWe cannot let this happen. \n\nTonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act.... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
1655734ce45a-4 | db1.merge_from(db2)
db1.docstore._dict
{'e0b74348-6c93-4893-8764-943139ec1d17': Document(page_content='foo', lookup_str='', metadata={}, lookup_index=0),
'd5211050-c777-493d-8825-4800e74cfdb6': Document(page_content='bar', lookup_str='', metadata={}, lookup_index=0)}
previous
ElasticSearch
next
LanceDB
Contents
Si... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
50529330ba19-0 | .ipynb
.pdf
Milvus
Milvus#
Milvus is a database that stores, indexes, and manages massive embedding vectors generated by deep neural networks and other machine learning (ML) models.
This notebook shows how to use functionality related to the Milvus vector database.
To run, you should have a Milvus instance up and runni... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/milvus.html |
50529330ba19-1 | docs = vector_db.similarity_search(query)
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. \n\nTonight, I’d like to honor someone who has dedicate... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/milvus.html |
c8b78ada27a5-0 | .ipynb
.pdf
MatchingEngine
Contents
Create VectorStore from texts
Create Index and deploy it to an Endpoint
Imports, Constants and Configs
Using Tensorflow Universal Sentence Encoder as an Embedder
Inserting a test embedding
Creating Index
Creating Endpoint
Deploy Index
MatchingEngine#
This notebook shows how to use ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/matchingengine.html |
c8b78ada27a5-1 | import tensorflow_text
PROJECT_ID = "<my_project_id>"
REGION = "<my_region>"
VPC_NETWORK = "<my_vpc_network_name>"
PEERING_RANGE_NAME = "ann-langchain-me-range" # Name for creating the VPC peering.
BUCKET_URI = "gs://<bucket_uri>"
# The number of dimensions for the tensorflow universal sentence encoder.
# If other em... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/matchingengine.html |
c8b78ada27a5-2 | ! gcloud compute firewall-rules create {VPC_NETWORK}-allow-rdp --network {VPC_NETWORK} --priority 65534 --project {PROJECT_ID} --allow tcp:3389
! gcloud compute firewall-rules create {VPC_NETWORK}-allow-ssh --network {VPC_NETWORK} --priority 65534 --project {PROJECT_ID} --allow tcp:22
# Reserve IP range
! g... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/matchingengine.html |
c8b78ada27a5-3 | Creating Index#
my_index = aiplatform.MatchingEngineIndex.create_tree_ah_index(
display_name=DISPLAY_NAME,
contents_delta_uri=EMBEDDING_DIR,
dimensions=DIMENSIONS,
approximate_neighbors_count=150,
distance_measure_type="DOT_PRODUCT_DISTANCE"
)
Creating Endpoint#
my_index_endpoint = aiplatform.Matchi... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/matchingengine.html |
c2c71522587d-0 | .ipynb
.pdf
Chroma
Contents
Similarity search with score
Persistance
Initialize PeristedChromaDB
Persist the Database
Load the Database from disk, and create the chain
Retriever options
MMR
Updating a Document
Chroma#
Chroma is a database for building AI applications with embeddings.
This notebook shows how to use fu... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
c2c71522587d-1 | 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/chroma.html |
c2c71522587d-2 | Initialize PeristedChromaDB#
Create embeddings for each chunk and insert into the Chroma vector database. The persist_directory argument tells ChromaDB where to store the database when it’s persisted.
# Embed and store the texts
# Supplying a persist_directory will store the embeddings on disk
persist_directory = 'db'
... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
c2c71522587d-3 | 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 elections. \n\nTonight, I’d like to honor someone who has dedica... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
c2c71522587d-4 | ids=[document_id],
)
At this point, we have a new Chroma instance with a single document “This is an initial document content” with id “doc1”. Now, let’s update the content of the document.
# Updated document content
updated_content = "This is the updated document content"
# Create a new Document instance with the upda... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
b74647ce495f-0 | .ipynb
.pdf
Redis
Contents
Installing
Example
Redis as Retriever
Redis#
Redis (Remote Dictionary Server) is an in-memory data structure store, used as a distributed, in-memory key–value database, cache and message broker, with optional durability.
This notebook shows how to use functionality related to the Redis vect... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/redis.html |
b74647ce495f-1 | 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/redis.html |
b74647ce495f-2 | 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.
Redis as Retriever#
Here we go over different options for using the vector store as a retriever.
There are three different searc... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/redis.html |
e4cb50554fe8-0 | .ipynb
.pdf
Supabase (Postgres)
Contents
Similarity search with score
Retriever options
Maximal Marginal Relevance Searches
Supabase (Postgres)#
Supabase is an open source Firebase alternative. Supabase is built on top of PostgreSQL, which offers strong SQL querying capabilities and enables a simple interface with al... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
e4cb50554fe8-1 | SELECT
id,
content,
metadata,
embedding,
1 -(documents.embedding <=> query_embedding) AS similarity
FROM
documents
ORDER BY
documents.embedding <=> query_embedding
LIMIT match_count;... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
e4cb50554fe8-2 | docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
# We're using the default `documents` table here. You can modify this by passing in a `table_name` argument to the `from_documents` method.
vector_store = SupabaseVectorStore.from_documents(
docs, embeddings, client=supabase
)
query = "... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
e4cb50554fe8-3 | matched_docs[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 elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
e4cb50554fe8-4 | 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/supabase.html |
e4cb50554fe8-5 | ## Document 2
And I’m taking robust action to make sure the pain of our sanctions is targeted at Russia’s economy. And I will use every tool at our disposal to protect American businesses and consumers.
Tonight, I can announce that the United States has worked with 30 other countries to release 60 Million barrels of ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
e4cb50554fe8-6 | I’ve worked on these issues a long time.
I know what works: Investing in crime preventionand community police officers who’ll walk the beat, who’ll know the neighborhood, and who can restore trust and safety.
previous
SKLearnVectorStore
next
Tair
Contents
Similarity search with score
Retriever options
Maximal Marg... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
c8a15e21438d-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 |
c8a15e21438d-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 |
c4b9c6d1746e-0 | .ipynb
.pdf
ElasticSearch
Contents
Installation
Example
ElasticSearch#
Elasticsearch is a distributed, RESTful search and analytics engine. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.
This notebook shows how to use functionality rel... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
c4b9c6d1746e-1 | Follow the prompts to reset the password
Format for Elastic Cloud URLs is
https://username:password@cluster_id.region_id.gcp.cloud.es.io:9243.
Example:
from langchain import ElasticVectorSearch
from langchain.embeddings import OpenAIEmbeddings
embedding = OpenAIEmbeddings()
elastic_host ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
c4b9c6d1746e-2 | We cannot let this happen.
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 his life to serve this country: Justi... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
788d606b45d9-0 | .ipynb
.pdf
OpenSearch
Contents
Installation
similarity_search using Approximate k-NN
similarity_search using Script Scoring
similarity_search using Painless Scripting
Using a preexisting OpenSearch instance
OpenSearch#
OpenSearch is a scalable, flexible, and extensible open-source software suite for search, analytic... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/opensearch.html |
788d606b45d9-1 | embeddings = OpenAIEmbeddings()
similarity_search using Approximate k-NN#
similarity_search using Approximate k-NN Search with Custom Parameters
docsearch = OpenSearchVectorSearch.from_documents(
docs,
embeddings,
opensearch_url="http://localhost:9200"
)
# If using the default Docker installation, use thi... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/opensearch.html |
788d606b45d9-2 | print(docs[0].page_content)
similarity_search using Painless Scripting#
similarity_search using Painless Scripting with Custom Parameters
docsearch = OpenSearchVectorSearch.from_documents(docs, embeddings, opensearch_url="http://localhost:9200", is_appx_search=False)
filter = {"bool": {"filter": {"term": {"text": "smug... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/opensearch.html |
83dd9eccc188-0 | .ipynb
.pdf
AnalyticDB
AnalyticDB#
AnalyticDB for PostgreSQL is a massively parallel processing (MPP) data warehousing service that is designed to analyze large volumes of data online.
AnalyticDB for PostgreSQL is developed based on the open source Greenplum Database project and is enhanced with in-depth extensions by ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/analyticdb.html |
83dd9eccc188-1 | import os
connection_string = AnalyticDB.connection_string_from_db_params(
driver=os.environ.get("PG_DRIVER", "psycopg2cffi"),
host=os.environ.get("PG_HOST", "localhost"),
port=int(os.environ.get("PG_PORT", "5432")),
database=os.environ.get("PG_DATABASE", "postgres"),
user=os.environ.get("PG_USER", ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/analyticdb.html |
ebe12e652b4e-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 |
ebe12e652b4e-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 Jun 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pinecone.html |
47a1e1edcc1c-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 |
47a1e1edcc1c-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 |
47a1e1edcc1c-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 Jun 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/docarray_hnsw.html |
16bb9705f53b-0 | .ipynb
.pdf
MyScale
Contents
Setting up envrionments
Get connection info and data schema
Filtering
Deleting your data
MyScale#
MyScale is a cloud-based database optimized for AI applications and solutions, built on the open-source ClickHouse.
This notebook shows how to use functionality related to the MyScale vector ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/myscale.html |
16bb9705f53b-1 | text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
for d in docs:
d.metadata = {'some': 'metadata'}
docsearch = MyScale.from_documents(docs, embeddings)
query = "What did the president say about Ketanji Brown Jackso... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/myscale.html |
16bb9705f53b-2 | If you custimized your column_map under your setting, you search with filter like this:
from langchain.vectorstores import MyScale, MyScaleSettings
from langchain.document_loaders import TextLoader
loader = TextLoader('../../../state_of_the_union.txt')
documents = loader.load()
text_splitter = CharacterTextSplitter(chu... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/myscale.html |
16bb9705f53b-3 | Get connection info and data schema
Filtering
Deleting your data
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/myscale.html |
f0580a061033-0 | .ipynb
.pdf
MongoDB Atlas Vector Search
MongoDB Atlas Vector Search#
MongoDB Atlas is a document database managed in the cloud. It also enables Lucene and its vector search feature.
This notebook shows how to use the functionality related to the MongoDB Atlas Vector Search feature where you can store your embeddings in... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/mongodb_atlas_vector_search.html |
f0580a061033-1 | }
}
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import MongoDBAtlasVectorSearch
from langchain.document_loaders import TextLoader
from langchain.document_loaders import TextLoader
loader = TextLoader('../../../state_of_th... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/mongodb_atlas_vector_search.html |
15fea8987773-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 |
15fea8987773-1 | Hide embedded project
Explore on atlas.nomic.ai
previous
Annoy
next
Chroma
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html |
92328fc85d9e-0 | .ipynb
.pdf
Typesense
Contents
Similarity Search
Typesense as a Retriever
Typesense#
Typesense is an open source, in-memory search engine, that you can either self-host or run on Typesense Cloud.
Typesense focuses on performance by storing the entire index in RAM (with a backup on disk) and also focuses on providing ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/typesense.html |
92328fc85d9e-1 | 'typesense_api_key': 'xyz',
'typesense_collection_name': 'lang-chain'
})
Similarity Search#
query = "What did the president say about Ketanji Brown Jackson"
found_docs = docsearch.similarity_search(query)
print(found_docs[0].page_content)
Typ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/typesense.html |
f9e24dcf503a-0 | .ipynb
.pdf
DocArrayInMemorySearch
Contents
Setup
Using DocArrayInMemorySearch
Similarity search
Similarity search with score
DocArrayInMemorySearch#
DocArrayInMemorySearch is a document index provided by Docarray that stores documents in memory. It is a great starting point for small datasets, where you may not want... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/docarray_in_memory.html |
f9e24dcf503a-1 | 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/docarray_in_memory.html |
f9e24dcf503a-2 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/docarray_in_memory.html |
af7149cb26dd-0 | .ipynb
.pdf
Deep Lake
Contents
Retrieval Question/Answering
Attribute based filtering in metadata
Choosing distance function
Maximal Marginal relevance
Delete dataset
Deep Lake datasets on cloud (Activeloop, AWS, GCS, etc.) or in memory
Creating dataset on AWS S3
Deep Lake API
Transfer local dataset to cloud
Deep Lak... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
af7149cb26dd-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 |
af7149cb26dd-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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.