Start studying
Module 7 · Prompt Engineering Module contents
Module 7  ·  Card 8 / 17beginner

Few-Shot Prompting

Few-shot prompting includes several worked examples in the prompt.

The examples demonstrate the exact input and output pattern you want.

Two to five well-chosen examples usually capture most of the benefit.

It is especially effective for enforcing a specific output format.

Examples should cover edge cases, since the model will imitate their style closely.

Learn in depth ↓
Module 07 · Prompt Engineering · 17 concepts
In depth  /  15 lines

Few-Shot Prompting, in more detail

Few-shot prompting means including worked examples in the prompt itself.

Each example shows an input and the exact output you would want for it.

The model infers the pattern and continues it, which is in-context learning at work.

Two to five examples capture most of the available benefit.

Beyond about ten the returns flatten while the cost keeps rising.

It is the most reliable way to pin down an output format.

Describing a format takes a paragraph, and showing it takes one line.

The examples are imitated closely, including their style and their mistakes.

A typo in an example will reappear in the output.

Choose examples that cover the edge cases, not three variations of the easy case.

Include a hard case with the correct hard answer, since that is where the model needs guidance.

Keep the formatting of every example identical, because inconsistency is copied as variety.

Order has a mild effect, and the last example tends to weigh slightly more.

Every call resends the examples and pays for them, which is the recurring cost.

When that cost becomes uncomfortable, that is the honest signal to fine-tune instead.

Want the full technical article? Wikipedia ↗
Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
When is few-shot prompting most useful over zero-shot?
Prompt Engineering

17 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close