ショットプロンプティング

OpenAI APIを使いこなす

James Chapman

Curriculum Manager, DataCamp

例の提示

ロボットが例を見る

  • ショットプロンプティング
OpenAI APIを使いこなす

ショットプロンプティングとは

ショットプロンプティング:例を含めて、欲しい回答を理解させる

$$

  • ゼロショット:例なし、指示のみ
  • ワンショット:例を1つ提示する
  • フューショット:複数の例を示して、深く理解させる

ゼロショットからフューショットの表現

OpenAI APIを使いこなす

ショットプロンプティングが重要な理由

$$

✅ ショットプロンプティングの使用ケース:

  • 📑 テキスト文書の分類
  • 💬 感情分析
  • 🔍 データ抽出
  • ✨ その他いろいろ!

ショットプロンプティングの使用ケース

OpenAI APIを使いこなす

ゼロショットプロンプティング

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)
OpenAI APIを使いこなす

ワンショットプロンプティング

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
OpenAI APIを使いこなす

フューショットプロンプティング

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
OpenAI APIを使いこなす

一般的なカテゴリ分け

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
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
OpenAI APIを使いこなす

練習しましょう!

OpenAI APIを使いこなす

Preparing Video For Download...