Prompt Engineering Tutorial 0/120 lessons ~6 min read Lesson 17

    One-Shot Prompting

    One-shot gives the model exactly one example of the desired input → output pattern.

    Course progress0%
    Focus
    6 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    One-shot gives the model exactly one example of the desired input → output pattern. It's the cheapest way to teach the model an unusual format.

    Beginner analogy: Showing a new intern one completed expense report. They don't need a manual — one example clarifies the format.

    Understanding the topic

    Core concepts to understand:

    • Format: instruction + 1 example + new input.
    • Best for tasks where format is novel but logic is simple.
    • Cheaper than few-shot, more reliable than zero-shot.
    • Watch out for the model copying the example too literally.

    Syntax reference

    Visual workflow / architecture:

    bash
    Instruction: Convert dates to ISO.
    Example:
    Input: "3rd of March 2024"
    Output: "2024-03-03"
    Now do:
    Input: "12 December 1999"
    Output: ?

    Real-world use

    Form-filling, data extraction and code-formatting tools rely heavily on one-shot prompts — one example is often enough.

    Best practices

    • Use one shot when zero-shot fails but format is the only problem.
    • Pick an example that covers the edge case you fear.
    • Mark example and target inputs with delimiters to avoid leakage.

    Hands-on exercise

    Interview preparation — practice these questions:

    • Q1. Difference between zero-shot and one-shot?
    • Q2. Risk of using a biased single example?
    • Q3. When would you upgrade from one-shot to few-shot?
    • Q4. How do you choose THE example?
    Ready to mark this lesson complete?Track your journey across the entire course.