id stringlengths 14 16 | text stringlengths 29 2.73k | source stringlengths 49 115 |
|---|---|---|
bf7630d360cd-0 | .ipynb
.pdf
YouTube
Contents
Add video info
YouTube loader from Google Cloud
Prerequisites
🧑 Instructions for ingesting your Google Docs data
YouTube#
How to load documents from YouTube transcripts.
from langchain.document_loaders import YoutubeLoader
# !pip install youtube-transcript-api
loader = YoutubeLoader.from... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/youtube.html |
bf7630d360cd-1 | # Use a Channel
youtube_loader_channel = GoogleApiYoutubeLoader(google_api_client=google_api_client, channel_name="Reducible",captions_language="en")
# Use Youtube Ids
youtube_loader_ids = GoogleApiYoutubeLoader(google_api_client=google_api_client, video_ids=["TrdevFK_am4"], add_video_info=True)
# returns a list of Doc... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/youtube.html |
d9f6d97abcad-0 | .ipynb
.pdf
Image captions
Contents
Prepare a list of image urls from Wikimedia
Create the loader
Create the index
Query
Image captions#
This notebook shows how to use the ImageCaptionLoader tutorial to generate a query-able index of image captions
from langchain.document_loaders import ImageCaptionLoader
Prepare a l... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/image_captions.html |
d9f6d97abcad-1 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/2022-01-22_Men%27s_World_Cup_at_2021-22_St._Moritz%E2%80%93Celerina_Luge_World_Cup_and_European_Championships_by_Sandro_Halank%E2%80%93257.jpg/288px-2022-01-22_Men%27s_World_Cup_at_2021-22_St._Moritz%E2%80%93Celerina_Luge_World_Cup_and_European_Championships_by... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/image_captions.html |
d9f6d97abcad-2 | Document(page_content='an image of a shark swimming in the ocean [SEP]', metadata={'image_path': 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Tibur%C3%B3n_azul_%28Prionace_glauca%29%2C_canal_Fayal-Pico%2C_islas_Azores%2C_Portugal%2C_2020-07-27%2C_DD_14.jpg/270px-Tibur%C3%B3n_azul_%28Prionace_glauca%29%2C_... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/image_captions.html |
d9f6d97abcad-3 | Document(page_content='an image of a man on skis in the snow [SEP]', metadata={'image_path': 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/2022-01-22_Men%27s_World_Cup_at_2021-22_St._Moritz%E2%80%93Celerina_Luge_World_Cup_and_European_Championships_by_Sandro_Halank%E2%80%93257.jpg/288px-2022-01-22_Men%27s_... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/image_captions.html |
d9f6d97abcad-4 | from .autonotebook import tqdm as notebook_tqdm
/Users/saitosean/dev/langchain/.venv/lib/python3.10/site-packages/transformers/generation/utils.py:1313: UserWarning: Using `max_length`'s default (20) to control the generation length. This behaviour is deprecated and will be removed from the config in v5 of Transformers... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/image_captions.html |
29a7b59a834d-0 | .ipynb
.pdf
Sitemap Loader
Contents
Filtering sitemap URLs
Sitemap Loader#
Extends from the WebBaseLoader, this will load a sitemap from a given URL, and then scrape and load all the pages in the sitemap, returning each page as a document.
The scraping is done concurrently, using WebBaseLoader. There are reasonable ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-1 | Document(page_content='\n\n\n\n\n\nWelcome to LangChain — 🦜🔗 LangChain 0.0.123\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSkip to main content\n\n\n\n\n\n\n\n\n\n\nCtrl+K\n\n\n\n\n\n\n\n\n\n\n\n\n🦜🔗 LangChain 0.0.123\n\n\n\nGetting Started\n\nQuickstart Guide\n\nMod... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-2 | OpenAI\nSageMakerEndpoint\nSelf-Hosted Models via Runhouse\nStochasticAI\nWriter\n\n\nAsync API for LLM\nStreaming with LLMs\n\n\nReference\n\n\nDocument Loaders\nKey Concepts\nHow To Guides\nCoNLL-U\nAirbyte JSON\nAZLyrics\nBlackboard\nCollege Confidential\nCopy Paste\nCSV Loader\nDirectory Loader\nEmail\nEverNote\nFa... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-3 | Document Embeddings\nText Splitter\nVectorStores\nAtlasDB\nChroma\nDeep Lake\nElasticSearch\nFAISS\nMilvus\nOpenSearch\nPGVector\nPinecone\nQdrant\nRedis\nWeaviate\nChatGPT Plugin Retriever\nVectorStore Retriever\nAnalyze Document\nChat Index\nGraph QA\nQuestion Answering with Sources\nQuestion Answering\nSummarization... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-4 | Agent\nJSON Agent\nOpenAPI Agent\nPandas Dataframe Agent\nPython Agent\nSQL Database Agent\nVectorstore Agent\nMRKL\nMRKL Chat\nReAct\nSelf Ask With Search\n\n\nReference\n\n\nMemory\nGetting Started\nKey Concepts\nHow-To Guides\nConversationBufferMemory\nConversationBufferWindowMemory\nEntity Memory\nConversation Know... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-5 | Generation\nQuestion Answering\nSQL Question Answering Benchmarking: Chinook\n\n\nModel Comparison\n\nReference\n\nInstallation\nIntegrations\nAPI References\nPrompts\nPromptTemplates\nExample Selector\n\n\nUtilities\nPython REPL\nSerpAPI\nSearxNG Search\nDocstore\nText Splitter\nEmbeddings\nVectorStores\n\n\nChains\nA... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-6 | Started\nModules\nUse Cases\nReference Docs\nLangChain Ecosystem\nAdditional Resources\n\n\n\n\n\n\n\n\nWelcome to LangChain#\nLarge language models (LLMs) are emerging as a transformative technology, enabling\ndevelopers to build applications that they previously could not.\nBut using these LLMs in isolation is often ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-7 | support for.\nFor each module we provide some examples to get started, how-to guides, reference docs, and conceptual guides.\nThese modules are, in increasing order of complexity:\n\nPrompts: This includes prompt management, prompt optimization, and prompt serialization.\nLLMs: This includes a generic interface for all... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-8 | models are often more powerful when combined with your own text data - this module covers best practices for doing exactly that.\nAgents: Agents involve an LLM making decisions about which Actions to take, taking that Action, seeing an Observation, and repeating that until done. LangChain provides a standard interface ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-9 | the common use cases LangChain supports.\n\nAgents: Agents are systems that use a language model to interact with other tools. These can be used to do more grounded question/answering, interact with APIs, or even take actions.\nChatbots: Since language models are good at producing text, that makes them ideal for creati... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-10 | SQL, dataframes, etc) you should read this page.\nEvaluation: Generative models are notoriously hard to evaluate with traditional metrics. One new way of evaluating them is using language models themselves to do the evaluation. LangChain provides some prompts/chains for assisting in this.\nGenerate similar examples: Ge... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-11 | application!\n\nLangChainHub: The LangChainHub is a place to share and explore other prompts, chains, and agents.\nGlossary: A glossary of all related terms, papers, methods, etc. Whether implemented in LangChain or not!\nGallery: A collection of our favorite projects that use LangChain. Useful for finding inspiration ... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-12 | Harrison Chase\n\n\n\n\n \n © Copyright 2023, Harrison Chase.\n \n\n\n\n\n Last updated on Mar 24, 2023.\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', lookup_str='', metadata={'source': 'https://python.langchain.com/en/stable/', 'loc': 'https://python.langchain.com/en/stable/', 'lastmod': '2023-03-24T19:30:54.647... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-13 | Filtering sitemap URLs#
Sitemaps can be massive files, with thousands of urls. Often you don’t need every single one of them. You can filter the urls by passing a list of strings or regex patterns to the url_filter parameter. Only urls that match one of the patterns will be loaded.
loader = SitemapLoader(
"https... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-14 | Document(page_content='\n\n\n\n\n\nWelcome to LangChain — 🦜🔗 LangChain 0.0.123\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSkip to main content\n\n\n\n\n\n\n\n\n\n\nCtrl+K\n\n\n\n\n\n\n\n\n\n\n\n\n🦜🔗 LangChain 0.0.123\n\n\n\nGetting Started\n\nQuickstart Guide\n\nMod... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-15 | Models\nGetting Started\nHow-To Guides\nHow to use few shot examples\nHow to stream responses\n\n\nIntegrations\nAzure\nOpenAI\nPromptLayer ChatOpenAI\n\n\n\n\nText Embedding Models\nAzureOpenAI\nCohere\nFake Embeddings\nHugging Face Hub\nInstructEmbeddings\nOpenAI\nSageMaker Endpoint Embeddings\nSelf Hosted Embeddings... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-16 | File Storage\nGitBook\nGoogle Drive\nGutenberg\nHacker News\nHTML\niFixit\nImages\nIMSDb\nMarkdown\nNotebook\nNotion\nObsidian\nPDF\nPowerPoint\nReadTheDocs Documentation\nRoam\ns3 Directory\ns3 File\nSubtitle Files\nTelegram\nUnstructured File Loader\nURL\nWeb Base\nWord Documents\nYouTube\n\n\nText Splitters\nGetting... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-17 | Memory class\nHow to use multiple memroy classes in the same chain\n\n\n\n\nChains\nGetting Started\nHow-To Guides\nAsync API for Chain\nLoading from LangChainHub\nLLM Chain\nSequential Chains\nSerialization\nTransformation Chain\nAnalyze Document\nChat Index\nGraph QA\nHypothetical Document Embeddings\nQuestion Answer... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-18 | Dataframe Agent\nPython Agent\nSQL Database Agent\nVectorstore Agent\n\n\nAgent Executors\nHow to combine agents and vectorstores\nHow to use the async API for Agents\nHow to create ChatGPT Clone\nHow to access intermediate steps\nHow to cap the max number of iterations\nHow to add SharedMemory to an Agent and its Tool... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-19 | Lake\nForefrontAI\nGoogle Search Wrapper\nGoogle Serper Wrapper\nGooseAI\nGraphsignal\nHazy Research\nHelicone\nHugging Face\nMilvus\nModal\nNLPCloud\nOpenAI\nOpenSearch\nPetals\nPGVector\nPinecone\nPromptLayer\nQdrant\nRunhouse\nSearxNG Search API\nSerpAPI\nStochasticAI\nUnstructured\nWeights & Biases\nWeaviate\nWolfr... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-20 | data\nBe agentic: allow a language model to interact with its environment\n\nThe LangChain framework is designed with the above principles in mind.\nThis is the Python specific portion of the documentation. For a purely conceptual guide to LangChain, see here. For the JavaScript documentation, see here.\n\nGetting Star... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-21 | that use memory.\nIndexes: Language models are often more powerful when combined with your own text data - this module covers best practices for doing exactly that.\nChains: Chains go beyond just a single LLM call, and are sequences of calls (whether to an LLM or a different utility). LangChain provides a standard inte... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-22 | have knowledge about your data.\nQuestion Answering: The second big LangChain use case. Answering questions over specific documents, only utilizing the information in those documents to construct an answer.\nChatbots: Since language models are good at producing text, that makes them ideal for creating chatbots.\nQueryi... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-23 | assisting in this.\n\n\n\n\n\nReference Docs#\nAll of LangChain’s reference documentation, in one place. Full documentation on all methods, classes, installation methods, and integration setups for LangChain.\n\nReference Documentation\n\n\n\n\n\nLangChain Ecosystem#\nGuides for how other companies/products can be used... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-24 | prompts, models, and chains is a big part of developing the best possible application. The ModelLaboratory makes it easy to do so.\nDiscord: Join us on our Discord to discuss all things LangChain!\nProduction Support: As you move your LangChains into production, we’d love to offer more comprehensive support. Please fil... | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
29a7b59a834d-25 | previous
s3 File
next
Slack (Local Exported Zipfile)
Contents
Filtering sitemap URLs
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/sitemap.html |
31540dd3a059-0 | .ipynb
.pdf
Contextual Compression Retriever
Contents
Contextual Compression Retriever
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 C... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html |
31540dd3a059-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 |
31540dd3a059-2 | We’re securing commitments and supporting partners in South and Central America to host more refugees and secure their own borders.
----------------------------------------------------------------------------------------------------
Document 3:
And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html |
31540dd3a059-3 | Let’s increase Pell Grants and increase our historic support of HBCUs, and invest in what Jill—our First Lady who teaches full-time—calls America’s best-kept secret: community colleges.
Adding contextual compression with an LLMChainExtractor#
Now let’s wrap our base retriever with a ContextualCompressionRetriever. We’l... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html |
31540dd3a059-4 | More built-in compressors: filters#
LLMChainFilter#
The LLMChainFilter is slightly simpler but more robust compressor that uses an LLM chain to decide which of the initially retrieved documents to filter out and which ones to return, without manipulating the document contents.
from langchain.retrievers.document_compres... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html |
31540dd3a059-5 | from langchain.retrievers.document_compressors import EmbeddingsFilter
embeddings = OpenAIEmbeddings()
embeddings_filter = EmbeddingsFilter(embeddings=embeddings, similarity_threshold=0.76)
compression_retriever = ContextualCompressionRetriever(base_compressor=embeddings_filter, base_retriever=retriever)
compressed_doc... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html |
31540dd3a059-6 | We can do both. At our border, we’ve installed new technology like cutting-edge scanners to better detect drug smuggling.
We’ve set up joint patrols with Mexico and Guatemala to catch more human traffickers.
We’re putting in place dedicated immigration judges so families fleeing persecution and violence can have th... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html |
31540dd3a059-7 | Below we create a compressor pipeline by first splitting our docs into smaller chunks, then removing redundant documents, and then filtering based on relevance to the query.
from langchain.document_transformers import EmbeddingsRedundantFilter
from langchain.retrievers.document_compressors import DocumentCompressorPipe... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html |
31540dd3a059-8 | previous
Cohere Reranker
next
Databerry
Contents
Contextual Compression Retriever
Using a vanilla vector store retriever
Adding contextual compression with an LLMChainExtractor
More built-in compressors: filters
LLMChainFilter
EmbeddingsFilter
Stringing compressors and document transformers together
By Harrison Cha... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html |
77ae097f2f74-0 | .ipynb
.pdf
SVM Retriever
Contents
Create New Retriever with Texts
Use Retriever
SVM Retriever#
This notebook goes over how to use a retriever that under the hood uses an SVM using scikit-learn.
Largely based on https://github.com/karpathy/randomfun/blob/master/knn_vs_svm.ipynb
from langchain.retrievers import SVMRet... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/svm_retriever.html |
ee0fa9e9a02f-0 | .ipynb
.pdf
Metal
Contents
Ingest Documents
Query
Metal#
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 = ""
INDEX_ID = ""
metal = Metal(API_KEY, CLIENT... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/metal.html |
ee0fa9e9a02f-1 | previous
ElasticSearch BM25
next
Pinecone Hybrid Search
Contents
Ingest Documents
Query
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/metal.html |
a980bb23bc7c-0 | .ipynb
.pdf
TF-IDF Retriever
Contents
Create New Retriever with Texts
Use Retriever
TF-IDF Retriever#
This notebook goes over how to use a retriever that under the hood uses TF-IDF using scikit-learn.
For more information on the details of TF-IDF see this blog post.
from langchain.retrievers import TFIDFRetriever
# !... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/tf_idf_retriever.html |
f25514acf053-0 | .ipynb
.pdf
VectorStore Retriever
VectorStore Retriever#
The index - and therefore the retriever - that LangChain has the most support for is a VectorStoreRetriever. As the name suggests, this retriever is backed heavily by a VectorStore.
Once you construct a VectorStore, its very easy to construct a retriever. Let’s w... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vectorstore-retriever.html |
f25514acf053-1 | next
Vespa retriever
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vectorstore-retriever.html |
08aa56a8e82b-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#
This notebook goes over how to use a retriever that under the hood uses Pinecone and Hybrid Search.
The logic of this retriever is taken from this... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/pinecone_hybrid_search.html |
08aa56a8e82b-1 | index = pinecone.Index(index_name)
Get embeddings and sparse encoders#
Embeddings are used for the dense vectors, tokenizer is used for the sparse vector
from langchain.embeddings import OpenAIEmbeddings
embeddings = OpenAIEmbeddings()
To encode the text to sparse values you can either choose SPLADE or BM25. For out of... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/pinecone_hybrid_search.html |
08aa56a8e82b-2 | Use Retriever#
We can now use the retriever!
result = retriever.get_relevant_documents("foo")
result[0]
Document(page_content='foo', metadata={})
previous
Metal
next
Self-querying retriever
Contents
Setup Pinecone
Get embeddings and sparse encoders
Load Retriever
Add texts (if necessary)
Use Retriever
By Harrison C... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/pinecone_hybrid_search.html |
e48b082edeb0-0 | .ipynb
.pdf
ElasticSearch BM25
Contents
Create New Retriever
Add texts (if necessary)
Use Retriever
ElasticSearch BM25#
This notebook goes over how to use a retriever that under the hood uses ElasticSearcha and BM25.
For more information on the details of BM25 see this blog post.
from langchain.retrievers import Elas... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/elastic_search_bm25.html |
e48b082edeb0-1 | result = retriever.get_relevant_documents("foo")
result
[Document(page_content='foo', metadata={}),
Document(page_content='foo bar', metadata={})]
previous
Databerry
next
Metal
Contents
Create New Retriever
Add texts (if necessary)
Use Retriever
By Harrison Chase
© Copyright 2023, Harrison Chase.
... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/elastic_search_bm25.html |
fe23f8c4a908-0 | .ipynb
.pdf
Weaviate Hybrid Search
Weaviate Hybrid Search#
This notebook shows how to use Weaviate hybrid search as a LangChain retriever.
import weaviate
import os
WEAVIATE_URL = "..."
client = weaviate.Client(
url=WEAVIATE_URL,
)
from langchain.retrievers.weaviate_hybrid_search import WeaviateHybridSearchRetrieve... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html |
ded8ba2f2406-0 | .ipynb
.pdf
ChatGPT Plugin Retriever
Contents
Create
Using the ChatGPT Retriever Plugin
ChatGPT Plugin Retriever#
This notebook shows how to use the ChatGPT Retriever Plugin within LangChain.
Create#
First, let’s go over how to create the ChatGPT Retriever Plugin.
To set up the ChatGPT Retriever Plugin, please follow... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin-retriever.html |
ded8ba2f2406-1 | The below code walks through how to do that.
from langchain.retrievers import ChatGPTPluginRetriever
retriever = ChatGPTPluginRetriever(url="http://0.0.0.0:8000", bearer_token="foo")
retriever.get_relevant_documents("alice's phone number")
[Document(page_content="This is Alice's phone number: 123-456-7890", lookup_str=... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin-retriever.html |
ded8ba2f2406-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-retriever.html |
3fc01435b3b6-0 | .ipynb
.pdf
Vespa retriever
Vespa retriever#
This notebook shows how to use Vespa.ai as a LangChain retriever.
Vespa.ai is a platform for highly efficient structured text and vector search.
Please refer to Vespa.ai for more information.
In order to create a retriever, we use pyvespa to
create a connection a Vespa servi... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vespa_retriever.html |
3fc01435b3b6-1 | previous
VectorStore Retriever
next
Weaviate Hybrid Search
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vespa_retriever.html |
8419110b4109-0 | .ipynb
.pdf
Self-querying retriever
Contents
Self-querying retriever
Creating a Pinecone index
Creating our self-querying retriever
Testing it out
Self-querying retriever#
In the notebook we’ll demo the SelfQueryRetriever, which, as the name suggests, has the ability to query itself. Specifically, given any natural l... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query_retriever.html |
8419110b4109-1 | 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 bring back dinosaurs and mayhem breaks loose", metadata={"year": 1993, "rating": 7.7, "genre": [... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query_retriever.html |
8419110b4109-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_retriever.html |
8419110b4109-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_retriever.html |
8419110b4109-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_retriever.html |
8419110b4109-5 | next
SVM Retriever
Contents
Self-querying retriever
Creating a Pinecone index
Creating our self-querying retriever
Testing it out
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query_retriever.html |
27b31922af88-0 | .ipynb
.pdf
Time Weighted VectorStore Retriever
Contents
Low Decay Rate
High Decay Rate
Time Weighted VectorStore Retriever#
This retriever uses a combination of semantic similarity and recency.
The algorithm for scoring them is:
semantic_similarity + (1.0 - decay_rate) ** hours_passed
Notably, hours_passed refers to... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/time_weighted_vectorstore.html |
27b31922af88-1 | retriever.add_documents([Document(page_content="hello foo")])
['5c9f7c06-c9eb-45f2-aea5-efce5fb9f2bd']
# "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 |
27b31922af88-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 |
8741fe087010-0 | .ipynb
.pdf
Cohere Reranker
Contents
Set up the base vector store retriever
Doing reranking with CohereRerank
Cohere Reranker#
This notebook shows how to use Cohere’s rerank endpoint in a retriever. This builds on top of ideas in the ContextualCompressionRetriever.
# Helper function for printing docs
def pretty_print... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
8741fe087010-1 | 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:
As I said last ... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
8741fe087010-2 | I’ve worked on these issues a long time.
I know what works: Investing in crime preventionand community police officers who’ll walk the beat, who’ll know the neighborhood, and who can restore trust and safety.
So let’s not abandon our streets. Or choose between safety and equal justice.
-------------------------------... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
8741fe087010-3 | ----------------------------------------------------------------------------------------------------
Document 9:
All told, we created 369,000 new manufacturing jobs in America just last year.
Powered by people I’ve met like JoJo Burgess, from generations of union steelworkers from Pittsburgh, who’s here with us tonigh... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
8741fe087010-4 | Tonight, we meet as Democrats Republicans and Independents. But most importantly as Americans.
With a duty to one another to the American people to the Constitution.
And with an unwavering resolve that freedom will always triumph over tyranny.
--------------------------------------------------------------------------... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
8741fe087010-5 | Our troops in Iraq and Afghanistan faced many dangers.
----------------------------------------------------------------------------------------------------
Document 16:
When we invest in our workers, when we build the economy from the bottom up and the middle out together, we can do something we haven’t done in a long ... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
8741fe087010-6 | Because people were hurting. We needed to act, and we did.
Few pieces of legislation have done more in a critical moment in our history to lift us out of crisis.
----------------------------------------------------------------------------------------------------
Document 20:
So let’s not abandon our streets. Or choose... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
8741fe087010-7 | ----------------------------------------------------------------------------------------------------
Document 2:
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 i... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
8741fe087010-8 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html |
784dee4a6c94-0 | .ipynb
.pdf
Databerry
Contents
Query
Databerry#
This notebook shows how to use Databerry’s retriever.
First, you will need to sign up for Databerry, create a datastore, add some data and get your datastore api endpoint url
Query#
Now that our index is set up, we can set up a retriever and start querying it.
from lang... | https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/databerry.html |
784dee4a6c94-1 | 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 |
784dee4a6c94-2 | 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 |
c990ff52495b-0 | .ipynb
.pdf
Getting Started
Contents
Add texts
From Documents
Getting Started#
This notebook showcases basic functionality related to VectorStores. A key part of working with vectorstores is creating the vector to put in them, which is usually created via embeddings. Therefore, it is recommended that you familiarize ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/getting_started.html |
c990ff52495b-1 | One of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court.
And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/getting_started.html |
c990ff52495b-2 | We cannot let this happen.
Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections.
Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justi... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/getting_started.html |
dc3a5e8cd57e-0 | .ipynb
.pdf
Pinecone
Pinecone#
Pinecone is a vector database with broad functionality.
This notebook shows how to use functionality related to the Pinecone vector database.
To use Pinecone, you must have an API key.
Here are the installation instructions.
!pip install pinecone-client
import os
import getpass
PINECONE_A... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pinecone.html |
dc3a5e8cd57e-1 | docs = docsearch.similarity_search(query)
print(docs[0].page_content)
previous
PGVector
next
Qdrant
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pinecone.html |
99f80014dda4-0 | .ipynb
.pdf
AtlasDB
AtlasDB#
This notebook shows you how to use functionality related to the AtlasDB.
MongoDB‘s Atlas is an on-demand fully managed service. MongoDB Atlas runs on AWS, Microsoft Azure, and Google Cloud Platform.
!pip install spacy
!python3 -m spacy download en_core_web_sm
!pip install nomic
import time
... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html |
99f80014dda4-1 | Hide embedded project
Explore on atlas.nomic.ai
previous
Annoy
next
Chroma
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html |
4f7b265e5a1b-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/lanecdb.html |
4f7b265e5a1b-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/lanecdb.html |
4f7b265e5a1b-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/lanecdb.html |
4f7b265e5a1b-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
Milvus
By Harrison Chase
© Copyright 2023, Harrison Chase.
L... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lanecdb.html |
b0a437962262-0 | .ipynb
.pdf
SupabaseVectorStore
Contents
Similarity search with score
Retriever options
Maximal Marginal Relevance Searches
SupabaseVectorStore#
Supabase is an open source Firebase alternative.
This notebook shows how to use Supabase and pgvector as your VectorStore.
To run this notebook, please ensure:
the pgvector ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
b0a437962262-1 | $$;
# with pip
!pip install supabase
# with conda
# !conda install -c conda-forge supabase
We want to use OpenAIEmbeddings so we have to get the OpenAI API Key.
import os
import getpass
os.environ['OPENAI_API_KEY'] = getpass.getpass('OpenAI API Key:')
os.environ['SUPABASE_URL'] = getpass.getpass('Supabase URL:')
os.env... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
b0a437962262-2 | docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
# We're using the default `documents` table here. You can modify this by passing in a `table_name` argument to the `from_documents` method.
vector_store = SupabaseVectorStore.from_documents(
docs, embeddings, client=supabase
)
query = "... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
b0a437962262-3 | matched_docs = vector_store.similarity_search_with_relevance_scores(query)
matched_docs[0]
(Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\n... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
b0a437962262-4 | Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service.
One of the most serious constitutional responsibilities a President h... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
b0a437962262-5 | ## Document 2
And I’m taking robust action to make sure the pain of our sanctions is targeted at Russia’s economy. And I will use every tool at our disposal to protect American businesses and consumers.
Tonight, I can announce that the United States has worked with 30 other countries to release 60 Million barrels of ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
b0a437962262-6 | I’ve worked on these issues a long time.
I know what works: Investing in crime preventionand community police officers who’ll walk the beat, who’ll know the neighborhood, and who can restore trust and safety.
previous
Redis
next
Tair
Contents
Similarity search with score
Retriever options
Maximal Marginal Relevanc... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html |
b7324fa37a68-0 | .ipynb
.pdf
FAISS
Contents
Similarity Search with score
Saving and loading
Merging
FAISS#
Facebook AI Similarity Search (Faiss) is a library for efficient similarity search and clustering of dense vectors. It contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM. I... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
b7324fa37a68-1 | Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service.
One of the most serious constitutional responsibilities a President h... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.