id stringlengths 14 16 | text stringlengths 36 2.73k | source stringlengths 49 117 |
|---|---|---|
d7bac2a60dbd-4 | - [Gallery](https://python.langchain.com/en/latest/additional_resources/gallery.html): A collection of our favorite projects that use LangChain. Useful for finding inspiration or seeing how things were done in other applications.
- [Deployments](https://python.langchain.com/en/latest/additional_resources/deployments.ht... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/tomarkdown.html |
79280504db46-0 | .ipynb
.pdf
Jupyter Notebook
Jupyter Notebook#
Jupyter Notebook (formerly IPython Notebook) is a web-based interactive computational environment for creating notebook documents.
This notebook covers how to load data from a Jupyter notebook (.ipynb) into a format suitable by LangChain.
from langchain.document_loaders im... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/jupyter_notebook.html |
79280504db46-1 | traceback (bool): whether to include full traceback (default is False).
loader.load()
[Document(page_content='\'markdown\' cell: \'[\'# Notebook\', \'\', \'This notebook covers how to load data from an .ipynb notebook into a format suitable by LangChain.\']\'\n\n \'code\' cell: \'[\'from langchain.document_loaders impo... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/jupyter_notebook.html |
2ba962768247-0 | .ipynb
.pdf
OpenAIWhisperParser
OpenAIWhisperParser#
This notebook goes over how to load data from an audio file, such as an mp3.
We use the OpenAIWhisperParser, which will use the OpenAI Whisper API to transcribe audio to text.
Note: You will need to have an OPENAI_API_KEY supplied.
from langchain.document_loaders.gen... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-1 | [Document(page_content="Hello, my name is Andrej and I've been training deep neural networks for a bit more than a decade. And in this lecture I'd like to show you what neural network training looks like under the hood. So in particular we are going to start with a blank Jupyter notebook and by the end of this lecture ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-2 | and you'll see that a and b are negative four and two but we are wrapping those values into this value object that we are going to build out as part of micrograd. So this value object will wrap the numbers themselves and then we are going to build out a mathematical expression here where a and b are transformed into c ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-3 | going to evaluate basically the derivative of g with respect to all the internal nodes like e, d, and c but also with respect to the inputs a and b. And then we can actually query this derivative of g with respect to a, for example that's a.grad, in this case it happens to be 138, and the derivative of g with respect t... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-4 | machinery for training of neural networks. Now one more note I would like to make at this stage is that as you see here micrograd is a scalar valued autograd engine so it's working on the you know level of individual scalars like negative 4 and 2 and we're taking neural nets and we're breaking them down all the way to ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-5 | So if we just go to micrograd and you'll see that there's only two files here in micrograd. This is the actual engine, it doesn't know anything about neural nets and this is the entire neural nets library on top of micrograd. So engine and nn.py. So the actual back propagation autograd engine that gives you the power o... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-6 | can tell from the mathematical expression that this is probably a parabola, it's a quadratic and so if we just create a set of scalar values that we can feed in using for example a range from negative 5 to 5 in steps of 0.25. So this is so x is just from negative 5 to 5 not including 5 in steps of 0.25 and we can actua... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-7 | really understand what the derivative is measuring, what it's telling you about the function. And so if we just look up derivative we see that okay so this is not a very good definition of derivative. This is a definition of what it means to be differentiable but if you remember from your calculus it is the limit as h ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-8 | we have to normalize by the run so we have the rise over run to get the slope so this of course is just a numerical approximation of the slope because we have to make h very very small to converge to the exact amount now if i'm doing too many zeros at some point i'm going to i'm going to get an incorrect answer because... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-9 | going to start you know complexifying a bit so now we have a function here with output variable d that is a function of three scalar inputs a b and c so a b and c are some specific values three inputs into our expression graph and a single output d and so if we just print d we get four and now what i like to do is i'd ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-10 | uh printed out here in particular d1 will be four will d2 be a number slightly greater than four or slightly lower than four and that's going to tell us the sign of the derivative so we're bumping a by h b is minus three c is 10 so you can just intuitively think through this derivative and what it's doing a will be sli... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-11 | working well and then if c gets bumped a tiny amount in h by h then of course a times b is unaffected and now c becomes slightly bit higher what does that do to the function it makes it slightly bit higher because we're simply adding c and it makes it slightly bit higher by the exact same amount that we added to c and ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
2ba962768247-12 | previous
Airtable
next
CoNLL-U
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/audio.html |
138364f3fabc-0 | .ipynb
.pdf
Unstructured File
Contents
Retain Elements
Define a Partitioning Strategy
PDF Example
Unstructured API
Unstructured File#
This notebook covers how to use Unstructured package to load files of many types. Unstructured currently supports loading of text files, powerpoints, html, pdfs, images, and more.
# # ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html |
138364f3fabc-1 | docs = loader.load()
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.', lookup_str='', metadata={'source': '../../state_of_the_union.txt'}, lookup_index=0),
Document(page_c... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html |
138364f3fabc-2 | from langchain.document_loaders import UnstructuredFileLoader
loader = UnstructuredFileLoader("layout-parser-paper-fast.pdf", strategy="fast", mode="elements")
docs = loader.load()
docs[:5]
[Document(page_content='1', lookup_str='', metadata={'source': 'layout-parser-paper-fast.pdf', 'filename': 'layout-parser-paper-fa... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html |
138364f3fabc-3 | docs = loader.load()
docs[:5]
[Document(page_content='LayoutParser : A Unified Toolkit for Deep Learning Based Document Image Analysis', lookup_str='', metadata={'source': '../../layout-parser-paper.pdf'}, lookup_index=0),
Document(page_content='Zejiang Shen 1 ( (ea)\n ), Ruochen Zhang 2 , Melissa Dell 3 , Benjamin Cha... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html |
138364f3fabc-4 | loader = UnstructuredAPIFileLoader(
file_path=filenames[0],
api_key="FAKE_API_KEY",
)
docs = loader.load()
docs[0]
Document(page_content='Lorem ipsum dolor sit amet.', metadata={'source': 'example_data/fake.docx'})
You can also batch multiple files through the Unstructured API in a single API using Unstructured... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html |
da658218a0ce-0 | .ipynb
.pdf
WhatsApp Chat
WhatsApp Chat#
WhatsApp (also called WhatsApp Messenger) is a freeware, cross-platform, centralized instant messaging (IM) and voice-over-IP (VoIP) service. It allows users to send text and voice messages, make voice and video calls, and share images, documents, user locations, and other conte... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/whatsapp_chat.html |
3de0ead61219-0 | .ipynb
.pdf
Telegram
Telegram#
Telegram Messenger is a globally accessible freemium, cross-platform, encrypted, cloud-based and centralized instant messaging service. The application also provides optional end-to-end encrypted chats and video calling, VoIP, file sharing and several other features.
This notebook covers ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/telegram.html |
4c53e9105228-0 | .ipynb
.pdf
Arxiv
Contents
Installation
Examples
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 science, and economics.
This notebook shows how t... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/arxiv.html |
4c53e9105228-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/document_loaders/examples/arxiv.html |
882ec2509c30-0 | .ipynb
.pdf
Trello
Contents
Features
Trello#
Trello is a web-based project management and collaboration tool that allows individuals and teams to organize and track their tasks and projects. It provides a visual interface known as a “board” where users can create lists and cards to represent their tasks and activitie... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/trello.html |
882ec2509c30-1 | from getpass import getpass
API_KEY = getpass()
TOKEN = getpass()
········
········
from langchain.document_loaders import TrelloLoader
# Get the open cards from "Awesome Board"
loader = TrelloLoader.from_credentials(
"Awesome Board",
api_key=API_KEY,
token=TOKEN,
card_filter="open",
)
documents = l... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/trello.html |
882ec2509c30-2 | loader = TrelloLoader.from_credentials(
"test",
api_key=API_KEY,
token=TOKEN,
include_card_name= False,
include_checklist= False,
include_comments= False,
)
documents = loader.load()
print("Document: " + documents[0].page_content)
print(documents[0].metadata)
Contents
Features
By Harrison Ch... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/trello.html |
f4c8407a149b-0 | .ipynb
.pdf
Microsoft Excel
Microsoft Excel#
The UnstructuredExcelLoader is used to load Microsoft Excel files. The loader works with both .xlsx and .xls files. The page content will be the raw text of the Excel file. If you use the loader in "elements" mode, an HTML representation of the Excel file will be available i... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/excel.html |
f4c8407a149b-1 | mode="elements"
)
docs = loader.load()
docs[0]
Document(page_content='\n \n \n Team\n Location\n Stanley Cups\n \n \n Blues\n STL\n 1\n \n \n Flyers\n PHI\n 2\n \n \n Maple Leafs\n TOR\n 13\n \n \n', metadata={'source': 'example_data/... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/excel.html |
b42eea8c12d6-0 | .ipynb
.pdf
Microsoft PowerPoint
Contents
Retain Elements
Microsoft PowerPoint#
Microsoft PowerPoint is a presentation program by Microsoft.
This covers how to load Microsoft PowerPoint documents into a document format that we can use downstream.
from langchain.document_loaders import UnstructuredPowerPointLoader
loa... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/microsoft_powerpoint.html |
fc717c0565f5-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 |
fc717c0565f5-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 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/text_splitters/getting_started.html |
ddead15725ed-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 |
bb0ed53381be-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 |
1f296b407e44-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 |
1f296b407e44-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 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/nltk.html |
e5b2c36f394e-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 |
e5b2c36f394e-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 |
e5b2c36f394e-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 |
e5b2c36f394e-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 |
75f162d065b1-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 |
8017eeb4dbd1-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 |
8017eeb4dbd1-1 | previous
Recursive Character
next
Tiktoken
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/spacy.html |
2ad46927ed10-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 |
2ad46927ed10-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 |
2ad46927ed10-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 |
2ad46927ed10-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 |
2ad46927ed10-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 |
2ad46927ed10-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 |
19367f03b39c-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 |
19367f03b39c-1 | previous
NLTK
next
spaCy
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 11, 2023. | https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/recursive_text_splitter.html |
988884a574d1-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html |
988884a574d1-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html |
988884a574d1-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html |
988884a574d1-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html |
988884a574d1-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html |
988884a574d1-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html |
01bc45200067-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 |
01bc45200067-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 |
01bc45200067-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 |
01bc45200067-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query.html |
01bc45200067-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query.html |
01bc45200067-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query.html |
ac246f227c88-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 |
ac246f227c88-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 |
d52edacd440a-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 |
d52edacd440a-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 |
d52edacd440a-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 |
d52edacd440a-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 |
d52edacd440a-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 |
d52edacd440a-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 |
d52edacd440a-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 |
d52edacd440a-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 |
d52edacd440a-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 |
543779df7dd9-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.... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/elastic_search_bm25.html |
543779df7dd9-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/elastic_search_bm25.html |
df6a4725e1f4-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 |
df6a4725e1f4-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 |
df6a4725e1f4-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 |
bce31c051c51-0 | .ipynb
.pdf
Wikipedia
Contents
Installation
Examples
Running retriever
Question Answering on facts
Wikipedia#
Wikipedia is a multilingual free online encyclopedia written and maintained by a community of volunteers, known as Wikipedians, through open collaboration and using a wiki-based editing system called MediaWik... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html |
bce31c051c51-1 | 'summary': 'Hunter × Hunter (stylized as HUNTER×HUNTER and pronounced "hunter hunter") is a Japanese manga series written and illustrated by Yoshihiro Togashi. It has been serialized in Shueisha\'s shōnen manga magazine Weekly Shōnen Jump since March 1998, although the manga has frequently gone on extended hiatuses sin... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html |
bce31c051c51-2 | with the first series having aired on the Funimation Channel in 2009 and the second series broadcast on Adult Swim\'s Toonami programming block from April 2016 to June 2019.\nHunter × Hunter has been a huge critical and financial success and has become one of the best-selling manga series of all time, having over 84 mi... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html |
bce31c051c51-3 | docs[0].page_content[:400] # a content of the Document
'Hunter × Hunter (stylized as HUNTER×HUNTER and pronounced "hunter hunter") is a Japanese manga series written and illustrated by Yoshihiro Togashi. It has been serialized in Shueisha\'s shōnen manga magazine Weekly Shōnen Jump since March 1998, although the mang... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html |
bce31c051c51-4 | -> **Question**: What is Apify?
**Answer**: Apify is a platform that allows you to easily automate web scraping, data extraction and web automation. It provides a cloud-based infrastructure for running web crawlers and other automation tasks, as well as a web-based tool for building and managing your crawlers. Additio... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html |
e90baab6ce7d-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 |
e90baab6ce7d-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 |
e90baab6ce7d-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 |
e90baab6ce7d-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 |
c54e50d36f0e-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 |
c54e50d36f0e-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 |
c54e50d36f0e-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 |
1452b0547a90-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.
... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/knn.html |
0ee80f4e216a-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html |
0ee80f4e216a-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html |
0ee80f4e216a-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",
... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html |
0ee80f4e216a-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_... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html |
0ee80f4e216a-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html |
0ee80f4e216a-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html |
0ee80f4e216a-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... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.