少样本提示:把示例都用上!
压轴来了!请把示例 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)