id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
cbb1c83363ae-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
796cb34d426b-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
796cb34d426b-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
796cb34d426b-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
796cb34d426b-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
796cb34d426b-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
ed7b014cbd40-0
.ipynb .pdf Contextual Compression Contents Contextual Compression Using a vanilla vector store retriever Adding contextual compression with an LLMChainExtractor More built-in compressors: filters LLMChainFilter EmbeddingsFilter Stringing compressors and document transformers together Contextual Compression# This not...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
ed7b014cbd40-1
texts = text_splitter.split_documents(documents) retriever = FAISS.from_documents(texts, OpenAIEmbeddings()).as_retriever() docs = retriever.get_relevant_documents("What did the president say about Ketanji Brown Jackson") pretty_print_docs(docs) Document 1: Tonight. I call on the Senate to: Pass the Freedom to Vote Act...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
ed7b014cbd40-2
We’re securing commitments and supporting partners in South and Central America to host more refugees and secure their own borders. ---------------------------------------------------------------------------------------------------- Document 3: And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
ed7b014cbd40-3
Let’s increase Pell Grants and increase our historic support of HBCUs, and invest in what Jill—our First Lady who teaches full-time—calls America’s best-kept secret: community colleges. Adding contextual compression with an LLMChainExtractor# Now let’s wrap our base retriever with a ContextualCompressionRetriever. We’l...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
ed7b014cbd40-4
More built-in compressors: filters# LLMChainFilter# The LLMChainFilter is slightly simpler but more robust compressor that uses an LLM chain to decide which of the initially retrieved documents to filter out and which ones to return, without manipulating the document contents. from langchain.retrievers.document_compres...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
ed7b014cbd40-5
from langchain.retrievers.document_compressors import EmbeddingsFilter embeddings = OpenAIEmbeddings() embeddings_filter = EmbeddingsFilter(embeddings=embeddings, similarity_threshold=0.76) compression_retriever = ContextualCompressionRetriever(base_compressor=embeddings_filter, base_retriever=retriever) compressed_doc...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
ed7b014cbd40-6
We can do both. At our border, we’ve installed new technology like cutting-edge scanners to better detect drug smuggling. 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 th...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
ed7b014cbd40-7
Below we create a compressor pipeline by first splitting our docs into smaller chunks, then removing redundant documents, and then filtering based on relevance to the query. from langchain.document_transformers import EmbeddingsRedundantFilter from langchain.retrievers.document_compressors import DocumentCompressorPipe...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
ed7b014cbd40-8
previous Cohere Reranker next Databerry Contents Contextual Compression Using a vanilla vector store retriever Adding contextual compression with an LLMChainExtractor More built-in compressors: filters LLMChainFilter EmbeddingsFilter Stringing compressors and document transformers together By Harrison Chase ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
ed22e9ea0f7b-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
ed22e9ea0f7b-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
ed22e9ea0f7b-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
ed22e9ea0f7b-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
ed22e9ea0f7b-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
ed22e9ea0f7b-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
ed22e9ea0f7b-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
ed22e9ea0f7b-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
ed22e9ea0f7b-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 May 29, 2023.
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
394bbc1c0eb6-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
394bbc1c0eb6-1
previous kNN next Pinecone Hybrid Search Contents Ingest Documents Query By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 29, 2023.
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/metal.html
1ae410e34210-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
1ae410e34210-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
1ae410e34210-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
81efea079f4c-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
81efea079f4c-1
previous Text Splitters next Character By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 29, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/getting_started.html
2ee8c3c96b74-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
ac94016997e3-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
2a526e3b2b1f-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
2a526e3b2b1f-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
2a526e3b2b1f-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
a1128c3b4c82-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
a1128c3b4c82-1
previous Recursive Character next Tiktoken By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 29, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/spacy.html
253ee703d713-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
dabaed28c87d-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
dabaed28c87d-1
previous Python Code next spaCy By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 29, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/recursive_text_splitter.html
a103da332e3e-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
a103da332e3e-1
previous LaTeX next NLTK By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 29, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/markdown.html
b311ff97d702-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
b311ff97d702-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
b311ff97d702-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
b311ff97d702-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
e94f92a324e0-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
2319d3c1472f-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
2319d3c1472f-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 29, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/nltk.html
2b8b1378c8e3-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
2b8b1378c8e3-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
2b8b1378c8e3-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
3981c452574e-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
3981c452574e-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
3981c452574e-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
3981c452574e-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
3981c452574e-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
8240b79a20ef-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
8240b79a20ef-1
Hide embedded project Explore on atlas.nomic.ai previous Annoy next Chroma By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 29, 2023.
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html
d69a0a831382-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
d69a0a831382-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
d69a0a831382-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
d69a0a831382-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
d69a0a831382-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 29, 2023...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html
84a889a4c614-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
84a889a4c614-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
84a889a4c614-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
597f04a94746-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
597f04a94746-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
597f04a94746-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
dd96d9715fd0-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
dd96d9715fd0-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
5bc337c75127-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
5bc337c75127-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
5bc337c75127-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
5bc337c75127-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
5bc337c75127-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
5bc337c75127-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
5bc337c75127-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
5bc337c75127-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
5bc337c75127-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
5bc337c75127-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
cda2d8f15657-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
cda2d8f15657-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
cda2d8f15657-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
dc8d36349fb6-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
dc8d36349fb6-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
dc8d36349fb6-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
dc8d36349fb6-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
dc8d36349fb6-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
dc8d36349fb6-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
dc8d36349fb6-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
e45651d29ca9-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
e45651d29ca9-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
e45651d29ca9-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
e45651d29ca9-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
e45651d29ca9-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
e45651d29ca9-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
e45651d29ca9-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