Prompt Engineering Fundamentals / Prompting Techniques

One-Shot Prompting

Beginner [2/5]
Single example prompting Single demonstration

Definition

One-shot prompting is a technique where exactly one example is provided to demonstrate the desired task or output format before asking the model to perform the same task on new input.

It sits between zero-shot (no examples) and few-shot (multiple examples), offering a balance between context efficiency and task clarity.

Key Concepts

  • Single demonstration: One input-output pair shows the model what to do
  • Pattern recognition: The model extracts the pattern from just one example
  • Token efficiency: Uses fewer tokens than few-shot while providing more guidance than zero-shot
  • Example quality: The single example must be representative and clear

Examples

Sentiment Analysis
One Example Classification
Example: Text: "This product exceeded my expectations!" Sentiment: Positive Now classify: Text: "The delivery was late and the item was damaged." Sentiment:
One example teaches the model the classification format and task.
Format Conversion
Data Transformation
Example: Input: John Smith, 25, New York Output: {"name": "John Smith", "age": 25, "city": "New York"} Now convert: Input: Jane Doe, 30, Los Angeles Output:
The single example demonstrates the exact JSON structure expected.

Interactive Exercise

Create a One-Shot Prompt

Create a one-shot prompt that teaches the model to convert temperatures from Celsius to Fahrenheit with a specific format.

Include one example and then a new temperature to convert.

Pro Tips
  • Choose an example that represents the most common or typical case
  • Make sure your example is 100% correct—errors will be replicated
  • Use clear formatting to distinguish example from actual task
  • Consider few-shot if one example isn't enough for complex tasks

Related Terms