One-shot プロンプティング:それだけで十分でしょうか?
ご覧のとおり、最初のプロンプトにはまだ改善の余地があります。Love these! = 5 という例を追加し、各レビューの後に = を加えることで、より一貫したフォーマットと正確な数値が得られるか試してみましょう。
この演習はコースの一部です
Python で DeepSeek を使いこなす
演習の手順
- プロンプトの冒頭に
Love these! = 5という例を追加し、プロンプト内の各レビューの後に=を加えて、結果をどのようにフォーマットすべきかを示します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")
# Add the example to the prompt
prompt = """Classify sentiment as 1-5 (negative to positive). Return no explanations:
1. ____
2. Unbelievably good! ____
3. Shoes fell apart on the second use. ____
4. The shoes look nice, but they aren't very comfortable. ____
5. 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)