Sentiment Classification
zero-shot sentiment classification prompt
#背景
这个 prompt 用于测试 LLM 的 classification 能力:把一段文本分类为
neutralnegativepositive#prompt
textClassify the text into neutral, negative, or positive Text: I think the food was okay. Sentiment:
#template
textClassify the text into neutral, negative, or positive Text: {input} Sentiment:
#API (example)
#GPT-4 (OpenAI)
pythonfrom 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 )