思维链提示
思维链 (CoT) 提示

思维链 (CoT) 提示由 Wei 等人 (2022) (在新标签页中打开) 提出,通过中间推理步骤实现复杂的推理能力。您可以将其与少样本提示结合使用,以便在需要先推理再响应的复杂任务中获得更好的结果。
提示
The odd numbers in this group add up to an even number: 4, 8, 9, 15, 12, 2, 1.
A: Adding all the odd numbers (9, 15, 1) gives 25. The answer is False.
The odd numbers in this group add up to an even number: 17, 10, 19, 4, 8, 12, 24.
A: Adding all the odd numbers (17, 19) gives 36. The answer is True.
The odd numbers in this group add up to an even number: 16, 11, 14, 4, 8, 13, 24.
A: Adding all the odd numbers (11, 13) gives 24. The answer is True.
The odd numbers in this group add up to an even number: 17, 9, 10, 12, 13, 4, 2.
A: Adding all the odd numbers (17, 9, 13) gives 39. The answer is False.
The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1.
A:
输出
Adding all the odd numbers (15, 5, 13, 7, 1) gives 41. The answer is False.
哇!当我们提供了推理步骤后,我们看到了一个完美的结果。事实上,我们可以通过提供更少的示例来解决这个任务,例如,一个示例似乎就足够了
提示
The odd numbers in this group add up to an even number: 4, 8, 9, 15, 12, 2, 1.
A: Adding all the odd numbers (9, 15, 1) gives 25. The answer is False.
The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1.
A:
输出
Adding all the odd numbers (15, 5, 13, 7, 1) gives 41. The answer is False.
请记住,作者声称这是一种新兴能力,它出现在足够大的语言模型中。
在我们的新 AI 课程中了解更多关于思维链提示和高级提示方法。 立即加入! (在新标签页中打开) 使用代码 PROMPTING20 额外享受 8 折优惠。
零样本 CoT 提示

图片来源:Kojima 等人 (2022) (在新标签页中打开)
最近出现的一个新想法是零样本 CoT (在新标签页中打开)(Kojima 等人,2022),它主要是在原始提示中添加“让我们一步步思考”。让我们试一个简单的问题,看看模型的表现如何
提示
I went to the market and bought 10 apples. I gave 2 apples to the neighbor and 2 to the repairman. I then went and bought 5 more apples and ate 1. How many apples did I remain with?
输出
11 apples
答案不正确!现在我们用特殊提示来试试。
提示
I went to the market and bought 10 apples. I gave 2 apples to the neighbor and 2 to the repairman. I then went and bought 5 more apples and ate 1. How many apples did I remain with?
Let's think step by step.
输出
First, you started with 10 apples.
You gave away 2 apples to the neighbor and 2 to the repairman, so you had 6 apples left.
Then you bought 5 more apples, so now you had 11 apples.
Finally, you ate 1 apple, so you would remain with 10 apples.
令人印象深刻的是,这个简单的提示对这项任务很有效。这在你没有太多示例可用于提示的情况下特别有用。
自动思维链 (Auto-CoT)
当使用示例应用思维链提示时,这个过程需要手工精心制作有效且多样的示例。这种手动工作可能会导致次优解。Zhang 等人 (2022) (在新标签页中打开) 提出了一种方法,通过利用带有“让我们一步步思考”提示的 LLM 逐个生成示例的推理链,从而消除手动工作。这个自动过程在生成的链中仍然可能出现错误。为了减轻错误的影响,示例的多样性至关重要。这项工作提出了 Auto-CoT,它对具有多样性的问题进行采样,并生成推理链来构建示例。
Auto-CoT 包括两个主要阶段:
- 阶段 1):问题聚类:将给定数据集中的问题划分到几个聚类中
- 阶段 2):示例采样:从每个聚类中选择一个代表性问题,并使用零样本 CoT 和简单的启发式方法生成其推理链
简单的启发式方法可以是问题的长度(例如,60 个 token)和推理步骤的数量(例如,5 个推理步骤)。这鼓励模型使用简单准确的示例。
过程如下图所示

图片来源:Zhang 等人 (2022) (在新标签页中打开)
Auto-CoT 的代码可在此处获取 (在新标签页中打开)。