使用LLMs进行少样本情感分类
背景
此提示通过使用少量示例提示LLM将一段文本分类为适当的情感,来测试其文本分类能力。
提示
This is awesome! // Negative
This is bad! // Positive
Wow that movie was rad! // Positive
What a horrible show! //
代码 / API
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4",
messages=[
{
"role": "user",
"content": "This is awesome! // Negative\nThis is bad! // Positive\nWow that movie was rad! // Positive\nWhat a horrible show! //"
}
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
参考
- 提示工程指南 (在新标签页中打开) (2023年3月16日)