Few-shotプロンプティング:すべての例を使う
いよいよ最終段階です。プロンプトに最後の例として 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)