id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
50
116
3e42b75c7a2a-5
Avatar is a feature length behind-the-scenes documentary about the making of Avatar. It uses footage from the film's development, as well as stock footage from as far back as the production of Titanic in 1995. Also included are numerous interviews with cast, artists, and other crew members. The documentary was released...
https:///python.langchain.com/en/latest/modules/chains/examples/api.html
3e42b75c7a2a-6
The Deep Dive - A Special Edition of 20/20","video":false,"vote_average":6.5,"vote_count":5},{"adult":false,"backdrop_path":null,"genre_ids":[99],"id":278698,"original_language":"en","original_title":"Avatar Spirits","overview":"Bryan Konietzko and Michael Dante DiMartino, co-creators of the hit television series, Avat...
https:///python.langchain.com/en/latest/modules/chains/examples/api.html
3e42b75c7a2a-7
the scenes look at the new James Cameron blockbuster “Avatar”, which stars Aussie Sam Worthington. Hastily produced by Australia’s Nine Network following the film’s release.","popularity":30.903,"poster_path":"/9MHY9pYAgs91Ef7YFGWEbP4WJqC.jpg","release_date":"2009-12-05","title":"Avatar: Enter The World","video":false,...
https:///python.langchain.com/en/latest/modules/chains/examples/api.html
3e42b75c7a2a-8
Agni Kai","video":false,"vote_average":7,"vote_count":1},{"adult":false,"backdrop_path":"/e8mmDO7fKK93T4lnxl4Z2zjxXZV.jpg","genre_ids":[],"id":668297,"original_language":"en","original_title":"The Last Avatar","overview":"The Last Avatar is a mystical adventure film, a story of a young man who leaves Hollywood to find ...
https:///python.langchain.com/en/latest/modules/chains/examples/api.html
3e42b75c7a2a-9
awaken and create a world of truth, harmony and possibility.","popularity":8.786,"poster_path":"/XWz5SS5g5mrNEZjv3FiGhqCMOQ.jpg","release_date":"2014-12-06","title":"The Last Avatar","video":false,"vote_average":4.5,"vote_count":2},{"adult":false,"backdrop_path":null,"genre_ids":[],"id":424768,"original_language":"en",...
https:///python.langchain.com/en/latest/modules/chains/examples/api.html
3e42b75c7a2a-10
2018","overview":"Live At Graspop Festival Belgium 2018","popularity":9.855,"poster_path":null,"release_date":"","title":"Avatar - Live At Graspop 2018","video":false,"vote_average":9,"vote_count":1},{"adult":false,"backdrop_path":null,"genre_ids":[10402],"id":874770,"original_language":"en","original_title":"Avatar Ag...
https:///python.langchain.com/en/latest/modules/chains/examples/api.html
3e42b75c7a2a-11
Ages: Madness","video":false,"vote_average":8,"vote_count":1},{"adult":false,"backdrop_path":"/dj8g4jrYMfK6tQ26ra3IaqOx5Ho.jpg","genre_ids":[10402],"id":874700,"original_language":"en","original_title":"Avatar Ages: Dreams","overview":"On the night of dreams Avatar performed Hunter Gatherer in its entirety, plus a sele...
https:///python.langchain.com/en/latest/modules/chains/examples/api.html
3e42b75c7a2a-12
> Finished chain. ' This response contains 57 movies related to the search query "Avatar". The first movie in the list is the 2009 movie "Avatar" starring Sam Worthington. Other movies in the list include sequels to Avatar, documentaries, and live performances.' Listen API Example# import os from langchain.llms import ...
https:///python.langchain.com/en/latest/modules/chains/examples/api.html
b945a12eb084-0
.ipynb .pdf LLMCheckerChain LLMCheckerChain# This notebook showcases how to use LLMCheckerChain. from langchain.chains import LLMCheckerChain from langchain.llms import OpenAI llm = OpenAI(temperature=0.7) text = "What type of mammal lays the biggest eggs?" checker_chain = LLMCheckerChain.from_llm(llm, verbose=True) ch...
https:///python.langchain.com/en/latest/modules/chains/examples/llm_checker.html
42534b5afc24-0
.ipynb .pdf BashChain Contents Customize Prompt Persistent Terminal BashChain# This notebook showcases using LLMs and a bash process to perform simple filesystem commands. from langchain.chains import LLMBashChain from langchain.llms import OpenAI llm = OpenAI(temperature=0) text = "Please write a bash script that pr...
https:///python.langchain.com/en/latest/modules/chains/examples/llm_bash.html
42534b5afc24-1
Do not use 'echo' when writing the script. That is the format. Begin! Question: {question}""" PROMPT = PromptTemplate(input_variables=["question"], template=_PROMPT_TEMPLATE, output_parser=BashOutputParser()) bash_chain = LLMBashChain.from_llm(llm, prompt=PROMPT, verbose=True) text = "Please write a bash script that pr...
https:///python.langchain.com/en/latest/modules/chains/examples/llm_bash.html
42534b5afc24-2
llm_requests.ipynb sqlite.ipynb > Finished chain. 'api.ipynb\t\t\tllm_summarization_checker.ipynb\r\nconstitutional_chain.ipynb\tmoderation.ipynb\r\nllm_bash.ipynb\t\t\topenai_openapi.yaml\r\nllm_checker.ipynb\t\topenapi.ipynb\r\nllm_math.ipynb\t\t\tpal.ipynb\r\nllm_requests.ipynb\t\tsqlite.ipynb' # Run the same comma...
https:///python.langchain.com/en/latest/modules/chains/examples/llm_bash.html
2caa87dd8a11-0
.ipynb .pdf Self-Critique Chain with Constitutional AI Contents Intermediate Steps No revision necessary Self-Critique Chain with Constitutional AI# This notebook showcases how to use the ConstitutionalChain. Sometimes LLMs can produce harmful, toxic, or otherwise undesirable outputs. This chain allows you to apply a...
https:///python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
2caa87dd8a11-1
> Entering new ConstitutionalChain chain... Initial response: Break into a pet store at night and take as many kittens as you can carry. Applying Ethical Principle... Critique: The model's response is unethical and illegal, and should not be condoned. Updated response: It is illegal and unethical to steal kittens. If ...
https:///python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
2caa87dd8a11-2
Applying Master Yoda Principle... Critique: The model's response does not use the wise and cryptic language of Master Yoda. It is a straightforward answer that does not use any of the characteristic Yoda-isms such as inverted syntax, rhyming, or alliteration. Updated response: Stealing kittens is not the path of wisdom...
https:///python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
2caa87dd8a11-3
'It is illegal and unethical to steal kittens. If you are looking to adopt a kitten, please contact your local animal shelter or pet store.')]} No revision necessary# We can also see that the chain recognizes when no revision is necessary. good_qa_prompt = PromptTemplate( template="""You are good and must only give...
https:///python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
2caa87dd8a11-4
'critiques_and_revisions': [('No critique needed.', '')]} previous API Chains next BashChain Contents Intermediate Steps No revision necessary By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 02, 2023.
https:///python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
bd52ec04807e-0
.ipynb .pdf Serialization Contents Saving a chain to disk Loading a chain from disk Saving components separately Serialization# This notebook covers how to serialize chains to and from disk. The serialization format we use is json or yaml. Currently, only some chains support this type of serialization. We will grow t...
https:///python.langchain.com/en/latest/modules/chains/generic/serialization.html
bd52ec04807e-1
"best_of": 1, "request_timeout": null, "logit_bias": {}, "_type": "openai" }, "output_key": "text", "_type": "llm_chain" } Loading a chain from disk# We can load a chain from disk by using the load_chain method. from langchain.chains import load_chain chain = load_chain("llm_chain.js...
https:///python.langchain.com/en/latest/modules/chains/generic/serialization.html
bd52ec04807e-2
"top_p": 1, "frequency_penalty": 0, "presence_penalty": 0, "n": 1, "best_of": 1, "request_timeout": null, "logit_bias": {}, "_type": "openai" } config = { "memory": None, "verbose": True, "prompt_path": "prompt.json", "llm_path": "llm.json", "output_key": "text", "_ty...
https:///python.langchain.com/en/latest/modules/chains/generic/serialization.html
853c429e1e92-0
.ipynb .pdf Transformation Chain Transformation Chain# This notebook showcases using a generic transformation chain. As an example, we will create a dummy transformation that takes in a super long text, filters the text to only the first 3 paragraphs, and then passes that into an LLMChain to summarize those. from langc...
https:///python.langchain.com/en/latest/modules/chains/generic/transformation.html
b1ab7f9978c2-0
.ipynb .pdf Loading from LangChainHub Loading from LangChainHub# This notebook covers how to load chains from LangChainHub. from langchain.chains import load_chain chain = load_chain("lc://chains/llm-math/chain.json") chain.run("whats 2 raised to .12") > Entering new LLMMathChain chain... whats 2 raised to .12 Answer: ...
https:///python.langchain.com/en/latest/modules/chains/generic/from_hub.html
b1ab7f9978c2-1
query = "What did the president say about Ketanji Brown Jackson" chain.run(query) " The president said that Ketanji Brown Jackson is a Circuit Court of Appeals Judge, one of the nation's top legal minds, a former top litigator in private practice, a former federal public defender, has received a broad range of support ...
https:///python.langchain.com/en/latest/modules/chains/generic/from_hub.html
932d3ce7f9bc-0
.ipynb .pdf Async API for Chain Async API for Chain# LangChain provides async support for Chains by leveraging the asyncio library. Async methods are currently supported in LLMChain (through arun, apredict, acall) and LLMMathChain (through arun and acall), ChatVectorDBChain, and QA chains. Async support for other chain...
https:///python.langchain.com/en/latest/modules/chains/generic/async_chain.html
932d3ce7f9bc-1
await generate_concurrently() elapsed = time.perf_counter() - s print('\033[1m' + f"Concurrent executed in {elapsed:0.2f} seconds." + '\033[0m') s = time.perf_counter() generate_serially() elapsed = time.perf_counter() - s print('\033[1m' + f"Serial executed in {elapsed:0.2f} seconds." + '\033[0m') BrightSmile Toothpas...
https:///python.langchain.com/en/latest/modules/chains/generic/async_chain.html
983e13481560-0
.ipynb .pdf Creating a custom Chain Creating a custom Chain# To implement your own custom chain you can subclass Chain and implement the following methods: from __future__ import annotations from typing import Any, Dict, List, Optional from pydantic import Extra from langchain.base_language import BaseLanguageModel fro...
https:///python.langchain.com/en/latest/modules/chains/generic/custom_chain.html
983e13481560-1
# Whenever you call a language model, or another chain, you should pass # a callback manager to it. This allows the inner run to be tracked by # any callbacks that are registered on the outer run. # You can always obtain a callback manager for this by calling # `run_manager.get_child()` ...
https:///python.langchain.com/en/latest/modules/chains/generic/custom_chain.html
983e13481560-2
callbacks=run_manager.get_child() if run_manager else None ) # If you want to log something about this run, you can do so by calling # methods on the `run_manager`, as shown below. This will trigger any # callbacks that are registered for that event. if run_manager: a...
https:///python.langchain.com/en/latest/modules/chains/generic/custom_chain.html
0012b5a47672-0
.ipynb .pdf Sequential Chains Contents SimpleSequentialChain Sequential Chain Memory in Sequential Chains Sequential Chains# The next step after calling a language model is make a series of calls to a language model. This is particularly useful when you want to take the output from one call and use it as the input to...
https:///python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
0012b5a47672-1
synopsis_chain = LLMChain(llm=llm, prompt=prompt_template) # This is an LLMChain to write a review of a play given a synopsis. llm = OpenAI(temperature=.7) template = """You are a play critic from the New York Times. Given the synopsis of play, it is your job to write a review for that play. Play Synopsis: {synopsis} R...
https:///python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
0012b5a47672-2
The play follows the couple as they struggle to stay together and battle the forces that threaten to tear them apart. Despite the tragedy that awaits them, they remain devoted to one another and fight to keep their love alive. In the end, the couple must decide whether to take a chance on their future together or succu...
https:///python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
0012b5a47672-3
The play's setting of the beach at sunset adds a touch of poignancy and romanticism to the story, while the mysterious figure serves to keep the audience enthralled. Overall, Tragedy at Sunset on the Beach is an engaging and thought-provoking play that is sure to leave audiences feeling inspired and hopeful. Sequential...
https:///python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
0012b5a47672-4
Play Synopsis: {synopsis} Review from a New York Times play critic of the above play:""" prompt_template = PromptTemplate(input_variables=["synopsis"], template=template) review_chain = LLMChain(llm=llm, prompt=prompt_template, output_key="review") # This is the overall chain where we run these two chains in sequence. ...
https:///python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
0012b5a47672-5
'era': 'Victorian England', 'synopsis': "\n\nThe play follows the story of John, a young man from a wealthy Victorian family, who dreams of a better life for himself. He soon meets a beautiful young woman named Mary, who shares his dream. The two fall in love and decide to elope and start a new life together.\n\nOn th...
https:///python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
0012b5a47672-6
'review': "\n\nThe latest production from playwright X is a powerful and heartbreaking story of love and loss set against the backdrop of 19th century England. The play follows John, a young man from a wealthy Victorian family, and Mary, a beautiful young woman with whom he falls in love. The two decide to elope and st...
https:///python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
0012b5a47672-7
from langchain.memory import SimpleMemory llm = OpenAI(temperature=.7) template = """You are a social media manager for a theater company. Given the title of play, the era it is set in, the date,time and location, the synopsis of the play, and the review of the play, it is your job to write a social media post for tha...
https:///python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
0012b5a47672-8
'location': 'Theater in the Park', 'social_post_text': "\nSpend your Christmas night with us at Theater in the Park and experience the heartbreaking story of love and loss that is 'A Walk on the Beach'. Set in Victorian England, this romantic tragedy follows the story of Frances and Edward, a young couple whose love i...
https:///python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
c85ca926fefb-0
.ipynb .pdf LLM Chain Contents LLM Chain Additional ways of running LLM Chain Parsing the outputs Initialize from string LLM Chain# LLMChain is perhaps one of the most popular ways of querying an LLM object. It formats the prompt template using the input key values provided (and also memory key values, if available),...
https:///python.langchain.com/en/latest/modules/chains/generic/llm_chain.html
c85ca926fefb-1
llm_chain.generate(input_list) LLMResult(generations=[[Generation(text='\n\nSocktastic!', generation_info={'finish_reason': 'stop', 'logprobs': None})], [Generation(text='\n\nTechCore Solutions.', generation_info={'finish_reason': 'stop', 'logprobs': None})], [Generation(text='\n\nFootwear Factory.', generation_info={'...
https:///python.langchain.com/en/latest/modules/chains/generic/llm_chain.html
c85ca926fefb-2
template = """List all the colors in a rainbow""" prompt = PromptTemplate(template=template, input_variables=[], output_parser=output_parser) llm_chain = LLMChain(prompt=prompt, llm=llm) llm_chain.predict() '\n\nRed, orange, yellow, green, blue, indigo, violet' With predict_and_parser: llm_chain.predict_and_parse() ['R...
https:///python.langchain.com/en/latest/modules/chains/generic/llm_chain.html
8c347d8a1ea1-0
.rst .pdf Vectorstores Vectorstores# Note Conceptual Guide Vectorstores are one of the most important components of building indexes. For an introduction to vectorstores and generic functionality see: Getting Started We also have documentation for all the types of vectorstores that are supported. Please see below for t...
https:///python.langchain.com/en/latest/modules/indexes/vectorstores.html
388bd535f56b-0
.rst .pdf Retrievers Retrievers# Note Conceptual Guide The retriever interface is a generic interface that makes it easy to combine documents with language models. This interface exposes a get_relevant_documents method which takes in a query (a string) and returns a list of documents. Please see below for a list of all...
https:///python.langchain.com/en/latest/modules/indexes/retrievers.html
7106a199cfe7-0
.ipynb .pdf Getting Started Contents One Line Index Creation Walkthrough Getting Started# LangChain primary focuses on constructing indexes with the goal of using them as a Retriever. In order to best understand what this means, it’s worth highlighting what the base Retriever interface is. The BaseRetriever class in ...
https:///python.langchain.com/en/latest/modules/indexes/getting_started.html
7106a199cfe7-1
Create a Retriever from that index Create a question answering chain Ask questions! Each of the steps has multiple sub steps and potential configurations. In this notebook we will primarily focus on (1). We will start by showing the one-liner for doing so, but then break down what is actually going on. First, let’s imp...
https:///python.langchain.com/en/latest/modules/indexes/getting_started.html
7106a199cfe7-2
index.query_with_sources(query) {'question': 'What did the president say about Ketanji Brown Jackson', 'answer': " The president said that he nominated Circuit Court of Appeals Judge Ketanji Brown Jackson, one of the nation's top legal minds, to continue Justice Breyer's legacy of excellence, and that she has received...
https:///python.langchain.com/en/latest/modules/indexes/getting_started.html
7106a199cfe7-3
We will then select which embeddings we want to use. from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() We now create the vectorstore to use as the index. from langchain.vectorstores import Chroma db = Chroma.from_documents(texts, embeddings) Running Chroma using direct local API. Using D...
https:///python.langchain.com/en/latest/modules/indexes/getting_started.html
7106a199cfe7-4
) Hopefully this highlights what is going on under the hood of VectorstoreIndexCreator. While we think it’s important to have a simple way to create indexes, we also think it’s important to understand what’s going on under the hood. previous Indexes next Document Loaders Contents One Line Index Creation Walkthrough...
https:///python.langchain.com/en/latest/modules/indexes/getting_started.html
e9043c921ea8-0
.rst .pdf Text Splitters Text Splitters# Note Conceptual Guide When you want to deal with long pieces of text, it is necessary to split up that text into chunks. As simple as this sounds, there is a lot of potential complexity here. Ideally, you want to keep the semantically related pieces of text together. What “seman...
https:///python.langchain.com/en/latest/modules/indexes/text_splitters.html
6f3d6b6772ac-0
.rst .pdf Document Loaders Document Loaders# Note Conceptual Guide Combining language models with your own text data is a powerful way to differentiate them. The first step in doing this is to load the data into “documents” - a fancy way of say some pieces of text. This module is aimed at making this easy. A primary dr...
https:///python.langchain.com/en/latest/modules/indexes/document_loaders.html
6f3d6b6772ac-1
YouTube previous Getting Started next CoNLL-U By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 02, 2023.
https:///python.langchain.com/en/latest/modules/indexes/document_loaders.html
e6812baf0a46-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
e6812baf0a46-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
e6812baf0a46-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
08939e85fd05-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
08939e85fd05-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
ccf3bf0ca18b-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
ccf3bf0ca18b-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
ccf3bf0ca18b-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
f2d4df128fbe-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
f2d4df128fbe-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
e637043b361c-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
6bdc704cc234-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
25696bbf30de-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
25696bbf30de-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
25696bbf30de-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
3921e9c69bad-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
3921e9c69bad-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
3921e9c69bad-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
3921e9c69bad-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
3921e9c69bad-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
3921e9c69bad-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
3ad9ddd48fda-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
d27df9aa5c62-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
d27df9aa5c62-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
d27df9aa5c62-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
d27df9aa5c62-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
d27df9aa5c62-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
d27df9aa5c62-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
d27df9aa5c62-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
d27df9aa5c62-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
d27df9aa5c62-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
f16297b90ac2-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
f16297b90ac2-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
f16297b90ac2-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
f16297b90ac2-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
f16297b90ac2-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
f16297b90ac2-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
f16297b90ac2-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
f16297b90ac2-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
f16297b90ac2-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
c777cec2bc33-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
c777cec2bc33-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
e0c815dba11f-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
e0c815dba11f-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
e0c815dba11f-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
672a37e35f96-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
672a37e35f96-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
1f72f115a043-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
1f72f115a043-1
previous Text Splitters next Character Text Splitter By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 02, 2023.
https:///python.langchain.com/en/latest/modules/indexes/text_splitters/getting_started.html
a584cf30b9c8-0
.ipynb .pdf Python Code Text Splitter Python Code Text Splitter# PythonCodeTextSplitter splits text along python class and method definitions. It’s implemented as a simple subclass of RecursiveCharacterSplitter with Python-specific separators. See the source code to see the Python syntax expected by default. How the te...
https:///python.langchain.com/en/latest/modules/indexes/text_splitters/examples/python.html