id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
f2a14555186f-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
f2a14555186f-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
f2a14555186f-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
f2a14555186f-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
f2a14555186f-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
f2a14555186f-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
f2a14555186f-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
f2a14555186f-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
548461147591-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
548461147591-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
548461147591-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
fc1037d7c8b8-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
5ca65b9282a9-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
ae2c0472d555-0
.ipynb .pdf Getting Started Contents One Line Index Creation Walkthrough Getting Started# LangChain primarily 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 i...
https://python.langchain.com/en/latest/modules/indexes/getting_started.html
ae2c0472d555-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
ae2c0472d555-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
ae2c0472d555-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
ae2c0472d555-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
6ed7c776f6a6-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
6ed7c776f6a6-1
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/text_splitters.html
d87d02b2a109-0
.rst .pdf Document Loaders Contents Transform loaders Public dataset or service loaders Proprietary dataset or service 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 “Docum...
https://python.langchain.com/en/latest/modules/indexes/document_loaders.html
d87d02b2a109-1
iFixit IMSDb MediaWikiDump Wikipedia YouTube transcripts Proprietary dataset or service loaders# These datasets and services are not from the public domain. These loaders mostly transform data from specific formats of applications or cloud services, for example Google Drive. We need access tokens and sometime other par...
https://python.langchain.com/en/latest/modules/indexes/document_loaders.html
43ab4d46f786-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
43ab4d46f786-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
43ab4d46f786-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
43ab4d46f786-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
43ab4d46f786-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
43ab4d46f786-5
We can also use the self query retriever to specify k: the number of documents to fetch. 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=Tr...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query.html
84704f9ddf9b-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
84704f9ddf9b-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
2663f0dba321-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
2663f0dba321-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
2663f0dba321-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
c563f1ac893d-0
.ipynb .pdf Vespa Vespa# Vespa is a fully featured search engine and vector database. It supports vector search (ANN), lexical search, and search in structured data, all in the same query. This notebook shows how to use Vespa.ai as a LangChain retriever. In order to create a retriever, we use pyvespa to create a connec...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vespa.html
c563f1ac893d-1
retriever.get_relevant_documents("what is vespa?") previous VectorStore next Weaviate Hybrid Search By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/vespa.html
86caca60b759-0
.ipynb .pdf SVM Contents Create New Retriever with Texts Use Retriever SVM# Support vector machines (SVMs) are a set of supervised learning methods used for classification, regression and outliers detection. This notebook goes over how to use a retriever that under the hood uses an SVM using scikit-learn package. Lar...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/svm.html
a252b67840a3-0
.ipynb .pdf Zep Memory Contents Retriever Example Initialize the Zep Chat Message History Class and add a chat message history to the memory store Use the Zep Retriever to vector search over the Zep memory Zep Memory# Retriever Example# This notebook demonstrates how to search historical chat message histories using ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
a252b67840a3-1
session_id = str(uuid4()) # This is a unique identifier for the user/session # Set up Zep Chat History. We'll use this to add chat histories to the memory store zep_chat_history = ZepChatMessageHistory( session_id=session_id, url=ZEP_API_URL, ) # Preload some messages into the memory. The default message windo...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
a252b67840a3-2
" Fellowship." ), }, { "role": "human", "content": "Which other women sci-fi writers might I want to read?", }, { "role": "ai", "content": "You might want to read Ursula K. Le Guin or Joanna Russ.", }, { "role": "human", "content": ( ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
a252b67840a3-3
url=ZEP_API_URL, top_k=5, ) await zep_retriever.aget_relevant_documents("Who wrote Parable of the Sower?") [Document(page_content='Who was Octavia Butler?', metadata={'score': 0.7759001673780126, 'uuid': '3a82a02f-056e-4c6a-b960-67ebdf3b2b93', 'created_at': '2023-05-25T15:03:30.2041Z', 'role': 'human', 'token_count...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
a252b67840a3-4
Document(page_content='Octavia Estelle Butler (June 22, 1947 – February 24, 2006) was an American science fiction author.', metadata={'score': 0.7546211059317948, 'uuid': '34678311-0098-4f1a-8fd4-5615ac692deb', 'created_at': '2023-05-25T15:03:30.231427Z', 'role': 'ai', 'token_count': 31}), Document(page_content='Which...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
a252b67840a3-5
Document(page_content="Write a short synopsis of Butler's book, Parable of the Sower. What is it about?", metadata={'score': 0.8857628682610436, 'uuid': 'f6706e8c-6c91-452f-8c1b-9559fd924657', 'created_at': '2023-05-25T15:03:30.265302Z', 'role': 'human', 'token_count': 23}), Document(page_content='Who was Octavia Butl...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
a252b67840a3-6
Document(page_content='You might want to read Ursula K. Le Guin or Joanna Russ.', metadata={'score': 0.7595293992240313, 'uuid': 'f22f2498-6118-4c74-8718-aa89ccd7e3d6', 'created_at': '2023-05-25T15:03:30.261198Z', 'role': 'ai', 'token_count': 18})] previous Wikipedia next Chains Contents Retriever Example Initializ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/zep_memorystore.html
eda9700557d0-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
eda9700557d0-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
eda9700557d0-2
Hunter was adapted into a 62-episode anime television series produced by Nippon Animation and directed by Kazuhiro Furuhashi, which ran on Fuji Television from October 1999 to March 2001. Three separate original video animations (OVAs) totaling 30 episodes were subsequently produced by Nippon Animation and released in ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html
eda9700557d0-3
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 million copies in circulation by July 2022.\n\n'}
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html
eda9700557d0-4
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
eda9700557d0-5
-> **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
d6fb658dd57d-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
d6fb658dd57d-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
d6fb658dd57d-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
d6fb658dd57d-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
d6fb658dd57d-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
d6fb658dd57d-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
36be6b46348a-0
.ipynb .pdf Azure Cognitive Search Retriever Contents Set up Azure Cognitive Search Using the Azure Cognitive Search Retriever Azure Cognitive Search Retriever# This notebook shows how to use Azure Cognitive Search (ACS) within LangChain. Set up Azure Cognitive Search# To set up ACS, please follow the instrcutions he...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/azure-cognitive-search-retriever.html
d9ff4168059c-0
.ipynb .pdf Self-querying with Weaviate Contents Creating a Weaviate vectorstore Creating our self-querying retriever Testing it out Filter k Self-querying with Weaviate# Creating a Weaviate vectorstore# First we’ll want to create a Weaviate VectorStore and seed it with some data. We’ve created a small demo set of do...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html
d9ff4168059c-1
Document(page_content="Toys come alive and have a blast doing so", metadata={"year": 1995, "genre": "animated"}), Document(page_content="Three men walk into the Zone, three men walk out of the Zone", metadata={"year": 1979, "rating": 9.9, "director": "Andrei Tarkovsky", "genre": "science fiction", "rating": 9.9}) ]...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html
d9ff4168059c-2
llm = OpenAI(temperature=0) retriever = SelfQueryRetriever.from_llm(llm, vectorstore, document_content_description, metadata_field_info, verbose=True) Testing it out# And now we can try actually using our retriever! # This example only specifies a relevant query retriever.get_relevant_documents("What are some movies ab...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html
d9ff4168059c-3
We can also use the self query retriever to specify k: the number of documents to fetch. 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=Tr...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate_self_query.html
f0fa91f792ab-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
f0fa91f792ab-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
c9abf70b2026-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
43dc5a00e5e9-0
.ipynb .pdf TF-IDF Contents Create New Retriever with Texts Create a New Retriever with Documents Use Retriever TF-IDF# TF-IDF means term-frequency times inverse document-frequency. This notebook goes over how to use a retriever that under the hood uses TF-IDF using scikit-learn package. For more information on the d...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/tf_idf.html
9098a34417f0-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
9098a34417f0-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
9098a34417f0-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
9098a34417f0-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
070c6b971e0f-0
.ipynb .pdf ChatGPT Plugin Contents Using the ChatGPT Retriever Plugin ChatGPT Plugin# OpenAI plugins connect ChatGPT to third-party applications. These plugins enable ChatGPT to interact with APIs defined by developers, enhancing ChatGPT’s capabilities and allowing it to perform a wide range of actions. Plugins can ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin.html
070c6b971e0f-1
Using the ChatGPT Retriever Plugin# Okay, so we’ve created the ChatGPT Retriever Plugin, but how do we actually use it? The below code walks through how to do that. We want to use ChatGPTPluginRetriever so we have to get the OpenAI API Key. import os import getpass os.environ['OPENAI_API_KEY'] = getpass.getpass('OpenAI...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin.html
070c6b971e0f-2
Document(page_content='Team: Angels "Payroll (millions)": 154.49 "Wins": 89', lookup_str='', metadata={'id': '59c2c0c1-ae3f-4272-a1da-f44a723ea631_0', 'metadata': {'source': None, 'source_id': None, 'url': None, 'created_at': None, 'author': None, 'document_id': '59c2c0c1-ae3f-4272-a1da-f44a723ea631'}, 'embedding': Non...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chatgpt-plugin.html
de656f6bc752-0
.ipynb .pdf Weaviate Hybrid Search Weaviate Hybrid Search# Weaviate is an open source vector database. Hybrid search is a technique that combines multiple search algorithms to improve the accuracy and relevance of search results. It uses the best features of both keyword-based search algorithms with vector search techn...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html
de656f6bc752-1
) Add some data: docs = [ Document( metadata={ "title": "Embracing The Future: AI Unveiled", "author": "Dr. Rebecca Simmons", }, page_content="A comprehensive analysis of the evolution of artificial intelligence, from its inception to its future prospects. Dr. Simmons...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html
de656f6bc752-2
"author": "Prof. Jonathan K. Sterling", }, page_content="In his follow-up to 'Symbiosis', Prof. Sterling takes a look at the subtle, unnoticed presence and influence of AI in our everyday lives. It reveals how AI has become woven into our routines, often without our explicit realization.", ), ] retr...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html
de656f6bc752-3
Document(page_content='Prof. Sterling explores the potential for harmonious coexistence between humans and artificial intelligence. The book discusses how AI can be integrated into society in a beneficial and non-disruptive manner.', metadata={})] Do a hybrid search with where filter: retriever.get_relevant_documents( ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html
ddf95ffb81c3-0
.ipynb .pdf Arxiv Contents Installation Examples Running retriever Question Answering on facts Arxiv# arXiv is an open-access archive for 2 million scholarly articles in the fields of physics, mathematics, computer science, quantitative biology, quantitative finance, statistics, electrical engineering and systems sci...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/arxiv.html
ddf95ffb81c3-1
'Authors': 'Caprice Stanley, Tobias Windisch', 'Summary': 'Graphs on lattice points are studied whose edges come from a finite set of\nallowed moves of arbitrary length. We show that the diameter of these graphs on\nfibers of a fixed integer matrix can be bounded from above by a constant. We\nthen study the mixing beh...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/arxiv.html
ddf95ffb81c3-2
questions = [ "What are Heat-bath random walks with Markov base?", "What is the ImageBind model?", "How does Compositional Reasoning with Large Language Models works?", ] chat_history = [] for question in questions: result = qa({"question": question, "chat_history": chat_history}) chat_history...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/arxiv.html
ddf95ffb81c3-3
-> **Question**: How does Compositional Reasoning with Large Language Models works? **Answer**: Compositional reasoning with large language models refers to the ability of these models to correctly identify and represent complex concepts by breaking them down into smaller, more basic parts and combining them in a stru...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/arxiv.html
ddf95ffb81c3-4
**Answer**: Heat-bath random walks with Markov base (HB-MB) is a class of stochastic processes that have been studied in the field of statistical mechanics and condensed matter physics. In these processes, a particle moves in a lattice by making a transition to a neighboring site, which is chosen according to a probabi...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/arxiv.html
4b19ed377cb0-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
4b19ed377cb0-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
4b19ed377cb0-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
4b19ed377cb0-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
4b19ed377cb0-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
4b19ed377cb0-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
4b19ed377cb0-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
4b19ed377cb0-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
4b19ed377cb0-8
previous Cohere Reranker next Databerry 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 By Harrison Chase ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/contextual-compression.html
a1ec34e55cb8-0
.ipynb .pdf Cohere Reranker Contents Set up the base vector store retriever Doing reranking with CohereRerank Cohere Reranker# Cohere is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions. This notebook shows how to use Cohere’s rerank endpoint i...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
a1ec34e55cb8-1
texts = text_splitter.split_documents(documents) retriever = FAISS.from_documents(texts, OpenAIEmbeddings()).as_retriever(search_kwargs={"k": 20}) query = "What did the president say about Ketanji Brown Jackson" docs = retriever.get_relevant_documents(query) pretty_print_docs(docs) Document 1: One of the most serious c...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
a1ec34e55cb8-2
Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. In this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight....
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
a1ec34e55cb8-3
It’s exploitation—and it drives up prices. ---------------------------------------------------------------------------------------------------- Document 8: For the past 40 years we were told that if we gave tax breaks to those at the very top, the benefits would trickle down to everyone else. But that trickle-down the...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
a1ec34e55cb8-4
The pandemic has been punishing. And so many families are living paycheck to paycheck, struggling to keep up with the rising cost of food, gas, housing, and so much more. I understand. ---------------------------------------------------------------------------------------------------- Document 12: Madam Speaker, Mada...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
a1ec34e55cb8-5
Third, support our veterans. Veterans are the best of us. I’ve always believed that we have a sacred obligation to equip all those we send to war and care for them and their families when they come home. My administration is providing assistance with job training and housing, and now helping lower-income veterans ge...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
a1ec34e55cb8-6
---------------------------------------------------------------------------------------------------- Document 19: I understand. I remember when my Dad had to leave our home in Scranton, Pennsylvania to find work. I grew up in a family where if the price of food went up, you felt it. That’s why one of the first things...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
a1ec34e55cb8-7
And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence. ---------------------------------------------------------------------------------------------------- Document 2: I spoke with th...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
a1ec34e55cb8-8
previous Self-querying with Chroma next Contextual Compression Contents Set up the base vector store retriever Doing reranking with CohereRerank By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
4856a8d3860d-0
.ipynb .pdf Metal Contents Ingest Documents Query Metal# Metal is a managed service for ML Embeddings. This notebook shows how to use Metal’s retriever. First, you will need to sign up for Metal and get an API key. You can do so here # !pip install metal_sdk from metal_sdk.metal import Metal API_KEY = "" CLIENT_ID = ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/metal.html
4856a8d3860d-1
previous kNN next Pinecone Hybrid Search Contents Ingest Documents Query By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/metal.html