示例提示

在 Python 中使用 DeepSeek

James Chapman

AI Curriculum Lead, DataCamp

提供示例

一个机器人在看示例

  • 示例提示
在 Python 中使用 DeepSeek

什么是示例提示?

示例提示:用示例引导 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

Vamos praticar!

在 Python 中使用 DeepSeek

Preparing Video For Download...