# Few-Shot Examples

> Show, do not just tell: well-chosen input and output examples teach format, tone and edge cases faster than paragraphs of rules. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/ai-engineer/few-shot-prompting
Last updated: 2026-11-28

Show, do not just tell: well-chosen input and output examples teach format, tone and edge cases faster than paragraphs of rules.

Beginner · about 3 hours · difficulty 2/5

Learn first: [Clear Instructions and System Prompts](https://www.internhack.in/roadmaps/tracks/ai-engineer/prompt-fundamentals)

**Few-shot prompting** includes a handful of example inputs with ideal outputs. Models imitate examples strongly, which makes them the fastest way to lock in a format or style.

### Choosing examples

- **Diverse**: cover the range of inputs, including tricky and edge cases, not five variations of the easy case.
- **Representative of the output you want**: the model copies length, tone and structure, including mistakes.
- **Labelled clearly**: wrap each example in tags or headings so the model can tell examples from the real input.
- Three to five good examples usually beat twenty mediocre ones.

### Pitfalls

- **Overfitting to examples**: if all examples mention the same product, outputs will too. Vary surface details.
- **Order and recency effects**: the last example can have outsized influence.
- **Leaking into answers**: the model may reuse facts from examples. Use obviously fictional data.
- Long example sets cost tokens on every request; prompt caching helps.

### Dynamic few-shot

For large tasks, store a library of examples and **retrieve the most similar ones** per request using embeddings. This combines prompting with the retrieval ideas coming later.

### Good enough to move on

You can improve a classification or rewriting prompt by adding diverse examples and measure the improvement on a test set.

## Key concepts

- **Zero-shot vs few-shot**
- **Choosing diverse examples**
- **Formatting and delimiting examples**
- **Avoiding example overfitting**
- **Dynamic example retrieval**

## Mini project

Build a support-ticket classifier, measure zero-shot accuracy on 40 labelled tickets, then add 4 diverse examples and measure again; report which categories improved.

## Check yourself

All your examples are short, and now every output is too short for complex inputs. What happened and how do you fix it?

## Free resources

- [Prompting Guide: few-shot prompting](https://www.promptingguide.ai/techniques/fewshot) (DAIR.AI)
- [Anthropic prompt engineering overview](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/overview) (Anthropic)

Previous: [Clear Instructions and System Prompts](https://www.internhack.in/roadmaps/tracks/ai-engineer/prompt-fundamentals) · Next: [Chain-of-Thought and Task Decomposition](https://www.internhack.in/roadmaps/tracks/ai-engineer/chain-of-thought)

## More in Prompt Design That Holds Up

- [Clear Instructions and System Prompts](https://www.internhack.in/roadmaps/tracks/ai-engineer/prompt-fundamentals)
- [Few-Shot Examples](https://www.internhack.in/roadmaps/tracks/ai-engineer/few-shot-prompting)
- [Chain-of-Thought and Task Decomposition](https://www.internhack.in/roadmaps/tracks/ai-engineer/chain-of-thought)
- [Structured Prompts and Long Context](https://www.internhack.in/roadmaps/tracks/ai-engineer/structured-prompts)
- [Prompt Templates, Versioning and Iteration](https://www.internhack.in/roadmaps/tracks/ai-engineer/prompt-management)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [AI Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/ai-engineer)
