Few-shot Prompting: เพิ่มตัวอย่างให้ครบ!
มาถึงขั้นตอนสุดท้ายแล้ว! ลองเพิ่มตัวอย่าง Comfortable, but not very pretty = 2 เข้าไปในพรอมต์ ตัวอย่างนี้มีความพอดีอยู่กลางๆ จึงอาจช่วยให้โมเดลรับมือกับรีวิวที่มีปัญหาในตำแหน่งที่สองจากท้ายได้ดีขึ้น
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การทำงานกับ OpenAI API
คำแนะนำการฝึกหัด
- เพิ่มตัวอย่าง
Comfortable, but not very pretty = 2เข้าไปในพรอมต์ แล้วรันคำขออีกครั้ง
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
client = OpenAI(api_key="")
# Add the final example
prompt = """Classify sentiment as 1-5 (negative to positive):
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="gpt-4o-mini", messages=[{"role": "user", "content": prompt}], max_completion_tokens=100)
print(response.choices[0].message.content)