Basic

Few-shot examples

Show the model a couple of examples and it will copy your shape. This few-shot trick is the simplest way to get consistent output.

About 1 min of reading

Data Flow

Examples set the pattern; the model matches new inputs to that pattern.
1 Write 2-3 example pairs
↓
2 Show them before the real input
↓
3 Let the model match the pattern
↓
4 Check the new output matches format
Why this works
Why examples work

When you show examples, the model doesn't guess your format, it matches the pattern it sees. This is called few-shot learning.

Zero-shot:  just instructions
Few-shot:   instructions + examples

Few-shot prompts are the easiest way to get consistent output.

Choosing good examples

Your examples teach the model what to do, so pick the ones you want to repeat.

  • Use realistic inputs, not edge cases.
  • Make the output format perfect.
  • Include 1 or 2 varied examples.

The model learns from your examples, good or bad.

A bad example in your prompt teaches a bad habit.

Examples

Showing the pattern

Example:
  Input:  "I am happy"
  Output: SENTIMENT: positive

Input: "I am sad"
Output:

By showing one example, the model matches your format exactly.

Why it works: examples are a faster teacher than explanations.

How many examples?

1 example  -> gets the shape
3 examples -> handles small variation
10+        -> only for hard patterns

More examples cost more tokens. Start with two or three and add only if needed.

Examples show; words explain. Show first.

Matching the shape

Input:  Paris
Output: Capital of France.

Input:  London
Output: Capital of England.

The model copies the shape of your examples, so keep every output the same shape.

Why it works: consistency in examples gives consistency in answers.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Writing clear prompts
Previous Lesson
Writing clear prompts
Next Lesson
When prompts fail
When prompts fail →