💬

Few Shots Prompting

Prompt Engineering Intermediate 1 min read 0 words

Few Shots Prompting

Definiție

Few Shots Prompting (sau Few Shot Learning) este o tehnică în care furnizezi modelului câteva exemple de input-output înainte de a-i cere să proceseze un input nou.

Structura Pattern-ului

[Exemplu 1: InputOutput]
[Exemplu 2: InputOutput]
[Exemplu 3: InputOutput]
...
[Input nou]
[Output: ?]

Exemplu: Clasificare sentiment

Input: The movie was good but a bit too long
Sentiment: Neutral

Input: I didn't really like this book, it lacked important
details and didn't end up making sense
Sentiment: Negative

Input: I loved this book, it was really helpful in learning
how to improve my gut health
Sentiment: Positive

Input: I wasn't sure what to think of this new restaurant,
the service was slow, but the dishes were pretty good
Sentiment:

Rezultat așteptat:

Sentiment: Neutral

Exemplu: Raționament matematic

The odd numbers in this group add up to an even number: 4, 8, 9, 15, 12, 2, 1.
A: The answer is False.

The odd numbers in this group add up to an even number: 17, 10, 19, 4, 8, 12, 24.
A: The answer is True.

The odd numbers in this group add up to an even number: 16, 11, 14, 4, 8, 13, 24.
A: The answer is True.

The odd numbers in this group add up to an even number: 17, 9, 10, 12, 13, 4, 2.
A: The answer is False.

The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1.
A:

Ce învață modelul din exemple:

  1. Formatul răspunsului (True/False)
  2. Pattern-ul de raționament
  3. Sarcina exactă (suma numerelor impare)

Câte exemple să folosești?

Număr Denumire Când să folosești
0 Zero Shot Sarcini simple, standard
1-2 One/Two Shot Sarcini clare, format specific
3-5 Few Shot Echilibru precizie/tokeni
5+ Many Shot Sarcini complexe, precizie maximă

De ce funcționează?

In-context learning:

Modelul învață din context pattern-ul dorit:

  1. Analizează exemplele
  2. Extrage regula implicită
  3. Aplică regula la input nou

Avantaje față de Zero Shot:

Zero Shot Few Shot
Bazat pe cunoștințe generale Ghidat de exemple specifice
Format imprevizibil Format consistent
Poate rata nuanțe Captează nuanțe din exemple

Bune practici pentru exemple

1. Diversitate

  • Include exemple din categorii diferite
  • Acoperă cazuri limită

2. Consistență

  • Folosește același format pentru toate exemplele
  • Menține stilul constant

3. Relevanță

  • Exemplele să fie similare cu input-ul real
  • Evită exemple confuze sau ambigue

4. Ordine

  • Plasează exemplele în ordine logică
  • Ultima exemplu să fie cel mai relevant

Variații avansate

Few Shot cu explicații:

Input: 4, 8, 9, 15
A: Odd numbers are 9, 15. Sum = 24 (even). Answer: True.

Input: 3, 7, 2
A:

Few Shot cu contra-exemple:

Good review: "Amazing product!" → Positive
Bad review: "Terrible experience" → Negative
Neutral review: "It's okay" → Neutral
Confusing but actually positive: "Not bad at all!" → Positive

Review: "Could have been worse"
Sentiment:

Limitări

  1. Consum de tokeni - exemplele ocupă din context
  2. Bias - exemplele pot introduce bias
  3. Overfitting - modelul poate copia prea literal
  4. Selecție - alegerea exemplelor afectează rezultatul

De reținut

Few Shots Prompting este una dintre cele mai eficiente tehnici pentru a ghida modelul către output-ul dorit. Calitatea și diversitatea exemplelor sunt critice pentru succes.

Întrebări de verificare

  1. Care este diferența principală între Zero Shots și Few Shots?
  2. Câte exemple sunt suficiente pentru Few Shots?
  3. Ce caracteristici trebuie să aibă exemplele bune?
  4. Care sunt limitările Few Shots Prompting?

📚 Related Articles