Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Back to Generative AI Notes
Topic #507

One-Shot Prompting

One-shot prompting gives the model exactly one example of the task before asking it to perform it — a middle ground between zero-shot (no examples) and few-shot (several examples).

Example

Prompt:
"Convert product descriptions into a title + 1-line tagline.

Example:
Description: A durable stainless steel water bottle that keeps
drinks cold for 24 hours.
Output:
Title: Stainless Steel Water Bottle
Tagline: Cold drinks, all day long.

Now convert this:
Description: A wireless mouse with a rechargeable battery lasting
up to 3 months per charge."

The single example demonstrates the exact desired output structure — often enough to lock in a consistent format that a plain instruction alone might not reliably produce.

Why Use Exactly One Example (Not Zero, Not Several)

SituationBetter Fit
Task is simple, instruction alone is clearZero-shot
Output format needs to be shown, but the pattern is simple/consistentOne-shot
Output has more variation, or the task benefits from seeing multiple pattern variationsFew-shot

One-shot is a reasonable default when zero-shot output format is inconsistent, but you want to keep the prompt compact (fewer tokens than several few-shot examples).

Practical Use Case

Structured, format-sensitive tasks (like the title/tagline example above) where a single clear demonstration is usually enough to establish the pattern, without the added token cost of multiple examples.

Common Mistakes

  • Choosing an example that's atypical or an edge case — the model tends to generalize from the pattern shown, so a poorly chosen example can bias output in unintended ways
  • Assuming one example is always sufficient — some tasks genuinely need multiple examples to show format variation (see Few-Shot Prompting)

Interview Relevance

"What's the practical difference between one-shot and few-shot prompting, beyond just the number of examples?" — token cost tradeoff and how much output-format variation the task actually has are the key distinguishing considerations.

Practice Question

Design a one-shot prompt for converting a customer complaint into a structured (category, urgency, summary) format, choosing a representative (not edge-case) example.

Related Notes

Want to go beyond the notes?

Join CodingNow's Generative AI course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →