qvib.pro
RU

Few-shot: teach AI with 2–3 samples

What for: set the answer format and style with input → output samples when words fail — tagging, classification, a single tone.

бесплатно профи

Техника: few-shot learning (Brown et al., 2020) checked 2026-06-01

Updated: 02.07.2026

$ Do the task STRICTLY following the samples below — reproduce their logic and …
Few-shot: teach AI with 2–3 samples

When to use it

When the format or style of the answer is easier to show than to describe: tagging, classification into your own categories, a consistent tone, a specific template. Result: the model copies the logic of the samples and returns the answer in exactly the shape you need.

The prompt (copy and paste)

Do the task STRICTLY following the samples below — reproduce their logic and format.

Sample 1:
Input: "<PASTE SAMPLE INPUT 1>"
Output: "<PASTE THE IDEAL OUTPUT 1>"

Sample 2:
Input: "<PASTE SAMPLE INPUT 2>"
Output: "<PASTE THE IDEAL OUTPUT 2>"

Now handle this one the same way:
Input: "<PASTE THE REAL INPUT>"
Output:

The technique: 2–3 samples (few-shot) pin the format down far more reliably than a long verbal description.

Filled-in example

The task — turn customer reviews into a CRM line. Sample 1: Input "Delivered a day late, but the product is fine" → Output "sentiment: mixed | issue: logistics | action: apologise for the delay". Sample 2: Input "Everything's great, thanks!" → Output "sentiment: positive | issue: none | action: say thank you". Real input: "The manager was rude, I'm cancelling the order".

Expected AI answer: "sentiment: negative | issue: service/communication | action: escalate to a manager" — exactly in the format of the samples.

Variations

  • Negative example. Add "Bad output (do NOT do this): …" — to cut off a typical mistake.
  • One-shot. Sometimes one very precise sample is enough — it saves tokens.
  • Few-shot + persona. Role first, samples second — the format holds even tighter.

Pro tips

  • The samples must cover DIFFERENT cases (positive/negative/edge), otherwise the model concludes only one type exists.
  • Watch the balance: if every sample is labelled "positive", the model will slap "positive" on negatives too.
  • Strong models (Claude, the GPT-4 class) often need just 1–2 samples; weaker ones need 3–5. Extra samples burn context for nothing.

Читать по-русски →