logo
P
Prompt Master

Prompt 大师

掌握和 AI 对话的艺术

Sentiment Classification

Zero-shot sentiment classification prompt

Background

This prompt tests an LLM's classification ability: categorize a piece of text as 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
)