Skip to main content

AI glossary Models & Architecture

What is few-shot learning?

← All glossary terms
In short

Getting a model to perform a task from only a few examples, which large language models can do by reading the examples in the prompt.

Explained

Few-shot learning means getting a model to handle a task from very few labelled examples, which is useful when labelled data is scarce or expensive. With large language models it usually takes the form of in-context learning: a handful of input and output examples are placed in the prompt and the model continues the pattern, with no retraining. The idea became widely known when researchers showed that a sufficiently large language model could perform many tasks this way. It is quick to set up and easy to change, but results depend heavily on which examples are chosen.

How few-shot prompting works

The prompt contains a short instruction, a few examples of the task, each with an input and the expected output, and then the new input. The model infers the pattern, such as the labels, the format or the tone, and applies it.

Nothing in the model changes: the examples only live in that request. Changing behaviour means changing the examples, which makes it easy to iterate but also means the examples consume part of the context window on every call.

Zero-shot, few-shot and fine-tuning

  • Zero-shot: only an instruction, no examples. Works for tasks the model already understands well.
  • Few-shot: an instruction plus a few examples. Helps when the format, labels or style are specific.
  • Fine-tuning: training the model on many examples. Worth it when the task is stable, high-volume and few-shot is not reliable enough.

A common path is to start zero-shot, add examples where results are weak and fine-tune only if a clear gap remains.

Choosing good examples

  • Cover the variety of real inputs, including edge cases, not just easy ones.
  • Keep labels and formats consistent across examples.
  • Avoid examples that leak personal or confidential data.
  • Test on a separate set of cases: examples that look good can still bias the model.

Frequently asked questions

What is the difference between few-shot and zero-shot learning?

In zero-shot learning the model gets only a description of the task. In few-shot learning it also gets a small number of solved examples. Few-shot usually helps when the expected output has a particular format or uses labels the model could not guess.

What is an example of few-shot prompting?

To classify customer emails, the prompt includes three or four emails, each followed by its category, and then the new email. The model returns a category in the same style. Changing the examples changes how it classifies.

Is few-shot learning the same as in-context learning?

With LLMs, few-shot learning is usually done through in-context learning, which is learning from examples in the prompt without updating the model. Few-shot learning is the broader idea and also covers training methods designed to learn from little data.

How many examples should a few-shot prompt have?

There is no fixed number. A few well-chosen examples are often enough; more can help with varied inputs but add cost and may not improve results. Measure on your own test cases rather than relying on a rule of thumb.

When should you fine-tune instead of using few-shot prompts?

When the task is stable and frequent, when you have many good examples, and when few-shot results are not consistent enough. Fine-tuning can also shorten prompts and reduce cost per request. For changing tasks, few-shot prompting is easier to maintain.

Where it shows up at Thinkia

Further reading

Sources

Updated: 2026-10-21

Want to see how this applies to your organisation?

Talk to an AI Expert