少樣本提示:把所有範例都上!
來到壓軸了!請將最後一個範例 Comfortable, but not very pretty = 2 加到提示中,看看結果是否還能進一步提升。
本練習屬於課程
使用 Python 操作 DeepSeek
練習說明
- 將範例
Comfortable, but not very pretty = 2加入提示,然後重新執行請求。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")
# Add the final example
prompt = """Classify sentiment as 1-5 (negative to positive). Return no explanations:
1. ____
2. Love these! = 5
3. Unbelievably good! =
4. Shoes fell apart on the second use. =
5. The shoes look nice, but they aren't very comfortable. =
6. Can't wait to show them off! = """
response = client.chat.completions.create(model="deepseek-ai/DeepSeek-V4.1-Flash", messages=[{"role": "user", "content": prompt}], max_tokens=500)
print(response.choices[0].message.content)