logo
P
Prompt Master

Prompt 大师

掌握和 AI 对话的艺术

Sentiment Classification

zero-shot sentiment classification prompt

背景

这个 prompt 用于测试 LLM 的 classification 能力:把一段文本分类为 neutral / negative / positive

prompt

Classify the text into neutral, negative, or positive
Text: I think the food was okay.
Sentiment:

template

Classify the text into neutral, negative, or positive
Text: {input}
Sentiment:

API (example)

GPT-4 (OpenAI)

from openai import OpenAI
client = OpenAI()

response = client.chat.completions.create(
    model="gpt-4",
    messages=[
        {
            "role": "user",
            "content": "Classify the text into neutral, negative, or positive\nText: I think the food was okay.\nSentiment:\n"
        }
    ],
    temperature=1,
    max_tokens=256,
    top_p=1,
    frequency_penalty=0,
    presence_penalty=0
)