P
Prompt Master
Prompt Engineering 教程与提示词实战

从任务定义、示例和工作流到评测与安全边界

Prompt Engineering 教程与提示词实战Prompt Library

Sentiment Classification

zero-shot sentiment classification prompt

本章 Prompt 决定
01要解决的 Prompt 问题

zero-shot sentiment classification prompt

02完成后带走

一份保留任务边界的可复用 Prompt、示例集、评测记录或安全规则。

03做到什么算完成

至少跑一个代表性样本,检查结果,并记录仍需人工复核的部分。

背景

这个 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
)

📚 相关资源