範例提示(Shot prompting)

使用 Python 操作 DeepSeek

James Chapman

AI Curriculum Lead, DataCamp

提供範例

機器人查看範例

  • 範例提示(Shot prompting)
使用 Python 操作 DeepSeek

什麼是範例提示?

範例提示(Shot prompting):加入範例來引導 AI 回覆

$$

  • Zero-shot:無範例,只給說明
  • One-shot:單一範例引導回覆
  • Few-shot:多個範例提供更多脈絡

從零到少量範例的示意

使用 Python 操作 DeepSeek

為什麼範例提示很重要?

$$

✅ 範例提示的應用:

  • 📑 文字分類
  • 💬 情緒分析
  • 🔍 資料擷取
  • ✨ 還有更多!

範例提示的應用案例

使用 Python 操作 DeepSeek

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. 3  
2. 2
使用 Python 操作 DeepSeek

One-shot 提示

prompt = """Classify sentiment as 1-5 (bad-good) in the following statements. Return no
explanations:
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. ->
"""
2. Meal was decent, but I've had better. -> 3  
3. My food was delayed, but drinks were good. -> 2
使用 Python 操作 DeepSeek

Few-shot 提示

prompt = """Classify sentiment as 1-5 (bad-good) in the following statements. Return no
explanations:
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. ->
"""
4. Meal was decent, but I've had better. -> 3  
5. My food was delayed, but drinks were good. -> 2
使用 Python 操作 DeepSeek

一起來練習吧!

使用 Python 操作 DeepSeek

Preparing Video For Download...