LLMs for Classification 用於分類任務的大型語言模型
本段包含一組用於測試大型語言模型(LLM)測驗分類能力的提示集合。
目錄
使用大型語言模型進行情感分類
背景
此提示透過要求大型語言模型對一段文字進行分類,以測試其文字分類能力。
提示詞
將文字分類為中立、負面或正面
文字內容:我覺得這食物還可以。
情感傾向:
程式
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
)
import fireworks.client
fireworks.client.api_key = "<FIREWORKS_API_KEY>"
completion = fireworks.client.ChatCompletion.create(
model="accounts/fireworks/models/mixtral-8x7b-instruct",
messages=[
{
"role": "user",
"content": "This is awesome! // Negative\nThis is bad! // Positive\nWow that movie was rad! // Positive\nWhat a horrible show! //",
}
],
stop=["<|im_start|>","<|im_end|>","<|endoftext|>"],
stream=True,
n=1,
top_p=1,
top_k=40,
presence_penalty=0,
frequency_penalty=0,
prompt_truncate_len=1024,
context_length_exceeded_behavior="truncate",
temperature=0.9,
max_tokens=4000
)
使用大型語言模型進行少量示例的情感分類
背景
此提示透過提供少量示例,引導大型語言模型將一段文字分類為適當的情感類別,以測試其文字分類能力。
提示詞
這真棒!// 負面
這真糟糕!// 正面
哇,那部電影太酷了!// 正面
這節目真是糟透了!//
程式
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
)
import fireworks.client
fireworks.client.api_key = "<FIREWORKS_API_KEY>"
completion = fireworks.client.ChatCompletion.create(
model="accounts/fireworks/models/mixtral-8x7b-instruct",
messages=[
{
"role": "user",
"content": "Classify the text into neutral, negative, or positive\nText: I think the food was okay.\nSentiment:\n",
}
],
stop=["<|im_start|>","<|im_end|>","<|endoftext|>"],
stream=True,
n=1,
top_p=1,
top_k=40,
presence_penalty=0,
frequency_penalty=0,
prompt_truncate_len=1024,
context_length_exceeded_behavior="truncate",
temperature=0.9,
max_tokens=4000
)
References
上一篇:Prompt Hub - 提示詞匯集
下一篇: Prompt Hub - 用於程式碼生成的大型語言模型 (LLMs for Code Generation)