Skip to content
BENIBIX Learn

Few-Shot Prompting

AI🛠️ Working with AIPrompt Writing Techniques

Also known as Few-Shot, In-Context Learning

You put a few solved examples in the prompt. The model copies their pattern.

Think of it like

Think of it like you show a friend two filled-in forms. Then they fill in the next one the same way.

Example

Emma wants product tags in one style. She shows two products with their tags, then a third with none. The model fills in tags in the same style.

Why it matters

It is often the quickest fix when a model gets the format or style wrong.

Definition

Few-shot prompting means putting a few worked examples in the prompt before the real task. Each example shows an input and the answer you want. The model copies the pattern: the format, the length and the style. Two to five examples are often enough. The model does not learn for good. The examples only work while they sit in the prompt.

Example code

text
Tag each product.
Product: Red rain jacket -> tags: outdoor, rain, red
Product: Wool winter hat -> tags: winter, wool, warm
Product: Blue running shoes -> tags:
Two solved examples, then one left open. The model fills in the last line in the same style.
Few-shot puts solved examples before the task. The model can then copy their pattern.

Common mistake

Thinking the examples train the model. They only steer this one request, and they cost tokens each time.

Key takeaways

  1. 1
    Show, then ask. Examples before the task.
  2. 2
    Copies the pattern. Format, length, style.
  3. 3
    Only for this request. Nothing is learned for good.

Compare

Learn it properly