What Is Few-Shot Prompting?

Also called few-shot examples, few-shot learning, zero-shot prompting

Short Answer

Few-shot prompting means including a few worked examples of the task in the prompt so the model copies their pattern, format and level of detail. Zero-shot means giving only the instruction, with no examples. Few-shot prompting is one of the quickest ways to make outputs consistent.

  • Taught in lesson 7
4.2%Part of a Skill Employers Ask For: Prompt Engineering4.2% of technical job ads at AI companies ask for Prompt Engineering, the skill this term belongs to (number 31 of the skills ai2hired tracks).Read the full skill guide: what employers expect, how deep to go and interview questions

Why It Matters

Few-shot prompting is one of the quickest ways to get consistent output from a model without training it. A handful of good examples often fixes format, tone and level of detail better than paragraphs of instructions.

How It Works

The idea became famous with the 2020 GPT-3 paper, "Language Models are Few-Shot Learners", which showed large models could learn a task from a handful of examples in the prompt, without any retraining.

Pick examples that cover the tricky cases, keep their format identical, and vary their content so the model does not copy one example too closely. Two to five examples are usually enough.

Good examples are realistic, varied and correct: they should cover typical and tricky cases and show exactly the output you want. The model copies patterns closely, including mistakes and quirks, so one bad example can spread errors. Examples also cost tokens on every request, so teams balance the number of examples against cost, and move to fine-tuning when they need hundreds of examples to get the behaviour.

Few-Shot Prompting in Practice

Everyday Example

To sort support tickets into billing, technical or account, the prompt shows three tickets with their correct category, then the new ticket.

Industry Example: Pharma

To classify adverse event reports as serious or non-serious, the prompt includes labelled examples, including borderline ones, matching the company's safety definitions.

Where You Meet It

  • Classification and extraction prompts.
  • Prompts that must follow a strict format.
  • Product prompts that set a consistent tone.
  • Quick prototypes before fine-tuning is considered.

Key Ideas Around It

Zero-shot
Giving only the instruction, with no examples.
One-shot
Giving a single example.
In-context learning
A model following patterns shown in its prompt.
Fine-tuning
Training on many examples so the behaviour is learned permanently.

A Common Mix-Up

Few-shot prompting does not train the model. The examples only guide the current answer; nothing is learned permanently.

Check YourselfWhy can one wrong example in a few-shot prompt cause problems?

Because the model copies the patterns of the examples closely, including their mistakes.

Learn It on ai2hired

S0 · #7Prompting from Zero: Get Better Answers

Coming in Season 0, Start Here. Every ai2hired lesson is free on YouTube.

Questions People Ask

How many examples should a few-shot prompt have?

Usually two to five. More examples cost tokens; if you need hundreds, fine-tuning may fit better.

What is zero-shot prompting?

Asking the model to do a task with instructions only, no examples. It works for simple tasks; examples help when the format or judgment is specific.

Learn AI From Zero to Hired

Free lessons on YouTube, each one built from what real AI job ads ask for.