id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
59
127
2b0042d6f350-13
[Document(page_content='Team: Nationals\n"Payroll (millions)": 81.34\n"Wins": 98', lookup_str='', metadata={'source': 'Nationals', 'row': 0}, lookup_index=0), Document(page_content='Team: Reds\n"Payroll (millions)": 82.20\n"Wins": 97', lookup_str='', metadata={'source': 'Reds', 'row': 1}, lookup_index=0), Document(page...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/document_loaders/examples/csv.html
2b0042d6f350-14
7}, lookup_index=0), Document(page_content='Team: Rays\n"Payroll (millions)": 64.17\n"Wins": 90', lookup_str='', metadata={'source': 'Rays', 'row': 8}, lookup_index=0), Document(page_content='Team: Angels\n"Payroll (millions)": 154.49\n"Wins": 89', lookup_str='', metadata={'source': 'Angels', 'row': 9}, lookup_index=0)...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/document_loaders/examples/csv.html
2b0042d6f350-15
'row': 15}, lookup_index=0), Document(page_content='Team: Diamondbacks\n"Payroll (millions)": 74.28\n"Wins": 81', lookup_str='', metadata={'source': 'Diamondbacks', 'row': 16}, lookup_index=0), Document(page_content='Team: Pirates\n"Payroll (millions)": 63.43\n"Wins": 79', lookup_str='', metadata={'source': 'Pirates', ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/document_loaders/examples/csv.html
2b0042d6f350-16
metadata={'source': 'Marlins', 'row': 23}, lookup_index=0), Document(page_content='Team: Red Sox\n"Payroll (millions)": 173.18\n"Wins": 69', lookup_str='', metadata={'source': 'Red Sox', 'row': 24}, lookup_index=0), Document(page_content='Team: Indians\n"Payroll (millions)": 78.43\n"Wins": 68', lookup_str='', metadata=...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/document_loaders/examples/csv.html
2b0042d6f350-17
UnstructuredCSVLoader# You can also load the table using the UnstructuredCSVLoader. One advantage of using UnstructuredCSVLoader is that if you use it in "elements" mode, an HTML representation of the table will be available in the metadata. from langchain.document_loaders.csv_loader import UnstructuredCSVLoader loader...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/document_loaders/examples/csv.html
2b0042d6f350-18
<td>120.51</td> <td>93</td> </tr> <tr> <td>Orioles</td> <td>81.43</td> <td>93</td> </tr> <tr> <td>Rays</td> <td>64.17</td> <td>90</td> </tr> <tr> <td>Angels</td> <td>154.49</td> <td>89</td> </tr> <tr> <td>Tigers</td> ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/document_loaders/examples/csv.html
2b0042d6f350-19
</tr> <tr> <td>Diamondbacks</td> <td>74.28</td> <td>81</td> </tr> <tr> <td>Pirates</td> <td>63.43</td> <td>79</td> </tr> <tr> <td>Padres</td> <td>55.24</td> <td>76</td> </tr> <tr> <td>Mariners</td> <td>81.97</td> <td>75<...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/document_loaders/examples/csv.html
2b0042d6f350-20
<td>78.43</td> <td>68</td> </tr> <tr> <td>Twins</td> <td>94.08</td> <td>66</td> </tr> <tr> <td>Rockies</td> <td>78.06</td> <td>64</td> </tr> <tr> <td>Cubs</td> <td>88.19</td> <td>61</td> </tr> <tr> <td>Astros</td> <t...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/document_loaders/examples/csv.html
0adfb2e97933-0
.ipynb .pdf Gutenberg Gutenberg# Project Gutenberg is an online library of free eBooks. This notebook covers how to load links to Gutenberg e-books into a document format that we can use downstream. from langchain.document_loaders import GutenbergLoader loader = GutenbergLoader('https://www.gutenberg.org/cache/epub/699...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/document_loaders/examples/gutenberg.html
c3caf977f19c-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/getting_started.html
c3caf977f19c-1
page_content='of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans.' metadata={'start_index': 82} previous Text Splitters next Character By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/getting_started.html
44526870d883-0
.ipynb .pdf CodeTextSplitter Contents Python JS Solidity 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 ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/code_splitter.html
44526870d883-1
} // Call the function 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={}), D...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/code_splitter.html
44526870d883-2
language=Language.MARKDOWN, chunk_size=60, chunk_overlap=0 ) md_docs = md_splitter.create_documents([markdown_text]) md_docs [Document(page_content='# 🦜️🔗 LangChain', metadata={}), Document(page_content='⚡ Building applications with LLMs through composability ⚡', metadata={}), Document(page_content='## Quick Instal...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/code_splitter.html
44526870d883-3
\subsection{Applications of LLMs} LLMs have many applications in industry, including chatbots, content creation, and virtual assistants. They can also be used in academia for research in linguistics, psychology, and computational linguistics. \end{document} """ latex_splitter = RecursiveCharacterTextSplitter.from_langu...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/code_splitter.html
44526870d883-4
Document(page_content='datasets, leading to significant improvements in', metadata={}), Document(page_content='performance.', metadata={}), Document(page_content='\\subsection{Applications of LLMs}', metadata={}), Document(page_content='LLMs have many applications in industry, including', metadata={}), Document(pag...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/code_splitter.html
44526870d883-5
Document(page_content='<title>🦜️🔗 LangChain</title>\n <style>', metadata={}), Document(page_content='body {', metadata={}), Document(page_content='font-family: Arial, sans-serif;', metadata={}), Document(page_content='}\n h1 {', metadata={}), Document(page_content='color: darkblue;\n ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/code_splitter.html
de368ca32158-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/spacy.html
de368ca32158-1
previous Recursive Character next Tiktoken By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/spacy.html
663fb253628f-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....
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/tiktoken_splitter.html
785ac476db93-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/huggingface_length_function.html
17aca0b5d2a3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/recursive_text_splitter.html
17aca0b5d2a3-1
previous NLTK next spaCy By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/recursive_text_splitter.html
a040b66c6ffb-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/tiktoken.html
ee7c634c6fbd-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....
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/nltk.html
ee7c634c6fbd-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 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/nltk.html
d7922252429a-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('../...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/character_text_splitter.html
d7922252429a-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/character_text_splitter.html
d7922252429a-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/character_text_splitter.html
d7922252429a-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/text_splitters/examples/character_text_splitter.html
a16d2d34b47f-0
.ipynb .pdf ElasticSearch BM25 Contents Create New Retriever Add texts (if necessary) Use Retriever ElasticSearch BM25# Elasticsearch is a distributed, RESTful search and analytics engine. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents....
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/elastic_search_bm25.html
a16d2d34b47f-1
# import elasticsearch # elasticsearch_url="http://localhost:9200" # retriever = ElasticSearchBM25Retriever(elasticsearch.Elasticsearch(elasticsearch_url), "langchain-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", "worl...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/elastic_search_bm25.html
fec7d90c114b-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/time_weighted_vectorstore.html
fec7d90c114b-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/time_weighted_vectorstore.html
fec7d90c114b-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})]...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/time_weighted_vectorstore.html
b7a9c4399cc4-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/cohere-reranker.html
b7a9c4399cc4-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/cohere-reranker.html
b7a9c4399cc4-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....
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/cohere-reranker.html
b7a9c4399cc4-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/cohere-reranker.html
b7a9c4399cc4-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/cohere-reranker.html
b7a9c4399cc4-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/cohere-reranker.html
b7a9c4399cc4-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/cohere-reranker.html
b7a9c4399cc4-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/cohere-reranker.html
b7a9c4399cc4-8
previous Self-querying with Chroma next Contextual Compression Contents Set up the base vector store retriever Doing reranking with CohereRerank By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/cohere-reranker.html
fd71ef51b801-0
.ipynb .pdf PubMed Retriever PubMed Retriever# This notebook goes over how to use PubMed as a retriever PubMed® comprises more than 35 million citations for biomedical literature from MEDLINE, life science journals, and online books. Citations may include links to full text content from PubMed Central and publisher web...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/pubmed.html
fd71ef51b801-1
previous Pinecone Hybrid Search next Self-querying with Qdrant By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/pubmed.html
58a9730fb62e-0
.ipynb .pdf AWS Kendra Contents Using the AWS Kendra Index Retriever AWS Kendra# AWS Kendra is an intelligent search service provided by Amazon Web Services (AWS). It utilizes advanced natural language processing (NLP) and machine learning algorithms to enable powerful search capabilities across various data sources ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/aws_kendra_index_retriever.html
2b8d91c15960-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/svm.html
6fdfbdafed2d-0
.ipynb .pdf kNN Contents Create New Retriever with Texts Use Retriever kNN# In statistics, the k-nearest neighbors algorithm (k-NN) is a non-parametric supervised learning method first developed by Evelyn Fix and Joseph Hodges in 1951, and later expanded by Thomas Cover. It is used for classification and regression. ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/knn.html
7ebc8806f552-0
.ipynb .pdf Azure Cognitive Search Contents Set up Azure Cognitive Search Using the Azure Cognitive Search Retriever Azure Cognitive Search# Azure Cognitive Search (formerly known as Azure Search) is a cloud search service that gives developers infrastructure, APIs, and tools for building a rich search experience ove...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/azure_cognitive_search.html
7ebc8806f552-1
os.environ["AZURE_COGNITIVE_SEARCH_API_KEY"] = "<YOUR_API_KEY>" Create the Retriever retriever = AzureCognitiveSearchRetriever(content_key="content") Now you can use retrieve documents from Azure Cognitive Search retriever.get_relevant_documents("what is langchain") previous AWS Kendra next ChatGPT Plugin Contents ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/azure_cognitive_search.html
8910a72533a0-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/tf_idf.html
9221c2b71a88-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/vespa.html
9221c2b71a88-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 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/vespa.html
440a546753af-0
.ipynb .pdf Zep 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# Zep - A long-term memory store for LLM applications. More on Zep: Zep stores, summarizes, embeds, indexes, and enr...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/zep_memorystore.html
440a546753af-1
Initialize the Zep Chat Message History Class and add a chat message history to the memory store# NOTE: Unlike other Retrievers, the content returned by the Zep Retriever is session/user specific. A session_id is required when instantiating the Retriever. session_id = str(uuid4()) # This is a unique identifier for the...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/zep_memorystore.html
440a546753af-2
" Delany, and Joanna Russ." ), }, {"role": "human", "content": "What awards did she win?"}, { "role": "ai", "content": ( "Octavia Butler won the Hugo Award, the Nebula Award, and the MacArthur" " Fellowship." ), }, { "role": "human", ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/zep_memorystore.html
440a546753af-3
Zep provides native vector search over historical conversation memory. Embedding happens automatically. NOTE: Embedding of messages occurs asynchronously, so the first query may not return results. Subsequent queries will return results as the embeddings are generated. from langchain.retrievers import ZepRetriever zep_...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/zep_memorystore.html
440a546753af-4
Document(page_content='Who were her contemporaries?', metadata={'score': 0.757553366415519, 'uuid': '41f9c41a-a205-41e1-b48b-a0a4cd943fc8', 'created_at': '2023-05-25T15:03:30.243995Z', 'role': 'human', 'token_count': 8}), Document(page_content='Octavia Estelle Butler (June 22, 1947 – February 24, 2006) was an American...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/zep_memorystore.html
440a546753af-5
[Document(page_content='Parable of the Sower is a science fiction novel by Octavia Butler, published in 1993. It follows the story of Lauren Olamina, a young woman living in a dystopian future where society has collapsed due to environmental disasters, poverty, and violence.', metadata={'score': 0.8897321402776546, 'uu...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/zep_memorystore.html
440a546753af-6
Document(page_content="Octavia Butler's contemporaries included Ursula K. Le Guin, Samuel R. Delany, and Joanna Russ.", metadata={'score': 0.7602854653476563, 'uuid': 'a2fc9c21-0897-46c8-bef7-6f5c0f71b04a', 'created_at': '2023-05-25T15:03:30.248065Z', 'role': 'ai', 'token_count': 27}), Document(page_content='You might...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/zep_memorystore.html
15c22005e0bd-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 ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/qdrant_self_query.html
15c22005e0bd-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"...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/qdrant_self_query.html
15c22005e0bd-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/qdrant_self_query.html
15c22005e0bd-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/qdrant_self_query.html
15c22005e0bd-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/qdrant_self_query.html
15c22005e0bd-5
Document(page_content='Toys come alive and have a blast doing so', metadata={'year': 1995, 'genre': 'animated'})] previous PubMed Retriever next Self-querying Contents Creating a Qdrant vectorstore Creating our self-querying retriever Testing it out Filter k By Harrison Chase © Copyright 2023, Harrison C...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/qdrant_self_query.html
7751380b00c9-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 ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/chatgpt-plugin.html
7751380b00c9-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/chatgpt-plugin.html
7751380b00c9-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/chatgpt-plugin.html
989b78f99164-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/contextual-compression.html
989b78f99164-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/contextual-compression.html
989b78f99164-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/contextual-compression.html
989b78f99164-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/contextual-compression.html
989b78f99164-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/contextual-compression.html
989b78f99164-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/contextual-compression.html
989b78f99164-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/contextual-compression.html
989b78f99164-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/contextual-compression.html
989b78f99164-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/contextual-compression.html
d7797d46d7af-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/pinecone_hybrid_search.html
d7797d46d7af-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/pinecone_hybrid_search.html
d7797d46d7af-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/pinecone_hybrid_search.html
214c45ef31c4-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/vectorstore.html
214c45ef31c4-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/vectorstore.html
a9607cc3ce89-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/self_query.html
a9607cc3ce89-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/self_query.html
a9607cc3ce89-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/self_query.html
a9607cc3ce89-3
Document(page_content='Toys come alive and have a blast doing so', metadata={'genre': 'animated', 'year': 1995.0}), Document(page_content='A psychologist / detective gets lost in a series of dreams within dreams within dreams and Inception reused the idea', metadata={'director': 'Satoshi Kon', 'rating': 8.6, 'year': 2...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/self_query.html
a9607cc3ce89-4
[Document(page_content='A bunch of normal-sized women are supremely wholesome and some men pine after them', metadata={'director': 'Greta Gerwig', 'rating': 8.3, 'year': 2019.0})] # This example specifies a composite filter retriever.get_relevant_documents("What's a highly rated (above 8.5) science fiction film?") quer...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/self_query.html
a9607cc3ce89-5
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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/self_query.html
21705101c034-0
.ipynb .pdf Self-querying with Chroma Contents Creating a Chroma vectorstore Creating our self-querying retriever Testing it out Filter k Self-querying with Chroma# Chroma is a database for building AI applications with embeddings. In the notebook we’ll demo the SelfQueryRetriever wrapped around a Chroma vector store...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/chroma_self_query.html
21705101c034-1
Document(page_content="A bunch of normal-sized women are supremely wholesome and some men pine after them", metadata={"year": 2019, "director": "Greta Gerwig", "rating": 8.3}), Document(page_content="Toys come alive and have a blast doing so", metadata={"year": 1995, "genre": "animated"}), Document(page_content...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/chroma_self_query.html
21705101c034-2
type="float" ), ] document_content_description = "Brief summary of a movie" 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 spec...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/chroma_self_query.html
21705101c034-3
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 a filter retriever.get_relevant_documents("Has Greta Gerwig directed any movies about women") qu...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/chroma_self_query.html
21705101c034-4
query='toys' filter=Operation(operator=<Operator.AND: 'and'>, arguments=[Comparison(comparator=<Comparator.GT: 'gt'>, attribute='year', value=1990), Comparison(comparator=<Comparator.LT: 'lt'>, attribute='year', value=2005), Comparison(comparator=<Comparator.EQ: 'eq'>, attribute='genre', value='animated')]) [Document(p...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/chroma_self_query.html
21705101c034-5
Document(page_content='Leo DiCaprio gets lost in a dream within a dream within a dream within a ...', metadata={'year': 2010, 'director': 'Christopher Nolan', 'rating': 8.2})] previous ChatGPT Plugin next Cohere Reranker Contents Creating a Chroma vectorstore Creating our self-querying retriever Testing it out Filt...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/chroma_self_query.html
127fa9812842-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/arxiv.html
127fa9812842-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/arxiv.html
127fa9812842-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/arxiv.html
127fa9812842-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/retrievers/examples/arxiv.html