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.
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.
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:
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.
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