MulaiMulai sekarang secara gratis

Few-shot prompting: semua contoh!

Sekarang saatnya penutup! Coba tambahkan contoh Comfortable, but not very pretty = 2 ke dalam prompt. Karena contoh ini lebih moderat, contoh ini mungkin membantu model dalam ulasan kedua dari terakhir yang bermasalah.

Latihan ini adalah bagian dari kursus

Bekerja dengan OpenAI API

Lihat Kursus

Petunjuk latihan

  • Tambahkan contoh Comfortable, but not very pretty = 2 ke dalam prompt dan jalankan kembali permintaannya.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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)
Edit dan Jalankan Kode