.md
.pdf
Key Concepts
 Contents 
Prompts
Prompt Templates
Input Variables
Few Shot Examples
Example selection
Serialization
Key Concepts#
Prompts#
A prompt is the input to a language model. It is a string of text that is used to generate a response from the language model.
Prompt Templates#
PromptTemplates are a way to create prompts in a reproducible way. They contain a template string, and a set of input variables. The template string can be formatted with the input variables to generate a prompt. The template string often contains instructions to the language model, a few shot examples, and a question to the language model.
PromptTemplates generically have a format method that takes in variables and returns a formatted string.
The most simple implementation of this is to have a template string with some variables in it, and then format it with the incoming variables.
More complex iterations dynamically construct the template string from few shot examples, etc.
To learn more about PromptTemplates, see Prompt Templates.
As an example, consider the following template string:
"""
Predict the capital of a country.
Country: {country}
Capital:
"""
Input Variables#
Input variables are the variables that are used to fill in the template string. In the example above, the input variable is country.
Given an input variable, the PromptTemplate can generate a prompt by filling in the template string with the input variable. For example, if the input variable is United States, the template string can be formatted to generate the following prompt:
"""
Predict the capital of a country.
Country: United States
Capital:
"""
Few Shot Examples#