Country: United States
Capital:
"""
Few Shot Examples#
Few shot examples refer to in-context examples that are provided to a language model as part of a prompt. The examples can be used to help the language model understand the context of the prompt, and as a result generate a better response. Few shot examples can contain both positive and negative examples about the expected response.
Below, we list out some few shot examples that may be relevant for the task of predicting the capital of a country.
Country: United States
Capital: Washington, D.C.
Country: Canada
Capital: Ottawa
To learn more about how to provide few shot examples, see Few Shot Examples.
Example selection#
If there are multiple examples that are relevant to a prompt, it is important to select the most relevant examples. Generally, the quality of the response from the LLM can be significantly improved by selecting the most relevant examples. This is because the language model will be able to better understand the context of the prompt, and also potentially learn failure modes to avoid.
To help the user with selecting the most relevant examples, we provide example selectors that select the most relevant based on different criteria, such as length, semantic similarity, etc. The example selector takes in a list of examples and returns a list of selected examples, formatted as a string. The user can also provide their own example selector. To learn more about example selectors, see Example Selectors.
Serialization#
To make it easy to share PromptTemplates, we provide a serialize method that returns a JSON string. The JSON string can be saved to a file, and then loaded back into a PromptTemplate using the deserialize method. This allows users to share PromptTemplates with others, and also to save them for later use.
To learn more about serialization, see Serialization.
previous
Getting Started
next
How-To Guides
 Contents
  
Prompts
Prompt Templates
Input Variables
Few Shot Examples