One-Shot Prompting

What it is about:

One-shot prompting is a technique where you provide a single example within the prompt to guide the LLM's response. This is a step further than zero-shot prompting, which relies solely on the LLM's pre-trained knowledge.

How it works:

  • Single Example Prompt: The prompt includes a single instance of the desired task outcome. This example acts as a reference point for the LLM.
  • Understanding the Structure: The LLM analyzes the provided example to understand the format, content, and relationship between input and output.
  • Generating Similar Output: Based on the single example, the LLM attempts to generate a new output similar in format and content to the provided example, but with potential variations.

Example:

  • Task: Generate a recipe
  • Prompt: "Here's an example recipe: * Ingredients: Flour, sugar, eggs, milk, baking powder. * Instructions: Preheat oven to 375°F. Mix flour, sugar, and baking powder..." Generate a recipe for pancakes.
  • Output: "Ingredients: All-purpose flour, buttermilk, eggs, baking soda. Instructions: In a large bowl, whisk together flour, baking soda..."

When to use it:

One-shot prompting is a good choice for tasks where:

  • The task is relatively simple: The desired output format and content are easy to understand from a single example.
  • Quick results are needed: You need a quick and easy way to get the LLM started without elaborate prompting.
  • No additional examples are readily available: You only have one relevant example to share with the LLM.