few_shot_learning
// Teaching AI by example β€” show 3 examples, it generalizes to new ones
πŸ’‘ The core idea: Instead of explaining the task in words, you just show examples. "Here are 3 correct examples. Now do this new one." The AI reads the pattern from your examples and applies it. Like teaching a new card game: instead of explaining rules, deal a few sample hands and say "see, like that." Works surprisingly well.
Compare zero, one, and few-shot prompting
0️⃣
Zero-Shot
Just give the task. No examples. AI uses its training knowledge only.
Prompt: "Is this tweet positive or negative: 'This product is amazing!'"
1️⃣
One-Shot
Give 1 example before your question. Helps for tricky formats.
Input: "I love it!" β†’ Positive

Input: "This product is amazing!" β†’ ?
πŸ”’
Few-Shot (3-5)
Show 3-5 examples. AI learns the exact pattern you want.
"I love it!" β†’ Positive
"Terrible!" β†’ Negative
"Meh." β†’ Neutral

"Amazing!" β†’ ?
Rule of thumb: Try zero-shot first. If the format or behavior is wrong, add 1 example. Still wrong? Add 2-4 more. Most tasks work well with 3-5 examples. Diminishing returns after ~10 examples.
Why does few-shot work?
LLMs were trained on patterns in text. When you show examples like "X β†’ Y, A β†’ B, M β†’ ?", the model recognizes this as a pattern-matching task and applies the pattern. It's not "learning" in the training sense β€” it's in-context learning: using examples in the prompt to understand the task format at inference time.
3-5 EXAMPLES IS USUALLY ENOUGHSHOW, DON'T TELL
also by echobash