StudyAIStudyAI
Pro
Lesson 37 min

Few-Shot Prompting

Teach the model by example instead of by description.

What you will learn
  • Zero-shot vs few-shot prompting
  • When examples beat instructions
  • How to format examples clearly

Explanation

Zero-shot means asking with no examples. Few-shot means showing the model 2–5 examples of the input-output pattern you want, then giving it a new input.

Examples are powerful when the task is hard to describe but easy to demonstrate — classification, formatting, tone matching. The model copies the pattern.

Keep examples consistent and clearly separated, and make sure they cover the variety you expect (e.g. include a tricky case).

Code Example

text
1
Classify sentiment.
2
Input: 'I love this!'  -> positive
3
Input: 'It is awful.'  -> negative
4
Input: 'It is fine.'   -> neutral
5
Input: 'Best purchase ever' ->
Real-world use

Few-shot prompts let teams standardise outputs (like tagging tickets) without training a custom model.

Common mistakes
  • Giving examples that are inconsistent in format, which confuses the pattern.
Practice

Write a 3-example few-shot prompt that rewrites blunt sentences into polite ones.

Knowledge check
0/1 answered

1. Few-shot prompting means...

Answer all questions to check.