Bắt đầu ngayBắt đầu miễn phí

Few-shot prompting: thêm mọi ví dụ!

Giờ đến màn kết! Hãy thử thêm ví dụ Comfortable, but not very pretty = 2 vào prompt. Vì đây là ví dụ ở mức độ trung bình hơn, nó có thể giúp mô hình xử lý bài đánh giá áp chót đang gây khó.

Bài tập này là một phần của khóa học

Làm việc với OpenAI API

Xem khóa học

Hướng dẫn bài tập

  • Thêm ví dụ Comfortable, but not very pretty = 2 vào prompt và chạy lại yêu cầu.

Bài tập tương tác thực hành trực tiếp

Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.

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)
Chỉnh sửa và Chạy Mã