
Few-Shot and Zero-Shot Learning
The most powerful technique in prompt engineering. Learn when to use Zero-Shot (asking directly) vs Few-Shot (giving examples) to solve complex tasks.
Few-Shot and Zero-Shot Learning
This concept defines 80% of your success with LLMs.
Zero-Shot Learning
Zero-Shot means asking the model to do something without giving it any examples of doing it.
- Prompt: "Classify the sentiment of this review: 'The food was cold.' "
- Reliance: Relies entirely on the model's pre-training knowledge.
- When to use: Common tasks (Summarization, Translation, basic Sentiment).
Few-Shot Learning
Few-Shot means providing 1 to 5 examples (shots) of the task being performed inside the prompt.
- Prompt:
Classify the sentiment of reviews into: POSITIVE, NEGATIVE, NEUTRAL. Review: "Loved the burger!" -> POSITIVE Review: "Wait time was long." -> NEGATIVE Review: "Table was wood." -> NEUTRAL Review: "The food was cold." -> - Result: The model completes the pattern:
NEGATIVE.
Why Few-Shot Wins
- Defines Output Format: If you want the answer in ALL CAPS, showing an example is better than explaining it.
- Nuance: If your definition of "Negative" is subtle (e.g., sarcasm), examples teach that subtlety better than rules.
The "Structured Prompt" Interface
In Google AI Studio, the Structured Prompt tab is specifically built for Few-Shot.
- You create columns:
Input,Output. - You fill in 5 rows of examples.
- You test on the 6th row.
Summary
- Try Zero-Shot first. It's cheaper (fewer tokens).
- If it fails, add Few-Shot examples.
- Few-Shot often outperforms complex instructions.
In the next lesson, we discuss Iterative Refinement.