id stringlengths 14 16 | text stringlengths 36 2.73k | source stringlengths 49 117 |
|---|---|---|
ba56fe40175a-0 | .ipynb
.pdf
SVM
Contents
Create New Retriever with Texts
Use Retriever
SVM#
Support vector machines (SVMs) are a set of supervised learning methods used for classification, regression and outliers detection.
This notebook goes over how to use a retriever that under the hood uses an SVM using scikit-learn package.
Lar... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/svm.html |
ee676f9c3de6-0 | .ipynb
.pdf
Metal
Contents
Ingest Documents
Query
Metal#
Metal is a managed service for ML Embeddings.
This notebook shows how to use Metal’s retriever.
First, you will need to sign up for Metal and get an API key. You can do so here
# !pip install metal_sdk
from metal_sdk.metal import Metal
API_KEY = ""
CLIENT_ID = ... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/metal.html |
ee676f9c3de6-1 | previous
LOTR (Merger Retriever)
next
Pinecone Hybrid Search
Contents
Ingest Documents
Query
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/metal.html |
ddc054d924da-0 | .ipynb
.pdf
Azure Cognitive Search
Contents
Set up Azure Cognitive Search
Using the Azure Cognitive Search Retriever
Azure Cognitive Search#
Azure Cognitive Search (formerly known as Azure Search) is a cloud search service that gives developers infrastructure, APIs, and tools for building a rich search experience ove... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/azure_cognitive_search.html |
ddc054d924da-1 | os.environ["AZURE_COGNITIVE_SEARCH_API_KEY"] = "<YOUR_API_KEY>"
Create the Retriever
retriever = AzureCognitiveSearchRetriever(content_key="content")
Now you can use retrieve documents from Azure Cognitive Search
retriever.get_relevant_documents("what is langchain")
previous
AWS Kendra
next
ChatGPT Plugin
Contents
... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/azure_cognitive_search.html |
c4d79f4fb09c-0 | .ipynb
.pdf
Self-querying with Qdrant
Contents
Creating a Qdrant vectorstore
Creating our self-querying retriever
Testing it out
Filter k
Self-querying with Qdrant#
Qdrant (read: quadrant ) is a vector similarity search engine. It provides a production-ready service with a convenient API to store, search, and manage ... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html |
c4d79f4fb09c-1 | Document(page_content="A psychologist / detective gets lost in a series of dreams within dreams within dreams and Inception reused the idea", metadata={"year": 2006, "director": "Satoshi Kon", "rating": 8.6}),
Document(page_content="A bunch of normal-sized women are supremely wholesome and some men pine after them"... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html |
c4d79f4fb09c-2 | type="integer",
),
AttributeInfo(
name="director",
description="The name of the movie director",
type="string",
),
AttributeInfo(
name="rating",
description="A 1-10 rating for the movie",
type="float"
),
]
document_content_description = "Brief summa... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html |
c4d79f4fb09c-3 | query=' ' filter=Comparison(comparator=<Comparator.GT: 'gt'>, attribute='rating', value=8.5) limit=None
[Document(page_content='Three men walk into the Zone, three men walk out of the Zone', metadata={'year': 1979, 'rating': 9.9, 'director': 'Andrei Tarkovsky', 'genre': 'science fiction'}),
Document(page_content='A ps... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html |
c4d79f4fb09c-4 | [Document(page_content='Three men walk into the Zone, three men walk out of the Zone', metadata={'year': 1979, 'rating': 9.9, 'director': 'Andrei Tarkovsky', 'genre': 'science fiction'})]
# This example specifies a query and composite filter
retriever.get_relevant_documents("What's a movie after 1990 but before 2005 th... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html |
c4d79f4fb09c-5 | Document(page_content='Toys come alive and have a blast doing so', metadata={'year': 1995, 'genre': 'animated'})]
previous
PubMed Retriever
next
Self-querying
Contents
Creating a Qdrant vectorstore
Creating our self-querying retriever
Testing it out
Filter k
By Harrison Chase
© Copyright 2023, Harrison C... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html |
b96d7d3dd3ed-0 | .ipynb
.pdf
LOTR (Merger Retriever)
Contents
Remove redundant results from the merged retrievers.
LOTR (Merger Retriever)#
Lord of the Retrievers, also known as MergerRetriever, takes a list of retrievers as input and merges the results of their get_relevant_documents() methods into a single list. The merged results ... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/merger_retriever.html |
b96d7d3dd3ed-1 | # Instantiate 2 diff cromadb indexs, each one with a diff embedding.
client_settings = chromadb.config.Settings(
chroma_db_impl="duckdb+parquet",
persist_directory=DB_DIR,
anonymized_telemetry=False,
)
db_all = Chroma(
collection_name="project_store_all",
persist_directory=DB_DIR,
client_setting... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/merger_retriever.html |
b96d7d3dd3ed-2 | base_compressor=pipeline, base_retriever=lotr
)
previous
kNN
next
Metal
Contents
Remove redundant results from the merged retrievers.
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/merger_retriever.html |
de2de9353f7f-0 | .ipynb
.pdf
ChatGPT Plugin
Contents
Using the ChatGPT Retriever Plugin
ChatGPT Plugin#
OpenAI plugins connect ChatGPT to third-party applications. These plugins enable ChatGPT to interact with APIs defined by developers, enhancing ChatGPT’s capabilities and allowing it to perform a wide range of actions.
Plugins can ... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin.html |
de2de9353f7f-1 | Using the ChatGPT Retriever Plugin#
Okay, so we’ve created the ChatGPT Retriever Plugin, but how do we actually use it?
The below code walks through how to do that.
We want to use ChatGPTPluginRetriever so we have to get the OpenAI API Key.
import os
import getpass
os.environ['OPENAI_API_KEY'] = getpass.getpass('OpenAI... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin.html |
de2de9353f7f-2 | Document(page_content='Team: Angels "Payroll (millions)": 154.49 "Wins": 89', lookup_str='', metadata={'id': '59c2c0c1-ae3f-4272-a1da-f44a723ea631_0', 'metadata': {'source': None, 'source_id': None, 'url': None, 'created_at': None, 'author': None, 'document_id': '59c2c0c1-ae3f-4272-a1da-f44a723ea631'}, 'embedding': Non... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin.html |
701cc57412b8-0 | .ipynb
.pdf
Vespa
Vespa#
Vespa is a fully featured search engine and vector database. It supports vector search (ANN), lexical search, and search in structured data, all in the same query.
This notebook shows how to use Vespa.ai as a LangChain retriever.
In order to create a retriever, we use pyvespa to
create a connec... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vespa.html |
701cc57412b8-1 | retriever.get_relevant_documents("what is vespa?")
previous
VectorStore
next
Weaviate Hybrid Search
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vespa.html |
a1e52cf4c921-0 | .ipynb
.pdf
Self-querying with Weaviate
Contents
Creating a Weaviate vectorstore
Creating our self-querying retriever
Testing it out
Filter k
Self-querying with Weaviate#
Creating a Weaviate vectorstore#
First we’ll want to create a Weaviate VectorStore and seed it with some data. We’ve created a small demo set of do... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html |
a1e52cf4c921-1 | Document(page_content="Toys come alive and have a blast doing so", metadata={"year": 1995, "genre": "animated"}),
Document(page_content="Three men walk into the Zone, three men walk out of the Zone", metadata={"year": 1979, "rating": 9.9, "director": "Andrei Tarkovsky", "genre": "science fiction", "rating": 9.9})
]... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html |
a1e52cf4c921-2 | llm = OpenAI(temperature=0)
retriever = SelfQueryRetriever.from_llm(llm, vectorstore, document_content_description, metadata_field_info, verbose=True)
Testing it out#
And now we can try actually using our retriever!
# This example only specifies a relevant query
retriever.get_relevant_documents("What are some movies ab... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html |
a1e52cf4c921-3 | We can do this by passing enable_limit=True to the constructor.
retriever = SelfQueryRetriever.from_llm(
llm,
vectorstore,
document_content_description,
metadata_field_info,
enable_limit=True,
verbose=True
)
# This example only specifies a relevant query
retriever.get_relevant_documents("wha... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html |
a834fcc40dd5-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 |
a834fcc40dd5-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 |
a834fcc40dd5-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 |
a834fcc40dd5-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 |
db0de848ad48-0 | .ipynb
.pdf
Arxiv
Contents
Installation
Examples
Running retriever
Question Answering on facts
Arxiv#
arXiv is an open-access archive for 2 million scholarly articles in the fields of physics, mathematics, computer science, quantitative biology, quantitative finance, statistics, electrical engineering and systems sci... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/arxiv.html |
db0de848ad48-1 | 'Authors': 'Caprice Stanley, Tobias Windisch',
'Summary': 'Graphs on lattice points are studied whose edges come from a finite set of\nallowed moves of arbitrary length. We show that the diameter of these graphs on\nfibers of a fixed integer matrix can be bounded from above by a constant. We\nthen study the mixing beh... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/arxiv.html |
db0de848ad48-2 | questions = [
"What are Heat-bath random walks with Markov base?",
"What is the ImageBind model?",
"How does Compositional Reasoning with Large Language Models works?",
]
chat_history = []
for question in questions:
result = qa({"question": question, "chat_history": chat_history})
chat_history... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/arxiv.html |
db0de848ad48-3 | -> **Question**: How does Compositional Reasoning with Large Language Models works?
**Answer**: Compositional reasoning with large language models refers to the ability of these models to correctly identify and represent complex concepts by breaking them down into smaller, more basic parts and combining them in a stru... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/arxiv.html |
db0de848ad48-4 | **Answer**: Heat-bath random walks with Markov base (HB-MB) is a class of stochastic processes that have been studied in the field of statistical mechanics and condensed matter physics. In these processes, a particle moves in a lattice by making a transition to a neighboring site, which is chosen according to a probabi... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/arxiv.html |
e56c5e03b7c6-0 | .ipynb
.pdf
AWS Kendra
Contents
Using the AWS Kendra Index Retriever
AWS Kendra#
AWS Kendra is an intelligent search service provided by Amazon Web Services (AWS). It utilizes advanced natural language processing (NLP) and machine learning algorithms to enable powerful search capabilities across various data sources ... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/aws_kendra_index_retriever.html |
d8e1480bac46-0 | .ipynb
.pdf
TF-IDF
Contents
Create New Retriever with Texts
Create a New Retriever with Documents
Use Retriever
TF-IDF#
TF-IDF means term-frequency times inverse document-frequency.
This notebook goes over how to use a retriever that under the hood uses TF-IDF using scikit-learn package.
For more information on the d... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/tf_idf.html |
e6dc0535abc1-0 | .ipynb
.pdf
PubMed Retriever
PubMed Retriever#
This notebook goes over how to use PubMed as a retriever
PubMed® comprises more than 35 million citations for biomedical literature from MEDLINE, life science journals, and online books. Citations may include links to full text content from PubMed Central and publisher web... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/pubmed.html |
e6dc0535abc1-1 | previous
Pinecone Hybrid Search
next
Self-querying with Qdrant
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/pubmed.html |
28f0f7081065-0 | .ipynb
.pdf
Cohere Reranker
Contents
Set up the base vector store retriever
Doing reranking with CohereRerank
Cohere Reranker#
Cohere is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions.
This notebook shows how to use Cohere’s rerank endpoint i... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
28f0f7081065-1 | texts = text_splitter.split_documents(documents)
retriever = FAISS.from_documents(texts, OpenAIEmbeddings()).as_retriever(search_kwargs={"k": 20})
query = "What did the president say about Ketanji Brown Jackson"
docs = retriever.get_relevant_documents(query)
pretty_print_docs(docs)
Document 1:
One of the most serious c... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
28f0f7081065-2 | Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland.
In this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight.... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
28f0f7081065-3 | It’s exploitation—and it drives up prices.
----------------------------------------------------------------------------------------------------
Document 8:
For the past 40 years we were told that if we gave tax breaks to those at the very top, the benefits would trickle down to everyone else.
But that trickle-down the... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
28f0f7081065-4 | The pandemic has been punishing.
And so many families are living paycheck to paycheck, struggling to keep up with the rising cost of food, gas, housing, and so much more.
I understand.
----------------------------------------------------------------------------------------------------
Document 12:
Madam Speaker, Mada... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
28f0f7081065-5 | Third, support our veterans.
Veterans are the best of us.
I’ve always believed that we have a sacred obligation to equip all those we send to war and care for them and their families when they come home.
My administration is providing assistance with job training and housing, and now helping lower-income veterans ge... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
28f0f7081065-6 | ----------------------------------------------------------------------------------------------------
Document 19:
I understand.
I remember when my Dad had to leave our home in Scranton, Pennsylvania to find work. I grew up in a family where if the price of food went up, you felt it.
That’s why one of the first things... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
28f0f7081065-7 | 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.
----------------------------------------------------------------------------------------------------
Document 2:
I spoke with th... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
28f0f7081065-8 | previous
Self-querying with Chroma
next
Contextual Compression
Contents
Set up the base vector store retriever
Doing reranking with CohereRerank
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
50dc7dbc9d7e-0 | .ipynb
.pdf
Getting Started
Contents
Add texts
From Documents
Getting Started#
This notebook showcases basic functionality related to VectorStores. A key part of working with vectorstores is creating the vector to put in them, which is usually created via embeddings. Therefore, it is recommended that you familiarize ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/getting_started.html |
50dc7dbc9d7e-1 | 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/getting_started.html |
50dc7dbc9d7e-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/getting_started.html |
8a148b41b975-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 |
8a148b41b975-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 |
8a148b41b975-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 |
2253129e66b5-0 | .ipynb
.pdf
ClickHouse Vector Search
Contents
Setting up envrionments
Get connection info and data schema
Clickhouse table schema
Filtering
Deleting your data
ClickHouse Vector Search#
ClickHouse is the fastest and most resource efficient open-source database for real-time apps and analytics with full SQL support and... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/clickhouse.html |
2253129e66b5-1 | docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
for d in docs:
d.metadata = {'some': 'metadata'}
settings = ClickhouseSettings(table="clickhouse_vector_search_example")
docsearch = Clickhouse.from_documents(docs, embeddings, config=settings)
query = "What did the president say about ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/clickhouse.html |
2253129e66b5-2 | |uuid |UUID |
---------------------------------------------------
Clickhouse table schema#
Clickhouse table will be automatically created if not exist by default. Advanced users could pre-create the table with optimized settings. For distributed Clickhouse cluster with sharding, ta... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/clickhouse.html |
2253129e66b5-3 | meta = docsearch.metadata_column
output = docsearch.similarity_search_with_relevance_scores('What did the president say about Ketanji Brown Jackson?',
k=4, where_str=f"{meta}.doc_id<10")
for d, dist in output:
print(dist, d.metadata, d.page_content[:20] + ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/clickhouse.html |
3f40017b794a-0 | .ipynb
.pdf
ElasticSearch
Contents
ElasticSearch
ElasticVectorSearch class
Installation
Example
ElasticKnnSearch Class
Test adding vectors
Test knn search using query vector builder
Test knn search using pre generated vector
Test source option
Test fields option
Test with es client connection rather than cloud_id
Ela... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
3f40017b794a-1 | To obtain your Elastic Cloud password for the default “elastic” user:
Log in to the Elastic Cloud console at https://cloud.elastic.co
Go to “Security” > “Users”
Locate the “elastic” user and click “Edit”
Click “Reset password”
Follow the prompts to reset the password
Format for Elastic Cloud URLs is
https://username:pa... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
3f40017b794a-2 | docs = db.similarity_search(query)
print(docs[0].page_content)
In state after state, new laws have been passed, not only to suppress the vote, but to subvert entire elections.
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 yo... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
3f40017b794a-3 | model_id,
#input_field=input_field,
es_cloud_id=es_cloud_id,
es_user=es_user,
es_password=es_password,
)
# Initialize ElasticKnnSearch
knn_search = ElasticKnnSearch(
es_cloud_id=es_cloud_id,
es_user=es_user,
es_password=es_password,
index_name= test_index,
embedding= embeddings
)
Test adding ve... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
3f40017b794a-4 | Test knn search using pre generated vector#
# Generate embedding for tests
query_text = 'Hello'
query_embedding = embeddings.embed_query(query_text)
print(f"Length of embedding: {len(query_embedding)}\nFirst two items in embedding: {query_embedding[:2]}")
# Test knn Search
knn_result = knn_search.knn_search(query_vecto... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
3f40017b794a-5 | assert 'text' in knn_result['hits']['hits'][0]['fields'].keys()
# Test `hybrid_search` method
query = "Hello"
hybrid_result = knn_search.knn_hybrid_search(query = query, model_id= model_id, k=2, fields=['text'])
assert 'text' in hybrid_result['hits']['hits'][0]['fields'].keys()
Test with es client connection rather tha... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
3f40017b794a-6 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
b7f1992d2312-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 |
b7f1992d2312-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 |
b7f1992d2312-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 |
df1dd20453d9-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 |
df1dd20453d9-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 |
df1dd20453d9-2 | Similarity search
Similarity search with score
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/docarray_in_memory.html |
4067997422c2-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 |
4067997422c2-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 |
56828f0d4b7f-0 | .ipynb
.pdf
SingleStoreDB vector search
SingleStoreDB vector search#
SingleStore DB is a high-performance distributed database that supports deployment both in the cloud and on-premises. For a significant duration, it has provided support for vector functions such as dot_product, thereby positioning itself as an ideal ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/singlestoredb.html |
56828f0d4b7f-1 | docsearch = SingleStoreDB.from_documents(
docs,
embeddings,
table_name = "noteook", # use table with a custom name
)
query = "What did the president say about Ketanji Brown Jackson"
docs = docsearch.similarity_search(query) # Find documents that correspond to the query
print(docs[0].page_content)
previous
... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/singlestoredb.html |
4a709ad2f118-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 |
4a709ad2f118-1 | 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 has dedicated his life to serve this country:... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/vectara.html |
4a709ad2f118-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.
Score: 0.7129974
Vectara as a Retriever#
Vectara, as all the other vector stores, is a LangChain Retriever, by using cosine simi... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/vectara.html |
4a709ad2f118-3 | previous
Typesense
next
Weaviate
Contents
Connecting to Vectara from LangChain
Similarity search
Similarity search with score
Vectara as a Retriever
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/vectara.html |
e2819ed910c4-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 |
e2819ed910c4-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 |
9d4bfd23f2ab-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 |
9d4bfd23f2ab-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 |
9d4bfd23f2ab-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 |
9d4bfd23f2ab-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 |
9d4bfd23f2ab-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 |
54e9dd38bf3c-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 |
54e9dd38bf3c-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 |
54e9dd38bf3c-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 |
54e9dd38bf3c-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 |
54e9dd38bf3c-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 |
54e9dd38bf3c-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 |
54e9dd38bf3c-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 |
63212a219bbe-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 |
63212a219bbe-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 |
63212a219bbe-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 |
63212a219bbe-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 |
3e8ffb678ec1-0 | .ipynb
.pdf
LanceDB
LanceDB#
LanceDB is an open-source database for vector-search built with persistent storage, which greatly simplifies retrevial, filtering and management of embeddings. Fully open source.
This notebook shows how to use functionality related to the LanceDB vector database based on the Lance data form... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lancedb.html |
3e8ffb678ec1-1 | I spoke with their families and told them that we are forever in debt for their sacrifice, and we will carry on their mission to restore the trust and safety every community deserves.
I’ve worked on these issues a long time.
I know what works: Investing in crime preventionand community police officers who’ll walk the... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lancedb.html |
3e8ffb678ec1-2 | These laws don’t infringe on the Second Amendment. They save lives.
The most fundamental right in America is the right to vote – and to have it counted. And it’s under assault.
In state after state, new laws have been passed, not only to suppress the vote, but to subvert entire elections.
We cannot let this happen. ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lancedb.html |
3e8ffb678ec1-3 | We’ve set up joint patrols with Mexico and Guatemala to catch more human traffickers.
We’re putting in place dedicated immigration judges so families fleeing persecution and violence can have their cases heard faster.
previous
FAISS
next
MatchingEngine
By Harrison Chase
© Copyright 2023, Harrison Chase.
... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lancedb.html |
422cc08f47b4-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 |
422cc08f47b4-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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.