GeekHub Learn
Module
Lesson 4.33 of 7 in this module2 min read Module 4: Prompt Engineering Fundamentals

Few-shot prompting: examples beat instructions

When you want a model to do something subtle, examples beat instructions every time. This is the secret weapon of pro prompt engineers.

If you ask a new chef to "make a Bangalorean-style dosa", you might get a dozen interpretations. Show them three photos of exactly what you want, and the next dosa will nail it.

Few-shot prompting is including 2 to 5 input-output examples in your prompt before the real input. The model uses the pattern to infer the rule.

Classify the sentiment.

Tweet: I love this phone, battery lasts all day.
Sentiment: positive

Tweet: Worst app ever. Crashes constantly.
Sentiment: negative

Tweet: It is fine, I guess.
Sentiment: neutral

Tweet: The camera is unreal. Worth every rupee.
Sentiment:

The model completes with positive. No "instruction" needed.

Choose examples that:

  • Cover edge cases (positive, negative, neutral, ambiguous)
  • Match the format exactly
  • Are real-world realistic, not toy

5 well-chosen examples often outperform a long instruction. They also fit better with how the model was trained.

Visualize it

A "stairs" diagram showing 3 example inputs leading to 3 example outputs, then the real input awaiting the model's output. Pattern recognition made literal.

Try it now

Take the sentiment example above. Run it. Then remove all examples and just write "Classify the sentiment: [tweet]". Compare consistency.

Hands-on lab

Build a few-shot prompt for "extract company name and amount from invoice text". Use 3 example invoices. Test on 5 new ones.

Try it now

When do few-shot examples hurt more than help?

Common mistakes

  • Using too few or too generic examples
  • Including examples that subtly conflict with each other
  • Burning tokens on examples when a tight instruction would have sufficed

Debugging tip

If output drifts away from format, add one more example matching that drift's correct version.

Challenge

Build a few-shot prompt that converts plain English to a specific JSON schema. Test on 10 inputs. Aim for 100% format compliance.

Where this shows up

  • Data extraction (invoices, emails, PDFs)
  • Classification with custom taxonomies
  • Style transfer in writing
  • Translation with house glossary

From the field

A well-tuned few-shot prompt often eliminates the need for fine-tuning, saving weeks of work. The 2026 best practice is: few-shot first, fine-tune only if accuracy plateau cannot be broken.

Recap

Examples teach faster than instructions. Three carefully crafted few-shot examples can replace a paragraph of rules and improve consistency.


Quick recall

3 prompts · think before you flip

Prompt 1 of 3

What is few-shot prompting?

Quiz time

1 question · tap an answer to check it

  1. 1. Few-shot prompting is most useful when

Finished lesson 4.3?

Mark complete to update your module progress and unlock the streak.

Loading