Glossary
What is few-shot prompting?
In short
Few-shot prompting is a technique in which you add a few ready examples to the task for a neural network, and it solves a new case by their pattern.
Prompts · few-shot prompting
MMOOZZGG.com editorsChecked: 1 min read
For a child
The teacher writes three pairs of words on the board: “cat, cats”, “house, houses”, “table, tables”. Then she writes “ball” and waits for an answer. The whole class says “balls” together, because they understood the rule from the examples, even though nobody explained it. A neural network also finds it easier when it first sees a couple of solved tasks and then gets a new one.
In plain words
Sometimes a task is hard to explain in words but easy to show. Then you put a few ready “question and correct answer” pairs in the request and end with a new question without an answer. The model notices the pattern: what kind of answers there are, how long and in what form, and continues the same way. It does not need to be trained again, and the examples work only inside this request. So if you show three reviews marked “complaint” or “question”, you can get the same marks for a hundred new ones.
For business
Examples in the request give a company a stable format without the cost of training its own model: AI fills in a request card, tags customer messages and writes replies in the accepted tone. Preparation takes hours, not weeks: you only need about ten well-chosen cases from staff. The price grows with the length of the request, because each example is paid for in tokens on every call. The risks: the model copies errors and biases from the examples, and similar examples narrow the answers. So take them from real work, include hard and rare cases, and check quality on a separate set. If even this is not enough, move to fine-tuning after the pilot.
For a specialist
Few-shot prompting, or in-context learning, means putting K input and output demonstrations into the prompt before the target input, without updating the weights. Brown et al. (2020) described this mode for GPT-3 with 175 billion parameters; K was usually 10 to 100, as many as fit in a window of 2,048 tokens. Min et al. (2022) got a surprising result: replacing the correct labels in demonstrations with random ones barely lowers quality on classification and multiple-choice tasks. What works is the label space, the distribution of the input text and the overall sequence format. The order of the demonstrations, their variety and their closeness to the request also affect the result, so they are often picked by embedding similarity search. Anthropic’s guide advises 3–5 varied examples, separated from the instructions by tags.
Example
A bank wants AI to sort customer messages into five topics. One real message for each topic, with the correct label, is added to the request, and the model starts labeling the new flow in the same way.
Related terms
Questions and answers
Sources
Where companies use it
Not sure whether your company needs this?
AI solutions map