Shot prompting

Lucrul cu OpenAI API

James Chapman

Curriculum Manager, DataCamp

Furnizarea de exemple

Un robot privește exemple

  • Shot prompting
Lucrul cu OpenAI API

Ce este shot prompting-ul?

Shot prompting: includerea de exemple pentru a ghida răspunsurile AI

$$

  • Zero-shot: fără exemple, doar instrucțiuni
  • One-shot: un singur exemplu ghidează răspunsul
  • Few-shot: mai multe exemple oferă context suplimentar

Reprezentare de la zero la câteva exemple

Lucrul cu OpenAI API

De ce contează shot prompting-ul?

$$

✅ Cazuri de utilizare a shot prompting-ului:

  • 📑 Clasificare text
  • 💬 Analiza sentimentelor
  • 🔍 Extragerea datelor
  • ✨ ... și multe altele!

Cazuri de utilizare a shot prompting-ului

Lucrul cu OpenAI API

Prompting fără exemple (zero-shot)

prompt = """Classify sentiment as 1-5 (bad-good) in the following statements:
1. Meal was decent, but I've had better.
2. My food was delayed, but drinks were good.
"""

...
1. Meal was decent, but I've had better. - 3 (Neutral)
2. My food was delayed, but drinks were good. - 3 (Neutral)
Lucrul cu OpenAI API

Prompting cu un singur exemplu

prompt = """Classify sentiment as 1-5 (bad-good) in the following statements:
1. The service was very slow -> 1
2. Meal was decent, but I've had better. ->
3. My food was delayed, but drinks were good. ->
"""
1. The service was very slow -> 1
2. Meal was decent, but I've had better. -> 3
3. My food was delayed, but drinks were good. -> 4
Lucrul cu OpenAI API

Prompting cu câteva exemple

prompt = """Classify sentiment as 1-5 (bad-good) in the following statements:
1. The service was very slow -> 1
2. The steak was awfully good! -> 5
3. It was ok, no massive complaints. -> 3
4. Meal was decent, but I've had better. ->
5. My food was delayed, but drinks were good. ->
"""
1. The service was very slow -> 1
2. The steak was awfully good! -> 5
3. It was ok, no massive complaints. -> 3
4. Meal was decent, but I've had better. -> 4
5. My food was delayed, but drinks were good. -> 3
Lucrul cu OpenAI API

Categorizare generală

prompt = """Classify the following animals as Land, Sea, or Both:
1. Blue whale
2. Polar bear
3. Salmon
4. Dog
"""
1. **Blue whale** - Sea
2. **Polar bear** - Both (primarily land but is a marine mammal that lives in sea ice)
3. **Salmon** - Both (spends part of its life in freshwater and part in the ocean)
4. **Dog** - Land
Lucrul cu OpenAI API
prompt = """Classify the following animals as Land, Sea, or Both:
1. Zebra = Land
2. Crocodile = Both
3. Blue whale = 
4. Polar bear = 
5. Salmon = 
6. Dog = 
"""
1. Zebra = Land
2. Crocodile = Both
3. Blue whale = Sea
4. Polar bear = Both
5. Salmon = Sea
6. Dog = Land
Lucrul cu OpenAI API

Să exersăm!

Lucrul cu OpenAI API

Preparing Video For Download...