id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
af7149cb26dd-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
3d20810c0eb5-0
.ipynb .pdf LanceDB LanceDB# LanceDB is an open-source database for vector-search built with persistent storage, which greatly simplifies retrevial, filtering and management of embeddings. Fully open source. This notebook shows how to use functionality related to the LanceDB vector database based on the Lance data form...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lancedb.html
3d20810c0eb5-1
I spoke with their families and told them that we are forever in debt for their sacrifice, and we will carry on their mission to restore the trust and safety every community deserves. I’ve worked on these issues a long time. I know what works: Investing in crime preventionand community police officers who’ll walk the...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lancedb.html
3d20810c0eb5-2
These laws don’t infringe on the Second Amendment. They save lives. The most fundamental right in America is the right to vote – and to have it counted. And it’s under assault. In state after state, new laws have been passed, not only to suppress the vote, but to subvert entire elections. We cannot let this happen. ...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lancedb.html
3d20810c0eb5-3
We’ve set up joint patrols with Mexico and Guatemala to catch more human traffickers. We’re putting in place dedicated immigration judges so families fleeing persecution and violence can have their cases heard faster. previous FAISS next MatchingEngine By Harrison Chase © Copyright 2023, Harrison Chase. ...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lancedb.html
d8f072b2b2a3-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
d8f072b2b2a3-1
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 about Ketanji Brow...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/sklearn.html
d8f072b2b2a3-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
d37b069f0fbd-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
d37b069f0fbd-1
previous Text Splitters next Character By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/getting_started.html
5dd940d4791b-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
68132bbe2d9e-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
68132bbe2d9e-1
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 together again. \n\nTonight, we meet as Democrats Republicans a...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/character_text_splitter.html
68132bbe2d9e-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
68132bbe2d9e-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
7a7e0c794cdf-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
7a7e0c794cdf-1
previous Recursive Character next Tiktoken By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/spacy.html
f37275476d02-0
.ipynb .pdf CodeTextSplitter Contents Python JS Markdown Latex HTML CodeTextSplitter# CodeTextSplitter allows you to split your code with multiple language support. Import enum Language and specify the language. from langchain.text_splitter import ( RecursiveCharacterTextSplitter, Language, ) # Full list of s...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/code_splitter.html
f37275476d02-1
helloWorld(); """ js_splitter = RecursiveCharacterTextSplitter.from_language( language=Language.JS, chunk_size=60, chunk_overlap=0 ) js_docs = js_splitter.create_documents([JS_CODE]) js_docs [Document(page_content='function helloWorld() {\n console.log("Hello, World!");\n}', metadata={}), Document(page_content='/...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/code_splitter.html
f37275476d02-2
latex_text = """ \documentclass{article} \begin{document} \maketitle \section{Introduction} Large 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 lan...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/code_splitter.html
f37275476d02-3
Document(page_content='made significant advances in a variety of natural language', metadata={}), Document(page_content='processing tasks, including language translation, text', metadata={}), Document(page_content='generation, and sentiment analysis.', metadata={}), Document(page_content='\\subsection{History of LLM...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/code_splitter.html
f37275476d02-4
color: darkblue; } </style> </head> <body> <div> <h1>🦜️🔗 LangChain</h1> <p>⚡ Building applications with LLMs through composability ⚡</p> </div> <div> As an open source project in a rapidly developing field, we are extremely open t...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/code_splitter.html
f37275476d02-5
Document(page_content='As an open source project in a rapidly', metadata={}), Document(page_content='developing field, we are extremely open to contributions.', metadata={}), Document(page_content='</div>\n </body>\n</html>', metadata={})] previous Character next NLTK Contents Python JS Markdown Latex HTML By ...
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/code_splitter.html
48462f38fd74-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
5eee34143928-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
5eee34143928-1
Groups of citizens blocking tanks with their bodies. previous CodeTextSplitter next Recursive Character By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/nltk.html
3d497d4e2cfa-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
e50487211f68-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
e50487211f68-1
previous NLTK next spaCy By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/recursive_text_splitter.html
d45bf0c52292-0
.ipynb .pdf ChatGPT Plugin Contents Using the ChatGPT Retriever Plugin ChatGPT Plugin# OpenAI plugins connect ChatGPT to third-party applications. These plugins enable ChatGPT to interact with APIs defined by developers, enhancing ChatGPT’s capabilities and allowing it to perform a wide range of actions. Plugins can ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin.html
d45bf0c52292-1
Using the ChatGPT Retriever Plugin# Okay, so we’ve created the ChatGPT Retriever Plugin, but how do we actually use it? The below code walks through how to do that. We want to use ChatGPTPluginRetriever so we have to get the OpenAI API Key. import os import getpass os.environ['OPENAI_API_KEY'] = getpass.getpass('OpenAI...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin.html
d45bf0c52292-2
Document(page_content='Team: Angels "Payroll (millions)": 154.49 "Wins": 89', lookup_str='', metadata={'id': '59c2c0c1-ae3f-4272-a1da-f44a723ea631_0', 'metadata': {'source': None, 'source_id': None, 'url': None, 'created_at': None, 'author': None, 'document_id': '59c2c0c1-ae3f-4272-a1da-f44a723ea631'}, 'embedding': Non...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin.html
71efb01e3d2c-0
.ipynb .pdf Pinecone Hybrid Search Contents Setup Pinecone Get embeddings and sparse encoders Load Retriever Add texts (if necessary) Use Retriever Pinecone Hybrid Search# Pinecone is a vector database with broad functionality. This notebook goes over how to use a retriever that under the hood uses Pinecone and Hybri...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/pinecone_hybrid_search.html
71efb01e3d2c-1
pinecone.init(api_key=api_key, enviroment=env) pinecone.whoami() WhoAmIResponse(username='load', user_label='label', projectname='load-test') # create the index pinecone.create_index( name = index_name, dimension = 1536, # dimensionality of dense model metric = "dotproduct", # sparse values supported only f...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/pinecone_hybrid_search.html
71efb01e3d2c-2
Load Retriever# We can now construct the retriever! retriever = PineconeHybridSearchRetriever(embeddings=embeddings, sparse_encoder=bm25_encoder, index=index) Add texts (if necessary)# We can optionally add texts to the retriever (if they aren’t already in there) retriever.add_texts(["foo", "bar", "world", "hello"]) 10...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/pinecone_hybrid_search.html
9d6b31adff14-0
.ipynb .pdf Vespa Vespa# Vespa is a fully featured search engine and vector database. It supports vector search (ANN), lexical search, and search in structured data, all in the same query. This notebook shows how to use Vespa.ai as a LangChain retriever. In order to create a retriever, we use pyvespa to create a connec...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vespa.html
9d6b31adff14-1
retriever.get_relevant_documents("what is vespa?") previous VectorStore next Weaviate Hybrid Search By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vespa.html
8426a36550df-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
8426a36550df-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
8426a36550df-2
We’ve set up joint patrols with Mexico and Guatemala to catch more human traffickers. We’re putting in place dedicated immigration judges so families fleeing persecution and violence can have their cases heard faster. We’re securing commitments and supporting partners in South and Central America to host more refuge...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
8426a36550df-3
Let’s pass the Paycheck Fairness Act and paid leave. Raise the minimum wage to $15 an hour and extend the Child Tax Credit, so no one has to raise a family in poverty. 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 b...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
8426a36550df-4
---------------------------------------------------------------------------------------------------- Document 2: "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 receive...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
8426a36550df-5
EmbeddingsFilter# Making an extra LLM call over each retrieved document is expensive and slow. The EmbeddingsFilter provides a cheaper and faster option by embedding the documents and query and only returning those documents which have sufficiently similar embeddings to the query. from langchain.embeddings import OpenA...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
8426a36550df-6
---------------------------------------------------------------------------------------------------- Document 2: 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...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
8426a36550df-7
First, beat the opioid epidemic. Stringing compressors and document transformers together# Using the DocumentCompressorPipeline we can also easily combine multiple compressors in sequence. Along with compressors we can add BaseDocumentTransformers to our pipeline, which don’t perform any contextual compression but simp...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
8426a36550df-8
---------------------------------------------------------------------------------------------------- Document 2: As I said last year, especially to our younger transgender Americans, I will always have your back as your President, so you can be yourself and reach your God-given potential. While it often appears that w...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
e82e0605cbc5-0
.ipynb .pdf SVM Contents Create New Retriever with Texts Use Retriever SVM# Support vector machines (SVMs) are a set of supervised learning methods used for classification, regression and outliers detection. This notebook goes over how to use a retriever that under the hood uses an SVM using scikit-learn package. Lar...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/svm.html
c3d8ca1d2cda-0
.ipynb .pdf TF-IDF Contents Create New Retriever with Texts Create a New Retriever with Documents Use Retriever TF-IDF# TF-IDF means term-frequency times inverse document-frequency. This notebook goes over how to use a retriever that under the hood uses TF-IDF using scikit-learn package. For more information on the d...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/tf_idf.html
97a9a5836da4-0
.ipynb .pdf Self-querying with Qdrant Contents Creating a Qdrant vectorstore Creating our self-querying retriever Testing it out Filter k Self-querying with Qdrant# Qdrant (read: quadrant ) is a vector similarity search engine. It provides a production-ready service with a convenient API to store, search, and manage ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html
97a9a5836da4-1
Document(page_content="A psychologist / detective gets lost in a series of dreams within dreams within dreams and Inception reused the idea", metadata={"year": 2006, "director": "Satoshi Kon", "rating": 8.6}), Document(page_content="A bunch of normal-sized women are supremely wholesome and some men pine after them"...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html
97a9a5836da4-2
type="integer", ), AttributeInfo( name="director", description="The name of the movie director", type="string", ), AttributeInfo( name="rating", description="A 1-10 rating for the movie", type="float" ), ] document_content_description = "Brief summa...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html
97a9a5836da4-3
query=' ' filter=Comparison(comparator=<Comparator.GT: 'gt'>, attribute='rating', value=8.5) limit=None [Document(page_content='Three men walk into the Zone, three men walk out of the Zone', metadata={'year': 1979, 'rating': 9.9, 'director': 'Andrei Tarkovsky', 'genre': 'science fiction'}), Document(page_content='A ps...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html
97a9a5836da4-4
[Document(page_content='Three men walk into the Zone, three men walk out of the Zone', metadata={'year': 1979, 'rating': 9.9, 'director': 'Andrei Tarkovsky', 'genre': 'science fiction'})] # This example specifies a query and composite filter retriever.get_relevant_documents("What's a movie after 1990 but before 2005 th...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html
97a9a5836da4-5
Document(page_content='Toys come alive and have a blast doing so', metadata={'year': 1995, 'genre': 'animated'})] previous Pinecone Hybrid Search next Self-querying Contents Creating a Qdrant vectorstore Creating our self-querying retriever Testing it out Filter k By Harrison Chase © Copyright 2023, Harr...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/qdrant_self_query.html
a17616639ebd-0
.ipynb .pdf VectorStore Contents Maximum Marginal Relevance Retrieval Similarity Score Threshold Retrieval Specifying top k VectorStore# The index - and therefore the retriever - that LangChain has the most support for is the VectorStoreRetriever. As the name suggests, this retriever is backed heavily by a VectorStor...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vectorstore.html
a17616639ebd-1
docs = retriever.get_relevant_documents("what did he say abotu ketanji brown jackson") Specifying top k# You can also specify search kwargs like k to use when doing retrieval. retriever = db.as_retriever(search_kwargs={"k": 1}) docs = retriever.get_relevant_documents("what did he say abotu ketanji brown jackson") len(d...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vectorstore.html
497b3d93f1e7-0
.ipynb .pdf Zep Memory Contents Retriever Example Initialize the Zep Chat Message History Class and add a chat message history to the memory store Use the Zep Retriever to vector search over the Zep memory Zep Memory# Retriever Example# This notebook demonstrates how to search historical chat message histories using ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
497b3d93f1e7-1
session_id = str(uuid4()) # This is a unique identifier for the user/session # Set up Zep Chat History. We'll use this to add chat histories to the memory store zep_chat_history = ZepChatMessageHistory( session_id=session_id, url=ZEP_API_URL, ) # Preload some messages into the memory. The default message windo...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
497b3d93f1e7-2
" Fellowship." ), }, { "role": "human", "content": "Which other women sci-fi writers might I want to read?", }, { "role": "ai", "content": "You might want to read Ursula K. Le Guin or Joanna Russ.", }, { "role": "human", "content": ( ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
497b3d93f1e7-3
url=ZEP_API_URL, top_k=5, ) await zep_retriever.aget_relevant_documents("Who wrote Parable of the Sower?") [Document(page_content='Who was Octavia Butler?', metadata={'score': 0.7759001673780126, 'uuid': '3a82a02f-056e-4c6a-b960-67ebdf3b2b93', 'created_at': '2023-05-25T15:03:30.2041Z', 'role': 'human', 'token_count...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
497b3d93f1e7-4
Document(page_content='Octavia Estelle Butler (June 22, 1947 – February 24, 2006) was an American science fiction author.', metadata={'score': 0.7546211059317948, 'uuid': '34678311-0098-4f1a-8fd4-5615ac692deb', 'created_at': '2023-05-25T15:03:30.231427Z', 'role': 'ai', 'token_count': 31}), Document(page_content='Which...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
497b3d93f1e7-5
Document(page_content="Write a short synopsis of Butler's book, Parable of the Sower. What is it about?", metadata={'score': 0.8857628682610436, 'uuid': 'f6706e8c-6c91-452f-8c1b-9559fd924657', 'created_at': '2023-05-25T15:03:30.265302Z', 'role': 'human', 'token_count': 23}), Document(page_content='Who was Octavia Butl...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
497b3d93f1e7-6
Document(page_content='You might want to read Ursula K. Le Guin or Joanna Russ.', metadata={'score': 0.7595293992240313, 'uuid': 'f22f2498-6118-4c74-8718-aa89ccd7e3d6', 'created_at': '2023-05-25T15:03:30.261198Z', 'role': 'ai', 'token_count': 18})] previous Wikipedia next Chains Contents Retriever Example Initializ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
23b99c2ceefa-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
23b99c2ceefa-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
23b99c2ceefa-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
e6df33fa9f7a-0
.ipynb .pdf Azure Cognitive Search Retriever Contents Set up Azure Cognitive Search Using the Azure Cognitive Search Retriever Azure Cognitive Search Retriever# This notebook shows how to use Azure Cognitive Search (ACS) within LangChain. Set up Azure Cognitive Search# To set up ACS, please follow the instrcutions he...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/azure-cognitive-search-retriever.html
237e8a3fd5b0-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
237e8a3fd5b0-1
previous kNN next Pinecone Hybrid Search Contents Ingest Documents Query By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/metal.html
b918f8934731-0
.ipynb .pdf Databerry Contents Query Databerry# Databerry platform brings data from anywhere (Datsources: Text, PDF, Word, PowerPpoint, Excel, Notion, Airtable, Google Sheets, etc..) into Datastores (container of multiple Datasources). Then your Datastores can be connected to ChatGPT via Plugins or any other Large La...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/databerry.html
b918f8934731-1
) retriever.get_relevant_documents("What is Daftpage?") [Document(page_content='✨ Made with DaftpageOpen main menuPricingTemplatesLoginSearchHelpGetting StartedFeaturesAffiliate ProgramGetting StartedDaftpage is a new type of website builder that works like a doc.It makes website building easy, fun and offers tons of p...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/databerry.html
b918f8934731-2
Document(page_content="✨ Made with DaftpageOpen main menuPricingTemplatesLoginSearchHelpGetting StartedFeaturesAffiliate ProgramHelp CenterWelcome to Daftpage’s help center—the one-stop shop for learning everything about building websites with Daftpage.Daftpage is the simplest way to create websites for all purposes in...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/databerry.html
b918f8934731-3
Document(page_content=" is the simplest way to create websites for all purposes in seconds. Without knowing how to code, and for free!Get StartedDaftpage is a new type of website builder that works like a doc.It makes website building easy, fun and offers tons of powerful features for free. Just type / in your page to ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/databerry.html
e5f8fc12f635-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
e5f8fc12f635-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
e5f8fc12f635-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
e5f8fc12f635-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
e5f8fc12f635-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
e9d2830392d1-0
.ipynb .pdf Self-querying with Weaviate Contents Creating a Weaviate vectorstore Creating our self-querying retriever Testing it out Filter k Self-querying with Weaviate# Creating a Weaviate vectorstore# First we’ll want to create a Weaviate VectorStore and seed it with some data. We’ve created a small demo set of do...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html
e9d2830392d1-1
Document(page_content="Toys come alive and have a blast doing so", metadata={"year": 1995, "genre": "animated"}), Document(page_content="Three men walk into the Zone, three men walk out of the Zone", metadata={"year": 1979, "rating": 9.9, "director": "Andrei Tarkovsky", "genre": "science fiction", "rating": 9.9}) ]...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html
e9d2830392d1-2
llm = OpenAI(temperature=0) retriever = SelfQueryRetriever.from_llm(llm, vectorstore, document_content_description, metadata_field_info, verbose=True) Testing it out# And now we can try actually using our retriever! # This example only specifies a relevant query retriever.get_relevant_documents("What are some movies ab...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html
e9d2830392d1-3
We can do this by passing enable_limit=True to the constructor. retriever = SelfQueryRetriever.from_llm( llm, vectorstore, document_content_description, metadata_field_info, enable_limit=True, verbose=True ) # This example only specifies a relevant query retriever.get_relevant_documents("wha...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html
d70d254758ea-0
.ipynb .pdf Self-querying Contents Creating a Pinecone index Creating our self-querying retriever Testing it out Filter k Self-querying# In the notebook we’ll demo the SelfQueryRetriever, which, as the name suggests, has the ability to query itself. Specifically, given any natural language query, the retriever uses a...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query.html
d70d254758ea-1
from langchain.schema import Document from langchain.embeddings.openai import OpenAIEmbeddings from langchain.vectorstores import Pinecone embeddings = OpenAIEmbeddings() # create new index pinecone.create_index("langchain-self-retriever-demo", dimension=1536) docs = [ Document(page_content="A bunch of scientists b...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query.html
d70d254758ea-2
) Creating our self-querying retriever# Now we can instantiate our retriever. To do this we’ll need to provide some information upfront about the metadata fields that our documents support and a short description of the document contents. from langchain.llms import OpenAI from langchain.retrievers.self_query.base impor...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query.html