id stringlengths 14 16 | text stringlengths 45 2.73k | source stringlengths 49 114 |
|---|---|---|
da64bfd03374-2 | index.query_with_sources(query)
{'question': 'What did the president say about Ketanji Brown Jackson',
'answer': " The president said that he nominated Circuit Court of Appeals Judge Ketanji Brown Jackson, one of the nation's top legal minds, to continue Justice Breyer's legacy of excellence, and that she has received... | https://python.langchain.com/en/latest/modules/indexes/getting_started.html |
da64bfd03374-3 | We will then select which embeddings we want to use.
from langchain.embeddings import OpenAIEmbeddings
embeddings = OpenAIEmbeddings()
We now create the vectorstore to use as the index.
from langchain.vectorstores import Chroma
db = Chroma.from_documents(texts, embeddings)
Running Chroma using direct local API.
Using D... | https://python.langchain.com/en/latest/modules/indexes/getting_started.html |
da64bfd03374-4 | )
Hopefully this highlights what is going on under the hood of VectorstoreIndexCreator. While we think it’s important to have a simple way to create indexes, we also think it’s important to understand what’s going on under the hood.
previous
Indexes
next
Document Loaders
Contents
One Line Index Creation
Walkthrough... | https://python.langchain.com/en/latest/modules/indexes/getting_started.html |
14f155f93635-0 | .rst
.pdf
Text Splitters
Text Splitters#
Note
Conceptual Guide
When you want to deal with long pieces of text, it is necessary to split up that text into chunks.
As simple as this sounds, there is a lot of potential complexity here. Ideally, you want to keep the semantically related pieces of text together. What “seman... | https://python.langchain.com/en/latest/modules/indexes/text_splitters.html |
678126f6c7db-0 | .rst
.pdf
Retrievers
Retrievers#
Note
Conceptual Guide
The retriever interface is a generic interface that makes it easy to combine documents with
language models. This interface exposes a get_relevant_documents method which takes in a query
(a string) and returns a list of documents.
Please see below for a list of all... | https://python.langchain.com/en/latest/modules/indexes/retrievers.html |
ac2a655e0447-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 |
ac2a655e0447-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/getting_started.html |
ac2a655e0447-2 | 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 you’re at it, pass the Disclose Act s... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/getting_started.html |
802c6b2a5b49-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#
This notebook shows how to use functionality related to the Annoy vector database.
“Annoy (Approxima... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
802c6b2a5b49-1 | 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.1580758094787598)]
Create VectorStore from docs#
from langchain... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
802c6b2a5b49-2 | 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 |
802c6b2a5b49-3 | 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 |
802c6b2a5b49-4 | 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 |
802c6b2a5b49-5 | 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 |
802c6b2a5b49-6 | (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 |
802c6b2a5b49-7 | 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 |
802c6b2a5b49-8 | 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 |
b052536883e5-0 | .ipynb
.pdf
Redis
Contents
RedisVectorStoreRetriever
Redis#
This notebook shows how to use functionality related to the Redis vector database.
from langchain.embeddings import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores.redis import Redis
from langchain.docum... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/redis.html |
b052536883e5-1 | print(rds.add_texts(["Ankush went to Princeton"]))
['doc:link:d7d02e3faf1b40bbbe29a683ff75b280']
query = "Princeton"
results = rds.similarity_search(query)
print(results[0].page_content)
Ankush went to Princeton
# Load from existing index
rds = Redis.from_existing_index(embeddings, redis_url="redis://localhost:6379", i... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/redis.html |
b052536883e5-2 | docs = retriever.get_relevant_documents(query)
We can also use similarity_limit as a search method. This is only return documents if they are similar enough
retriever = rds.as_retriever(search_type="similarity_limit")
# Here we can see it doesn't return any results because there are no relevant documents
retriever.get_... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/redis.html |
b47d68b5de87-0 | .ipynb
.pdf
FAISS
Contents
Similarity Search with score
Saving and loading
Merging
FAISS#
This notebook shows how to use functionality related to the FAISS vector database.
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores im... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
b47d68b5de87-1 | Similarity Search with score#
There are some FAISS specific methods. One of them is similarity_search_with_score, which allows you to return not only the documents but also the similarity score of the query to them.
docs_and_scores = db.similarity_search_with_score(query)
docs_and_scores[0]
(Document(page_content='In s... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
b47d68b5de87-2 | db.save_local("faiss_index")
new_db = FAISS.load_local("faiss_index", embeddings)
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 t... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
b47d68b5de87-3 | db2.docstore._dict
{'bdc50ae3-a1bb-4678-9260-1b0979578f40': Document(page_content='bar', lookup_str='', metadata={}, lookup_index=0)}
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-4800e7... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
118a95fd7a57-0 | .ipynb
.pdf
SupabaseVectorStore
Contents
Similarity search with score
Retriever options
Maximal Marginal Relevance Searches
SupabaseVectorStore#
This notebook shows how to use Supabase and pgvector as your VectorStore.
To run this notebook, please ensure:
the pgvector extension is enabled
you have installed the supab... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
118a95fd7a57-1 | $$;
# with pip
# !pip install supabase
# with conda
# !conda install -c conda-forge supabase
# If you're storing your Supabase and OpenAI API keys in a .env file, you can load them with dotenv
from dotenv import load_dotenv
load_dotenv()
True
import os
from supabase.client import Client, create_client
supabase_url = os... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
118a95fd7a57-2 | print(matched_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 countr... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
118a95fd7a57-3 | 0.802509746274066)
Retriever options#
This section goes over different options for how to use SupabaseVectorStore as a retriever.
Maximal Marginal Relevance Searches#
In addition to using similarity search in the retriever object, you can also use mmr.
retriever = vector_store.as_retriever(search_type="mmr")
matched_do... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
118a95fd7a57-4 | A cancer that would put them in a flag-draped coffin.
I know.
One of those soldiers was my son Major Beau Biden.
We don’t know for sure if a burn pit was the cause of his brain cancer, or the diseases of so many of our troops.
But I’m committed to finding out everything we can.
Committed to military families like ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
118a95fd7a57-5 | ## Document 3
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 ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
c2b4104e006d-0 | .ipynb
.pdf
AtlasDB
AtlasDB#
This notebook shows you how to use functionality related to the AtlasDB
import time
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import SpacyTextSplitter
from langchain.vectorstores import AtlasDB
from langchain.document_loaders import TextLoader
!py... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html |
c2b4104e006d-1 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 21, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html |
b811e1e108df-0 | .ipynb
.pdf
PGVector
Contents
Similarity search with score
Similarity Search with Euclidean Distance (Default)
PGVector#
This notebook shows how to use functionality related to the Postgres vector database (PGVector).
## Loading Environment Variables
from typing import List, Tuple
from dotenv import load_dotenv
load_... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
b811e1e108df-1 | # permission to create a table.
db = PGVector.from_documents(
embedding=embeddings,
documents=docs,
collection_name="state_of_the_union",
connection_string=CONNECTION_STRING,
)
query = "What did the president say about Ketanji Brown Jackson"
docs_with_score: List[Tuple[Document, float]] = db.similarity_... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
b811e1e108df-2 | 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/pgvector.html |
b811e1e108df-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/pgvector.html |
a982b90fb86c-0 | .ipynb
.pdf
OpenSearch
Contents
similarity_search using Approximate k-NN Search with Custom Parameters
similarity_search using Script Scoring with Custom Parameters
similarity_search using Painless Scripting with Custom Parameters
Using a preexisting OpenSearch instance
OpenSearch#
This notebook shows how to use func... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/opensearch.html |
a982b90fb86c-1 | query = "What did the president say about Ketanji Brown Jackson"
docs = docsearch.similarity_search(query)
print(docs[0].page_content)
similarity_search using Script Scoring with Custom Parameters#
docsearch = OpenSearchVectorSearch.from_documents(docs, embeddings, opensearch_url="http://localhost:9200", is_appx_search... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/opensearch.html |
a982b90fb86c-2 | docs = docsearch.similarity_search("Who was asking about getting lunch today?", search_type="script_scoring", space_type="cosinesimil", vector_field="message_embedding", text_field="message", metadata_field="message_metadata")
previous
Milvus
next
PGVector
Contents
similarity_search using Approximate k-NN Search wi... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/opensearch.html |
40b19c618431-0 | .ipynb
.pdf
Pinecone
Pinecone#
This notebook shows how to use functionality related to the Pinecone vector database.
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import Pinecone
from langchain.document_loaders import TextL... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pinecone.html |
be8601aca12e-0 | .ipynb
.pdf
Deep Lake
Contents
Retrieval Question/Answering
Attribute based filtering in metadata
Choosing distance function
Maximal Marginal relevance
Deep Lake datasets on cloud (Activeloop, AWS, GCS, etc.) or local
Deep Lake#
This notebook showcases basic functionality related to Deep Lake. While Deep Lake can sto... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
be8601aca12e-1 | ------- ------- ------- ------- -------
embedding generic (4, 1536) float32 None
ids text (4, 1) str None
metadata json (4, 1) str None
text text (4, 1) str None
print(docs[0].page_content)
Tonight. I call on the Senate to: Pass the F... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
be8601aca12e-2 | warnings.warn(
query = 'What did the president say about Ketanji Brown Jackson'
qa.run(query)
'The president nominated Circuit Court of Appeals Judge Ketanji Brown Jackson for the United States Supreme Court and praised her qualifications and broad support from both Democrats and Republicans.'
Attribute based filtering... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
be8601aca12e-3 | [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 b... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
be8601aca12e-4 | 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 |
be8601aca12e-5 | Document(page_content='Vice President Harris and I ran for office with a new economic vision for America. \n\nInvest in America. Educate Americans. Grow the workforce. Build the economy from the bottom up \nand the middle out, not from the top down. \n\nBecause we know that when the middle class grows, the poor have ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
be8601aca12e-6 | Document(page_content='It is going to transform America and put us on a path to win the economic competition of the 21st Century that we face with the rest of the world—particularly with China. \n\nAs I’ve told Xi Jinping, it is never a good bet to bet against the American people. \n\nWe’ll create good jobs for millio... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
be8601aca12e-7 | [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 |
be8601aca12e-8 | 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 |
be8601aca12e-9 | 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 |
be8601aca12e-10 | 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 |
be8601aca12e-11 | [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 |
be8601aca12e-12 | Document(page_content='One was stationed at bases and breathing in toxic smoke from “burn pits” that incinerated wastes of war—medical and hazard material, jet fuel, and more. \n\nWhen they came home, many of the world’s fittest and best trained warriors were never the same. \n\nHeadaches. Numbness. Dizziness. \n\nA ca... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
be8601aca12e-13 | Document(page_content='As Ohio Senator Sherrod Brown says, “It’s time to bury the label “Rust Belt.” \n\nIt’s time. \n\nBut with all the bright spots in our economy, record job growth and higher wages, too many families are struggling to keep up with the bills. \n\nInflation is robbing them of the gains they might oth... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
be8601aca12e-14 | Document(page_content='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. \n\nI recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera. \n\nThey were respond... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
be8601aca12e-15 | embedding = OpenAIEmbeddings()
vectordb = DeepLake.from_documents(documents=docs, embedding=embedding, dataset_path=dataset_path)
Your Deep Lake dataset has been successfully created!
The dataset is private so make sure you are logged in!
\
This dataset can be visualized in Jupyter Notebook by ds.visualize() or at http... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
be8601aca12e-16 | 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/deeplake.html |
fa3408ba3b6a-0 | .ipynb
.pdf
Zilliz
Zilliz#
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: https://zilliz.com/cloud
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import CharacterText... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/zilliz.html |
884d9e78bfcf-0 | .ipynb
.pdf
ElasticSearch
ElasticSearch#
This notebook shows how to use functionality related to the ElasticSearch database.
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import ElasticVectorSearch
from langchain.document_l... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
884d9e78bfcf-1 | 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.
previous
Deep Lake
next
FAISS
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 21, 20... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
62be421278af-0 | .ipynb
.pdf
Milvus
Milvus#
This notebook shows how to use functionality related to the Milvus vector database.
To run, you should have a Milvus instance up and running: https://milvus.io/docs/install_standalone-docker.md
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import Charac... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/milvus.html |
550f4784f3c7-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
Chroma#
This notebook shows how to use functionality related to the Chroma vector database.
from langchain.embeddings.openai imp... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
550f4784f3c7-1 | 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.
Similarity search with score#
docs = db.similarity_search_with_score(query)
docs[0]
(Document(page_content='In state after state... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
550f4784f3c7-2 | # Supplying a persist_directory will store the embeddings on disk
persist_directory = 'db'
embedding = OpenAIEmbeddings()
vectordb = Chroma.from_documents(documents=docs, embedding=embedding, persist_directory=persist_directory)
Running Chroma using direct local API.
No existing DB found in db, skipping load
No existin... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
550f4784f3c7-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 |
7f45cc552d91-0 | .ipynb
.pdf
Weaviate
Weaviate#
This notebook shows how to use functionality related to the Weaviate vector database.
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import Weaviate
from langchain.document_loaders import TextL... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
7f45cc552d91-1 | },
],
},
]
}
client.schema.create(schema)
vectorstore = Weaviate(client, "Paragraph", "content")
query = "What did the president say about Ketanji Brown Jackson"
docs = vectorstore.similarity_search(query)
print(docs[0].page_content)
previous
SupabaseVectorStore
next
Zilliz
By Harrison Chase
... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
d7fe425bb46e-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#
This notebo... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
d7fe425bb46e-1 | qdrant = Qdrant.from_documents(
docs, embeddings,
location=":memory:", # Local mode with in-memory storage only
collection_name="my_documents",
)
On-disk storage#
Local mode, without using the Qdrant server, may also store your vectors on disk so they’re persisted between runs.
qdrant = Qdrant.from_docume... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
d7fe425bb46e-2 | collection_name="my_documents",
)
Reusing the same collection#
Both Qdrant.from_texts and Qdrant.from_documents methods are great to start using Qdrant with LangChain, but they are going to destroy the collection and create it from scratch! If you want to reuse the existing collection, you can always create an instance... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
d7fe425bb46e-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.
Similarity search with score#
Sometimes we might want to perform the search, but also obtain a relevancy score to know how good ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
d7fe425bb46e-4 | query = "What did the president say about Ketanji Brown Jackson"
found_docs = qdrant.max_marginal_relevance_search(query, k=2, fetch_k=10)
for i, doc in enumerate(found_docs):
print(f"{i + 1}.", doc.page_content, "\n")
1. Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rig... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
d7fe425bb46e-5 | 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/qdrant.html |
d7fe425bb46e-6 | 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/qdrant.html |
d7fe425bb46e-7 | 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-premise server deployment
Qdrant Cloud
Reusing the same collection
Similarity search
Similarity search with sco... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
432f0f26fb1a-0 | .ipynb
.pdf
CoNLL-U
CoNLL-U#
This is an example of how to load a file in CoNLL-U format. The whole file is treated as one document. The example data (conllu.conllu) is based on one of the standard UD/CoNLL-U examples.
from langchain.document_loaders import CoNLLULoader
loader = CoNLLULoader("example_data/conllu.conllu"... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/CoNLL-U.html |
824d6ea9a3e1-0 | .ipynb
.pdf
Roam
Contents
🧑 Instructions for ingesting your own dataset
Roam#
This notebook covers how to load documents from a Roam database. This takes a lot of inspiration from the example repo here.
🧑 Instructions for ingesting your own dataset#
Export your dataset from Roam Research. You can do this by clickin... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/roam.html |
5b06bd1c2247-0 | .ipynb
.pdf
s3 Directory
Contents
Specifying a prefix
s3 Directory#
This covers how to load document objects from an s3 directory object.
from langchain.document_loaders import S3DirectoryLoader
#!pip install boto3
loader = S3DirectoryLoader("testing-hwc")
loader.load()
[Document(page_content='Lorem ipsum dolor sit a... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/s3_directory.html |
fef9c0eb9d08-0 | .ipynb
.pdf
CSV Loader
Contents
Customizing the csv parsing and loading
Specify a column to be used identify the document source
CSV Loader#
Load csv files with a single row per document.
from langchain.document_loaders.csv_loader import CSVLoader
loader = CSVLoader(file_path='./example_data/mlb_teams_2012.csv')
data... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-1 | [Document(page_content='Team: Nationals\n"Payroll (millions)": 81.34\n"Wins": 98', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 0}, lookup_index=0), Document(page_content='Team: Reds\n"Payroll (millions)": 82.20\n"Wins": 97', lookup_str='', metadata={'source': './example_data/mlb_teams... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-2 | lookup_index=0), Document(page_content='Team: Rangers\n"Payroll (millions)": 120.51\n"Wins": 93', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 6}, lookup_index=0), Document(page_content='Team: Orioles\n"Payroll (millions)": 81.43\n"Wins": 93', lookup_str='', metadata={'source': './exam... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-3 | 'row': 11}, lookup_index=0), Document(page_content='Team: Dodgers\n"Payroll (millions)": 95.14\n"Wins": 86', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 12}, lookup_index=0), Document(page_content='Team: White Sox\n"Payroll (millions)": 96.92\n"Wins": 85', lookup_str='', metadata={'so... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-4 | 'row': 17}, lookup_index=0), Document(page_content='Team: Padres\n"Payroll (millions)": 55.24\n"Wins": 76', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 18}, lookup_index=0), Document(page_content='Team: Mariners\n"Payroll (millions)": 81.97\n"Wins": 75', lookup_str='', metadata={'sour... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-5 | 'row': 23}, lookup_index=0), Document(page_content='Team: Red Sox\n"Payroll (millions)": 173.18\n"Wins": 69', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 24}, lookup_index=0), Document(page_content='Team: Indians\n"Payroll (millions)": 78.43\n"Wins": 68', lookup_str='', metadata={'sou... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-6 | Customizing the csv parsing and loading#
See the csv module documentation for more information of what csv args are supported.
loader = CSVLoader(file_path='./example_data/mlb_teams_2012.csv', csv_args={
'delimiter': ',',
'quotechar': '"',
'fieldnames': ['MLB Team', 'Payroll in millions', 'Wins']
})
data = ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-7 | [Document(page_content='MLB Team: Team\nPayroll in millions: "Payroll (millions)"\nWins: "Wins"', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 0}, lookup_index=0), Document(page_content='MLB Team: Nationals\nPayroll in millions: 81.34\nWins: 98', lookup_str='', metadata={'source': './e... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-8 | './example_data/mlb_teams_2012.csv', 'row': 5}, lookup_index=0), Document(page_content='MLB Team: Athletics\nPayroll in millions: 55.37\nWins: 94', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 6}, lookup_index=0), Document(page_content='MLB Team: Rangers\nPayroll in millions: 120.51\nW... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-9 | in millions: 132.30\nWins: 88', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 11}, lookup_index=0), Document(page_content='MLB Team: Cardinals\nPayroll in millions: 110.30\nWins: 88', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 12}, lookup_index=0), Do... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-10 | 16}, lookup_index=0), Document(page_content='MLB Team: Diamondbacks\nPayroll in millions: 74.28\nWins: 81', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 17}, lookup_index=0), Document(page_content='MLB Team: Pirates\nPayroll in millions: 63.43\nWins: 79', lookup_str='', metadata={'sour... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-11 | metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 22}, lookup_index=0), Document(page_content='MLB Team: Royals\nPayroll in millions: 60.91\nWins: 72', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 23}, lookup_index=0), Document(page_content='MLB Team: Marlins\nPayroll in ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-12 | in millions: 78.06\nWins: 64', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 28}, lookup_index=0), Document(page_content='MLB Team: Cubs\nPayroll in millions: 88.19\nWins: 61', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 29}, lookup_index=0), Document(... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-13 | Specify a column to be used identify the document source#
Use the source_column argument to specify a column to be set as the source for the document created from each row. Otherwise file_path will be used as the source for all documents created from the csv file.
This is useful when using documents loaded from CSV fil... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-14 | [Document(page_content='Team: Nationals\n"Payroll (millions)": 81.34\n"Wins": 98', lookup_str='', metadata={'source': 'Nationals', 'row': 0}, lookup_index=0), Document(page_content='Team: Reds\n"Payroll (millions)": 82.20\n"Wins": 97', lookup_str='', metadata={'source': 'Reds', 'row': 1}, lookup_index=0), Document(page... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-15 | 'row': 6}, lookup_index=0), Document(page_content='Team: Orioles\n"Payroll (millions)": 81.43\n"Wins": 93', lookup_str='', metadata={'source': 'Orioles', 'row': 7}, lookup_index=0), Document(page_content='Team: Rays\n"Payroll (millions)": 64.17\n"Wins": 90', lookup_str='', metadata={'source': 'Rays', 'row': 8}, lookup_... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-16 | lookup_str='', metadata={'source': 'White Sox', 'row': 13}, lookup_index=0), Document(page_content='Team: Brewers\n"Payroll (millions)": 97.65\n"Wins": 83', lookup_str='', metadata={'source': 'Brewers', 'row': 14}, lookup_index=0), Document(page_content='Team: Phillies\n"Payroll (millions)": 174.54\n"Wins": 81', lookup... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-17 | (millions)": 93.35\n"Wins": 74', lookup_str='', metadata={'source': 'Mets', 'row': 20}, lookup_index=0), Document(page_content='Team: Blue Jays\n"Payroll (millions)": 75.48\n"Wins": 73', lookup_str='', metadata={'source': 'Blue Jays', 'row': 21}, lookup_index=0), Document(page_content='Team: Royals\n"Payroll (millions)... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-18 | lookup_index=0), Document(page_content='Team: Rockies\n"Payroll (millions)": 78.06\n"Wins": 64', lookup_str='', metadata={'source': 'Rockies', 'row': 27}, lookup_index=0), Document(page_content='Team: Cubs\n"Payroll (millions)": 88.19\n"Wins": 61', lookup_str='', metadata={'source': 'Cubs', 'row': 28}, lookup_index=0),... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
fef9c0eb9d08-19 | previous
Copy Paste
next
DataFrame Loader
Contents
Customizing the csv parsing and loading
Specify a column to be used identify the document source
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 21, 2023. | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/csv.html |
182a9f626a5e-0 | .ipynb
.pdf
Slack (Local Exported Zipfile)
Contents
🧑 Instructions for ingesting your own dataset
Slack (Local Exported Zipfile)#
This notebook covers how to load documents from a Zipfile generated from a Slack export.
In order to get this Slack export, follow these instructions:
🧑 Instructions for ingesting your o... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/slack_directory.html |
457342ee84bb-0 | .ipynb
.pdf
Diffbot
Diffbot#
This covers how to extract HTML documents from a list of URLs using the Diffbot extract API, into a document format that we can use downstream.
urls = [
"https://python.langchain.com/en/latest/index.html",
]
The Diffbot Extract API Requires an API token. Once you have it, you can extrac... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/diffbot.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.