One-shot prompting: เพียงพอหรือไม่?
จากที่เห็น พรอมต์เริ่มต้นของเรายังมีจุดที่ปรับปรุงได้ ลองเพิ่มตัวอย่าง Love these! = 5 และใส่ = หลังรีวิวแต่ละรายการ เพื่อดูว่าจะช่วยให้รูปแบบผลลัพธ์สม่ำเสมอขึ้นและตัวเลขแม่นยำขึ้นหรือไม่
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การใช้งาน DeepSeek ใน Python
คำแนะนำการฝึกหัด
- เพิ่มตัวอย่าง
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-Pro", messages=[{"role": "user", "content": prompt}], max_tokens=500)
print(response.choices[0].message.content)