链式思维提示
思维链(CoT)提示
图片来源:Wei et al. (2022) (在新标签页中打开)
在Wei等人(2022年)(在新标签页中打开)中引入的思维链(CoT)提示通过中间推理步骤实现了复杂的推理能力。你可以将其与少量示例提示结合使用,以在需要推理的复杂任务上获得更好的结果。
提示:
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.
请记住,作者声称这是一种随着足够大的语言模型而出现的新兴能力。
零样本COT提示
图片来源: Kojima et al. (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 et al. (2022) (在新标签页中打开)提出了一种方法,通过利用LLMs和“让我们一步一步思考”提示来逐一生成示范的推理链,从而消除手动工作。这种自动化过程仍然可能在生成的链中出现错误。为了减轻错误的影响,示范的多样性至关重要。这项工作提出了Auto-CoT,它通过采样具有多样性的问题并生成推理链来构建示范。
Auto-CoT 包含两个主要阶段:
- 阶段 1): 问题聚类: 将给定数据集中的问题划分为几个簇
- 阶段 2): 演示采样: 从每个集群中选择一个代表性的问题,并使用带有简单启发式的 Zero-Shot-CoT 生成其推理链
简单的启发式方法可以是问题的长度(例如,60个标记)和推理步骤的数量(例如,5个推理步骤)。这鼓励模型使用简单且准确的演示。
过程如下所示:
图片来源: Zhang et al. (2022) (在新标签页中打开)
Auto-CoT的代码可在此处获取 here (在新标签页中打开)。