Press ESC to exit fullscreen
📖 Lesson ⏱️ 75 minutes

Zero-Shot and Few-Shot Prompting

Control model behavior without fine-tuning using examples in the prompt

Zero-Shot Prompting

Zero-shot means giving the model no examples — just a clear instruction. Modern LLMs handle zero-shot well for standard tasks.

Classify the following text as Technical, Business, or General.

Text: "The new transformer architecture reduces inference latency by 40%."

Output: Technical

Zero-shot works when:

  • The task is well-defined and common
  • The output format is standard
  • You need speed and simplicity

Few-Shot Prompting

Few-shot adds 2–5 examples before the actual input. The model learns the pattern and applies it.

Classify each text. Reply with only the label.

Text: "Q3 revenue up 12% YoY" → Business
Text: "Updated the CI/CD pipeline" → Technical
Text: "The weather is nice today" → General

Text: "Deployed new containerization strategy to reduce costs" →

Output: Business or Technical — the model will infer from context.

When to Use Each

SituationUse
Standard task, common formatZero-shot
Custom classification schemeFew-shot
Ambiguous output expectedFew-shot
Prompt length is a concernZero-shot
Need high consistencyFew-shot

How Many Examples?

  • 3 examples: usually sufficient for simple classification
  • 5 examples: good for nuanced tasks
  • 8–10 examples: complex tasks or rare edge cases
  • More than 10: rarely helps and increases cost

Always include at least one example of each class you want the model to produce.