id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
7d1c975f99e3-0
.ipynb .pdf Time Weighted VectorStore Contents Low Decay Rate High Decay Rate Virtual Time Time Weighted VectorStore# This retriever uses a combination of semantic similarity and a time decay. The algorithm for scoring them is: semantic_similarity + (1.0 - decay_rate) ** hours_passed Notably, hours_passed refers to t...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/time_weighted_vectorstore.html
7d1c975f99e3-1
retriever.add_documents([Document(page_content="hello foo")]) ['d7f85756-2371-4bdf-9140-052780a0f9b3'] # "Hello World" is returned first because it is most salient, and the decay rate is close to 0., meaning it's still recent enough retriever.get_relevant_documents("hello world") [Document(page_content='hello world', m...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/time_weighted_vectorstore.html
7d1c975f99e3-2
# "Hello Foo" is returned first because "hello world" is mostly forgotten retriever.get_relevant_documents("hello world") [Document(page_content='hello foo', metadata={'last_accessed_at': datetime.datetime(2023, 4, 16, 22, 9, 2, 494798), 'created_at': datetime.datetime(2023, 4, 16, 22, 9, 2, 178722), 'buffer_idx': 1})]...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/time_weighted_vectorstore.html
20e8da6b3c42-0
.ipynb .pdf Getting Started Getting Started# The default recommended text splitter is the RecursiveCharacterTextSplitter. This text splitter takes a list of characters. It tries to create chunks based on splitting on the first character, but if any chunks are too large it then moves onto the next character, and so fort...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/getting_started.html
20e8da6b3c42-1
previous Text Splitters next Character By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/getting_started.html
2f969e01ba35-0
.ipynb .pdf Python Code Python Code# PythonCodeTextSplitter splits text along python class and method definitions. It’s implemented as a simple subclass of RecursiveCharacterSplitter with Python-specific separators. See the source code to see the Python syntax expected by default. How the text is split: by list of pyth...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/python.html
aa9a1e563083-0
.ipynb .pdf tiktoken (OpenAI) tokenizer tiktoken (OpenAI) tokenizer# tiktoken is a fast BPE tokenizer created by OpenAI. We can use it to estimate tokens used. It will probably be more accurate for the OpenAI models. How the text is split: by character passed in How the chunk size is measured: by tiktoken tokenizer #!p...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/tiktoken.html
99fc82a18bfe-0
.ipynb .pdf LaTeX LaTeX# LaTeX is widely used in academia for the communication and publication of scientific documents in many fields, including mathematics, computer science, engineering, physics, chemistry, economics, linguistics, quantitative psychology, philosophy, and political science. LatexTextSplitter splits t...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/latex.html
99fc82a18bfe-1
latex_splitter = LatexTextSplitter(chunk_size=400, chunk_overlap=0) docs = latex_splitter.create_documents([latex_text]) docs [Document(page_content='\\documentclass{article}\n\n\x08egin{document}\n\n\\maketitle', lookup_str='', metadata={}, lookup_index=0), Document(page_content='Introduction}\nLarge language models ...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/latex.html
99fc82a18bfe-2
'Introduction}\nLarge language models (LLMs) are a type of machine learning model that can be trained on vast amounts of text data to generate human-like language. In recent years, LLMs have made significant advances in a variety of natural language processing tasks, including language translation, text generation, and...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/latex.html
951445e4aad8-0
.ipynb .pdf spaCy spaCy# spaCy is an open-source software library for advanced natural language processing, written in the programming languages Python and Cython. Another alternative to NLTK is to use Spacy tokenizer. How the text is split: by spaCy tokenizer How the chunk size is measured: by number of characters #!p...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/spacy.html
951445e4aad8-1
previous Recursive Character next Tiktoken By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/spacy.html
7bd4d0edb875-0
.ipynb .pdf Tiktoken Tiktoken# tiktoken is a fast BPE tokeniser created by OpenAI. How the text is split: by tiktoken tokens How the chunk size is measured: by tiktoken tokens #!pip install tiktoken # This is a long document we can split up. with open('../../../state_of_the_union.txt') as f: state_of_the_union = f....
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/tiktoken_splitter.html
0895afbe847a-0
.ipynb .pdf Recursive Character Recursive Character# This text splitter is the recommended one for generic text. It is parameterized by a list of characters. It tries to split on them in order until the chunks are small enough. The default list is ["\n\n", "\n", " ", ""]. This has the effect of trying to keep all parag...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/recursive_text_splitter.html
0895afbe847a-1
previous Python Code next spaCy By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/recursive_text_splitter.html
4446b360ac3a-0
.ipynb .pdf Markdown Markdown# Markdown is a lightweight markup language for creating formatted text using a plain-text editor. MarkdownTextSplitter splits text along Markdown headings, code blocks, or horizontal rules. It’s implemented as a simple subclass of RecursiveCharacterSplitter with Markdown-specific separator...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/markdown.html
4446b360ac3a-1
previous LaTeX next NLTK By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/markdown.html
f8106b98d570-0
.ipynb .pdf Character Character# This is the simplest method. This splits based on characters (by default “\n\n”) and measure chunk length by number of characters. How the text is split: by single character How the chunk size is measured: by number of characters # This is a long document we can split up. with open('../...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/character_text_splitter.html
f8106b98d570-1
texts = text_splitter.create_documents([state_of_the_union]) print(texts[0]) 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 to...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/character_text_splitter.html
f8106b98d570-2
print(documents[0]) 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 again. \n\nTonight, we meet as Democrats Republica...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/character_text_splitter.html
f8106b98d570-3
text_splitter.split_text(state_of_the_union)[0] '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 again. \n\nTonight, we meet as Demo...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/character_text_splitter.html
8e972d3ec532-0
.ipynb .pdf Hugging Face tokenizer Hugging Face tokenizer# Hugging Face has many tokenizers. We use Hugging Face tokenizer, the GPT2TokenizerFast to count the text length in tokens. How the text is split: by character passed in How the chunk size is measured: by number of tokens calculated by the Hugging Face tokenizer...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/huggingface_length_function.html
a1a5fb2dbf47-0
.ipynb .pdf NLTK NLTK# The Natural Language Toolkit, or more commonly NLTK, is a suite of libraries and programs for symbolic and statistical natural language processing (NLP) for English written in the Python programming language. Rather than just splitting on “\n\n”, we can use NLTK to split based on NLTK tokenizers....
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/nltk.html
a1a5fb2dbf47-1
Groups of citizens blocking tanks with their bodies. previous Markdown next Python Code By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/nltk.html
f7aa4137e39c-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
f7aa4137e39c-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
f7aa4137e39c-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
83b6fcc0f1ed-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
83b6fcc0f1ed-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
83b6fcc0f1ed-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
83b6fcc0f1ed-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
83b6fcc0f1ed-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
49cdd71d3da4-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
49cdd71d3da4-1
Hide embedded project Explore on atlas.nomic.ai previous Annoy next Chroma By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html
41b2327af5e8-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
41b2327af5e8-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
41b2327af5e8-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
41b2327af5e8-3
And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence. -------------------------------------------------------------------------------- -----------------------------------------------...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html
41b2327af5e8-4
previous OpenSearch next Pinecone Contents Similarity search with score Similarity Search with Euclidean Distance (Default) Working with vectorstore in PG Uploading a vectorstore in PG Retrieving a vectorstore in PG By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html
e367329799ae-0
.ipynb .pdf SKLearnVectorStore Contents Basic usage Load a sample document corpus Create the SKLearnVectorStore, index the document corpus and run a sample query Saving and loading a vector store Clean-up SKLearnVectorStore# scikit-learn is an open source collection of machine learning algorithms, including some impl...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/sklearn.html
e367329799ae-1
import tempfile persist_path = os.path.join(tempfile.gettempdir(), 'union.parquet') vector_store = SKLearnVectorStore.from_documents( documents=docs, embedding=embeddings, persist_path=persist_path, # persist_path and serializer are optional serializer='parquet' ) query = "What did the president say ab...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/sklearn.html
e367329799ae-2
) print('A new instance of vector store was loaded from', persist_path) A new instance of vector store was loaded from /var/folders/6r/wc15p6m13nl_nl_n_xfqpc5c0000gp/T/union.parquet docs = vector_store2.similarity_search(query) print(docs[0].page_content) Tonight. I call on the Senate to: Pass the Freedom to Vote Act. ...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/sklearn.html
e8fd03d1ffc6-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
e8fd03d1ffc6-1
found_docs = vectara.similarity_search(query) print(found_docs[0].page_content) Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/vectara.html
e8fd03d1ffc6-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
14883659923f-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
14883659923f-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
39443394b97d-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
39443394b97d-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
39443394b97d-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
39443394b97d-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
39443394b97d-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
39443394b97d-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
39443394b97d-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
39443394b97d-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
39443394b97d-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
39443394b97d-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
62390c65bd48-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
62390c65bd48-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
62390c65bd48-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
0184d9f8d510-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
0184d9f8d510-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
0184d9f8d510-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
0184d9f8d510-3
matched_docs = vector_store.similarity_search_with_relevance_scores(query) 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\n...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html
0184d9f8d510-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
0184d9f8d510-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
0184d9f8d510-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
b7fc5ffbf479-0
.ipynb .pdf Qdrant Contents Connecting to Qdrant from LangChain Local mode In-memory On-disk storage On-premise server deployment Qdrant Cloud Reusing the same collection Similarity search Similarity search with score Maximum marginal relevance search (MMR) Qdrant as a Retriever Customizing Qdrant Qdrant# Qdrant (rea...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html
b7fc5ffbf479-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
b7fc5ffbf479-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
b7fc5ffbf479-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
b7fc5ffbf479-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
b7fc5ffbf479-5
2. We can’t change how divided we’ve been. But we can change how we move forward—on COVID-19 and other issues we must face together. I recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera. They were responding to a 9-1-1 call when a...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html
b7fc5ffbf479-6
query = "What did the president say about Ketanji Brown Jackson" retriever.get_relevant_documents(query)[0] Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html
b7fc5ffbf479-7
location=":memory:", collection_name="my_documents_2", content_payload_key="my_page_content_key", metadata_payload_key="my_meta", ) <langchain.vectorstores.qdrant.Qdrant at 0x7fc4e2baa230> previous Pinecone next Redis Contents Connecting to Qdrant from LangChain Local mode In-memory On-disk storage On-p...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html
3219a1c100cf-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
3219a1c100cf-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
159c633d2a29-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# Chroma is a database for building AI applications with embeddings. This notebook shows how to use functionality related ...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html
159c633d2a29-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
159c633d2a29-2
The below steps cover how to persist a ChromaDB instance 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 wi...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html
159c633d2a29-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
f0e467a8bf4e-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
f0e467a8bf4e-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
f0e467a8bf4e-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
f0e467a8bf4e-3
text text (42, 1) str None Deep Lake, for now, is single writer and multiple reader. Setting read_only=True helps to avoid acquring the writer lock. Retrieval Question/Answering# from langchain.chains import RetrievalQA from langchain.llms import OpenAIChat qa = RetrievalQA.from_chain_type(llm=Open...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-4
tensor htype shape dtype compression ------- ------- ------- ------- ------- embedding generic (4, 1536) float32 None ids text (4, 1) str None metadata json (4, 1) str None text text (4, 1) str None db.similarity_search...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-5
Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-6
[Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justic...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-7
Document(page_content='A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-8
Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-9
Document(page_content='Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards ...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-10
[Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justic...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-11
Document(page_content='Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards ...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-12
Document(page_content='A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-13
Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-14
username = "<username>" # your username on app.activeloop.ai dataset_path = f"hub://{username}/langchain_test" # could be also ./local/path (much faster locally), s3://bucket/path/to/dataset, gcs://path/to/dataset, etc. embedding = OpenAIEmbeddings() db = DeepLake(dataset_path=dataset_path, embedding_function=embedd...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-15
'd6d6ccb7-e187-11ed-b66d-41c5f7b85421'] query = "What did the president say about Ketanji Brown Jackson" docs = db.similarity_search(query) print(docs[0].page_content) Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so ...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-16
}) s3://hub-2.0-datasets-n/langchain_test loaded successfully. Evaluating ingest: 100%|██████████| 1/1 [00:10<00:00 \ Dataset(path='s3://hub-2.0-datasets-n/langchain_test', tensors=['embedding', 'ids', 'metadata', 'text']) tensor htype shape dtype compression ------- ------- ------- ------- ----...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-17
username = "davitbun" # your username on app.activeloop.ai source = f"hub://{username}/langchain_test" # could be local, s3, gcs, etc. destination = f"hub://{username}/langchain_test_copy" # could be local, s3, gcs, etc. deeplake.deepcopy(src=source, dest=destination, overwrite=True) Copying dataset: 100%|██████████...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
f0e467a8bf4e-18
metadata json (4, 1) str None text text (4, 1) str None Evaluating ingest: 100%|██████████| 1/1 [00:31<00:00 - Dataset(path='hub://davitbun/langchain_test_copy', tensors=['embedding', 'ids', 'metadata', 'text']) tensor htype shape dtype compression ------- -...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html