跳到主要内容

使用LLMs加法奇数

背景

这个提示通过提示LLM检查加法奇数是否加起来等于偶数来测试其数学能力。在这个例子中,我们还将利用连锁思维提示。

提示

该组中的奇数加起来等于偶数:15、32、5、13、82、7、1。
通过分步解决问题。首先,识别奇数,加起来,然后指出结果是奇数还是偶数。

代码 / API

from openai import OpenAI
client = OpenAI()

response = client.chat.completions.create(
model="gpt-4",
messages=[
{
"role": "user",
"content": "The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1. \nSolve by breaking the problem into steps. First, identify the odd numbers, add them, and indicate whether the result is odd or even."
}
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)

参考