PaPoo
cover

What is few-shot prompting?

Few-shot prompting, also called in-context learning, is a way of asking a language model to do a task by giving it a few example inputs and outputs in the prompt.

Why it matters

Few-shot prompting helps when you want the model to follow a pattern, format, or classification rule without training or fine-tuning a new model.

You’d reach for it when:

In practice, many teams start here because it is fast, cheap to test, and easy to change.

How it works

The basic idea is that the model sees examples inside the prompt and uses them as context for the next answer. This is why it is often described as in-context learning: the model is not updated; it is inferring the pattern from the prompt itself.

A few-shot prompt usually includes:

  1. A short instruction.
  2. A small set of labeled examples.
  3. The new input you want the model to handle.

The examples act like a miniature specification. If they are clear and consistent, the model can mimic the style, structure, or decision rule you showed it.

This is different from training: nothing is permanently learned. The behavior applies only to that prompt and that conversation.

Tiny concrete example

Prompt:

Classify the sentiment as Positive or Negative.

Text: "The delivery arrived early and the product works great."
Sentiment: Positive

Text: "The app crashes every time I open it."
Sentiment: Negative

Text: "Support was helpful and resolved my issue quickly."
Sentiment:

Likely completion:

Positive

Common pitfalls / when NOT to use it

Related terms

Related terms

同じ著者の記事