id
stringlengths
14
15
text
stringlengths
101
5.26k
source
stringlengths
57
120
9ed49f9f780f-0
.ipynb .pdf NGram Overlap ExampleSelector NGram Overlap ExampleSelector# The NGramOverlapExampleSelector selects and orders examples based on which examples are most similar to the input, according to an ngram overlap score. The ngram overlap score is a float between 0.0 and 1.0, inclusive. The selector allows for a th...
https://langchain.readthedocs.io/en/latest/modules/prompts/example_selectors/examples/ngram_overlap.html
9ed49f9f780f-1
# it is excluded. example_selector.threshold=0.0 print(dynamic_prompt.format(sentence="Spot can run fast.")) Give the Spanish translation of every input Input: Spot can run. Output: Spot puede correr. Input: See Spot run. Output: Ver correr a Spot. Input: Spot plays fetch. Output: Spot juega a buscar. Input: Spot can r...
https://langchain.readthedocs.io/en/latest/modules/prompts/example_selectors/examples/ngram_overlap.html
49045e7c8e58-0
.ipynb .pdf LengthBased ExampleSelector LengthBased ExampleSelector# This ExampleSelector selects which examples to use based on length. This is useful when you are worried about constructing a prompt that will go over the length of the context window. For longer inputs, it will select fewer examples to include, while ...
https://langchain.readthedocs.io/en/latest/modules/prompts/example_selectors/examples/length_based.html
83d1e17d693a-0
.ipynb .pdf Similarity ExampleSelector Similarity ExampleSelector# The SemanticSimilarityExampleSelector selects examples based on which examples are most similar to the inputs. It does this by finding the examples with the embeddings that have the greatest cosine similarity with the inputs. from langchain.prompts.exam...
https://langchain.readthedocs.io/en/latest/modules/prompts/example_selectors/examples/similarity.html
589c461060dd-0
.ipynb .pdf Maximal Marginal Relevance ExampleSelector Maximal Marginal Relevance ExampleSelector# The MaxMarginalRelevanceExampleSelector selects examples based on a combination of which examples are most similar to the inputs, while also optimizing for diversity. It does this by finding the examples with the embeddin...
https://langchain.readthedocs.io/en/latest/modules/prompts/example_selectors/examples/mmr.html
fe5cfec8036e-0
.md .pdf Getting Started Contents What is a prompt template? Create a prompt template Template formats Validate template Serialize prompt template Pass few shot examples to a prompt template Select examples for a prompt template Getting Started# In this tutorial, we will learn about: what a prompt template is, and wh...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/getting_started.html
fe5cfec8036e-1
from langchain.prompts import load_prompt loaded_prompt = load_prompt("awesome_prompt.json") assert prompt_template == loaded_prompt langchain also supports loading prompt template from LangChainHub, which contains a collection of useful prompts you can use in your project. You can read more about LangChainHub and the ...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/getting_started.html
fe5cfec8036e-2
# This is the PromptTemplate being used to format the examples. example_prompt=example_prompt, # This is the maximum length that the formatted examples should be. # Length is measured by the get_text_length function below. max_length=25 # This is the function used to get the length of a string, whi...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/getting_started.html
0bec5795a7de-0
.rst .pdf How-To Guides How-To Guides# If you’re new to the library, you may want to start with the Quickstart. The user guide here shows more advanced workflows and how to use the library in different ways. Connecting to a Feature Store How to create a custom prompt template How to create a prompt template that uses f...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/how_to_guides.html
cb73239fa79a-0
.ipynb .pdf How to create a custom prompt template Contents Why are custom prompt templates needed? Creating a Custom Prompt Template Use the custom prompt template How to create a custom prompt template# Let’s suppose we want the LLM to generate English language explanations of a function given its name. To achieve ...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/custom_prompt_template.html
cb19152b8063-0
.ipynb .pdf Prompt Composition Prompt Composition# This notebook goes over how to compose multiple prompts together. This can be useful when you want to reuse parts of prompts. This can be done with a PipelinePrompt. A PipelinePrompt consists of two main parts: final_prompt: This is the final prompt that is returned pi...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/prompt_composition.html
4f42ee7b736a-0
.ipynb .pdf How to work with partial Prompt Templates Contents Partial With Strings Partial With Functions How to work with partial Prompt Templates# A prompt template is a class with a .format method which takes in a key-value map and returns a string (a prompt) to pass to the language model. Like other methods, it ...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/partial.html
2d3b70e088b8-0
.ipynb .pdf Connecting to a Feature Store Contents Feast Load Feast Store Prompts Use in a chain Tecton Prerequisites Define and Load Features Prompts Use in a chain Featureform Initialize Featureform Prompts Use in a chain Connecting to a Feature Store# Feature stores are a concept from traditional machine learning ...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/connecting_to_a_feature_store.html
2d3b70e088b8-1
chain.run(1001) "Hi there! I wanted to update you on your current stats. Your acceptance rate is 0.055561766028404236 and your average daily trips are 936. While your conversation rate is currently 0.4745151400566101, I have no doubt that with a little extra effort, you'll be able to exceed that .5 mark! Keep up the gr...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/connecting_to_a_feature_store.html
2d3b70e088b8-2
Featureform# Finally, we will use Featureform an open-source and enterprise-grade feature store to run the same example. Featureform allows you to work with your infrastructure like Spark or locally to define your feature transformations. Initialize Featureform# You can follow in the instructions in the README to initi...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/connecting_to_a_feature_store.html
f6c05cba93d4-0
.ipynb .pdf How to create a prompt template that uses few shot examples Contents Use Case Using an example set Create the example set Create a formatter for the few shot examples Feed examples and formatter to FewShotPromptTemplate Using an example selector Feed examples into ExampleSelector Feed example selector int...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/few_shot_examples.html
f6c05cba93d4-1
Are follow up questions needed here: Yes. Follow up: How old was Muhammad Ali when he died? Intermediate answer: Muhammad Ali was 74 years old when he died. Follow up: How old was Alan Turing when he died? Intermediate answer: Alan Turing was 41 years old when he died. So the final answer is: Muhammad Ali Question: Whe...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/few_shot_examples.html
f6c05cba93d4-2
Intermediate answer: The mother of George Washington was Mary Ball Washington. Follow up: Who was the father of Mary Ball Washington? Intermediate answer: The father of Mary Ball Washington was Joseph Ball. So the final answer is: Joseph Ball Question: Who was the father of Mary Ball Washington? previous How to create ...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/few_shot_examples.html
1a1fe5222c39-0
.ipynb .pdf How to serialize prompts Contents PromptTemplate Loading from YAML Loading from JSON Loading Template from a File FewShotPromptTemplate Examples Loading from YAML Loading from JSON Examples in the Config Example Prompt from a File PromptTempalte with OutputParser How to serialize prompts# It is often pref...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/prompt_serialization.html
1a1fe5222c39-1
_type: few_shot input_variables: ["adjective"] prefix: Write antonyms for the following words. example_prompt: _type: prompt input_variables: ["input", "output"] template: "Input: {input}\nOutput: {output}" examples: examples.yaml suffix: "Input: {adjective}\nOutput:" prompt...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/prompt_serialization.html
1a1fe5222c39-2
} prompt = load_prompt("prompt_with_output_parser.json") prompt.output_parser.parse("George Washington was born in 1732 and died in 1799.\nScore: 1/2") {'answer': 'George Washington was born in 1732 and died in 1799.', 'score': '1/2'} previous Prompt Composition next Prompts Contents PromptTemplate Loading from YA...
https://langchain.readthedocs.io/en/latest/modules/prompts/prompt_templates/examples/prompt_serialization.html
9f4c2d26ae5b-0
.ipynb .pdf Output Parsers Output Parsers# Language models output text. But many times you may want to get more structured information than just text back. This is where output parsers come in. Output parsers are classes that help structure language model responses. There are two main methods an output parser must impl...
https://langchain.readthedocs.io/en/latest/modules/prompts/output_parsers/getting_started.html
a8939f07e56d-0
.ipynb .pdf Structured Output Parser Structured Output Parser# While the Pydantic/JSON parser is more powerful, we initially experimented data structures having text fields only. from langchain.output_parsers import StructuredOutputParser, ResponseSchema from langchain.prompts import PromptTemplate, ChatPromptTemplate,...
https://langchain.readthedocs.io/en/latest/modules/prompts/output_parsers/examples/structured.html
04258ed25ad1-0
.ipynb .pdf PydanticOutputParser PydanticOutputParser# This output parser allows users to specify an arbitrary JSON schema and query LLMs for JSON outputs that conform to that schema. Keep in mind that large language models are leaky abstractions! You’ll have to use an LLM with sufficient capacity to generate well-form...
https://langchain.readthedocs.io/en/latest/modules/prompts/output_parsers/examples/pydantic.html
8632c7babfac-0
.ipynb .pdf Enum Output Parser Enum Output Parser# This notebook shows how to use an Enum output parser from langchain.output_parsers.enum import EnumOutputParser from enum import Enum class Colors(Enum): RED = "red" GREEN = "green" BLUE = "blue" parser = EnumOutputParser(enum=Colors) parser.parse("red") <C...
https://langchain.readthedocs.io/en/latest/modules/prompts/output_parsers/examples/enum.html
204a1b14411b-0
.ipynb .pdf RetryOutputParser RetryOutputParser# While in some cases it is possible to fix any parsing mistakes by only looking at the output, in other cases it can’t. An example of this is when the output is not just in the incorrect format, but is partially complete. Consider the below example. from langchain.prompts...
https://langchain.readthedocs.io/en/latest/modules/prompts/output_parsers/examples/retry.html
a7787a172610-0
.ipynb .pdf Datetime Datetime# This OutputParser shows out to parse LLM output into datetime format. from langchain.prompts import PromptTemplate from langchain.output_parsers import DatetimeOutputParser from langchain.chains import LLMChain from langchain.llms import OpenAI output_parser = DatetimeOutputParser() templ...
https://langchain.readthedocs.io/en/latest/modules/prompts/output_parsers/examples/datetime.html
a75840c8a3a0-0
.ipynb .pdf CommaSeparatedListOutputParser CommaSeparatedListOutputParser# Here’s another parser strictly less powerful than Pydantic/JSON parsing. from langchain.output_parsers import CommaSeparatedListOutputParser from langchain.prompts import PromptTemplate, ChatPromptTemplate, HumanMessagePromptTemplate from langch...
https://langchain.readthedocs.io/en/latest/modules/prompts/output_parsers/examples/comma_separated.html
cbf1f18c47da-0
.ipynb .pdf OutputFixingParser OutputFixingParser# This output parser wraps another output parser and tries to fix any mistakes The Pydantic guardrail simply tries to parse the LLM response. If it does not parse correctly, then it errors. But we can do other things besides throw errors. Specifically, we can pass the mi...
https://langchain.readthedocs.io/en/latest/modules/prompts/output_parsers/examples/output_fixing_parser.html
cbf1f18c47da-1
previous Enum Output Parser next PydanticOutputParser By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/modules/prompts/output_parsers/examples/output_fixing_parser.html
e7f50ecba501-0
.rst .pdf Welcome to LangChain Contents Getting Started Modules Use Cases Reference Docs Ecosystem Additional Resources Welcome to LangChain# LangChain is a framework for developing applications powered by language models. We believe that the most powerful and differentiated applications will not only call out to a l...
https://langchain.readthedocs.io/en/latest/langchain/index.html
e7f50ecba501-1
Tracing: A guide on using tracing in LangChain to visualize the execution of chains and agents. Model Laboratory: Experimenting with different prompts, models, and chains is a big part of developing the best possible application. The ModelLaboratory makes it easy to do so. Discord: Join us on our Discord to discuss all...
https://langchain.readthedocs.io/en/latest/langchain/index.html
3911e74c4326-0
.md .pdf Deployments Contents Anyscale Streamlit Gradio (on Hugging Face) Chainlit Beam Vercel FastAPI + Vercel Kinsta Fly.io Digitalocean App Platform Google Cloud Run SteamShip Langchain-serve BentoML Databutton Deployments# So, you’ve created a really cool chain - now what? How do you deploy it and make it easily ...
https://langchain.readthedocs.io/en/latest/ecosystem/deployments.html
3911e74c4326-1
Beam Vercel FastAPI + Vercel Kinsta Fly.io Digitalocean App Platform Google Cloud Run SteamShip Langchain-serve BentoML Databutton By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/ecosystem/deployments.html
cf5217c4d644-0
.md .pdf Tracing Contents Tracing Walkthrough Changing Sessions Tracing# By enabling tracing in your LangChain runs, you’ll be able to more effectively visualize, step through, and debug your chains and agents. First, you should install tracing and set up your environment properly. You can use either a locally hosted...
https://langchain.readthedocs.io/en/latest/additional_resources/tracing.html
cd8629718a26-0
.rst .pdf Deploying LLMs in Production Contents Outline Designing a Robust LLM Application Service Monitoring Fault tolerance Zero down time upgrade Load balancing Maintaining Cost-Efficiency and Scalability Self-hosting models Resource Management and Auto-Scaling Utilizing Spot Instances Independent Scaling Batching...
https://langchain.readthedocs.io/en/latest/additional_resources/deploy_llms.html
cd8629718a26-1
There are several strategies for load balancing. For example, one common method is the Round Robin strategy, where each request is sent to the next server in line, cycling back to the first when all servers have received a request. This works well when all servers are equally capable. However, if some servers are more ...
https://langchain.readthedocs.io/en/latest/additional_resources/deploy_llms.html
cd8629718a26-2
Infrastructure as Code (IaC)# Rapid iteration also involves the ability to recreate your infrastructure quickly and reliably. This is where Infrastructure as Code (IaC) tools like Terraform, CloudFormation, or Kubernetes YAML files come into play. They allow you to define your infrastructure in code files, which can be...
https://langchain.readthedocs.io/en/latest/additional_resources/deploy_llms.html
a2f0049aa52d-0
.ipynb .pdf Model Comparison Model Comparison# Constructing your language model application will likely involved choosing between many different options of prompts, models, and even chains to use. When doing so, you will want to compare these different options on different inputs in an easy, flexible, and intuitive way...
https://langchain.readthedocs.io/en/latest/additional_resources/model_laboratory.html
a2f0049aa52d-1
> Finished chain. So the final answer is: El Palmar, Spain Cohere Params: {'model': 'command-xlarge-20221108', 'max_tokens': 256, 'temperature': 0.0, 'k': 0, 'p': 1, 'frequency_penalty': 0, 'presence_penalty': 0} > Entering new chain... What is the hometown of the reigning men's U.S. Open champion? Are follow up questi...
https://langchain.readthedocs.io/en/latest/additional_resources/model_laboratory.html
93d8bb37c16b-0
.md .pdf YouTube Contents ⛓️Official LangChain YouTube channel⛓️ Introduction to LangChain with Harrison Chase, creator of LangChain Videos (sorted by views) YouTube# This is a collection of LangChain videos on YouTube. ⛓️Official LangChain YouTube channel⛓️# Introduction to LangChain with Harrison Chase, creator of ...
https://langchain.readthedocs.io/en/latest/additional_resources/youtube.html
93d8bb37c16b-1
⛓️ LangChain Tutorial - ChatGPT mit eigenen Daten by Coding Crashkurse ⛓️ Chat with a CSV | LangChain Agents Tutorial (Beginners) by GoDataProf ⛓️ Introdução ao Langchain - #Cortes - Live DataHackers by Prof. João Gabriel Lima ⛓️ LangChain: Level up ChatGPT !? | LangChain Tutorial Part 1 by Code Affinity ⛓️ KI schreibt...
https://langchain.readthedocs.io/en/latest/additional_resources/youtube.html