Chain-of-Thought Prompting

Chain-of-Thought Prompting

關聯思考提示

Chain-of-Thought (CoT) Prompting

關聯思考(CoT)提示

COT

Image Source: Wei et al. (2022) (opens in a new tab)

圖片來源:Wei et al. (2022) (opens in a new tab)

Introduced in Wei et al. (2022) (opens in a new tab), chain-of-thought (CoT) prompting enables complex reasoning capabilities through intermediate reasoning steps. You can combine it with few-shot prompting to get better results on more complex tasks that require reasoning before responding.

引入自Wei et al. (2022) (opens in a new tab)的思路鏈(CoT)提示,透過中間推理步驟實現複雜的推理能力。您可以將其與少量樣本提示結合使用,以獲得更好的結果,以應對需要在回答之前進行推理的更複雜任務。

Prompt:

提示:

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:

Output:

輸出:

Adding all the odd numbers (15, 5, 13, 7, 1) gives 41. The answer is False.

Wow! We can see a perfect result when we provided the reasoning step. In fact, we can solve this task by providing even fewer examples, i.e., just one example seems enough:

哇!當我們提供了推理步驟時,我們可以看到完美的結果。事實上,我們可以透過提供更少的示範來解決這個任務,即只需一個示範似乎就足夠了:

Prompt:

提示:

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:

Output:

輸出:

Adding all the odd numbers (15, 5, 13, 7, 1) gives 41. The answer is False.

Keep in mind that the authors claim that this is an emergent ability that arises with sufficiently large language models.

請記住,作者聲稱這是一種新興的能力,是由足夠大的語言模型產生的。

Zero-shot COT Prompting

zero-shot COT Prompting

Zero-shot COT
zero-shot COT

Image Source: Kojima et al. (2022) (opens in a new tab)

圖片來源:Kojima et al. (2022) (opens in a new tab)

One recent idea that came out more recently is the idea of zero-shot CoT (opens in a new tab) (Kojima et al. 2022) that essentially involves adding "Let's think step by step" to the original prompt. Let's try a simple problem and see how the model performs:

最近提出的一個新想法是zero-shot CoT (opens in a new tab)(Kojima等人,2022年),其基本上是在原始提示中新增“讓我們一步一步地思考”。讓我們試著解決一個簡單的問題,看看模型的表現如何:

Prompt:

提示:

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?

Output:

輸出:

11 apples

The answer is incorrect! Now Let's try with the special prompt.

答案不正確!現在讓我們嘗試使用特殊提示。

Prompt:

提示:

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.

Output:

輸出:

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.

It's impressive that this simple prompt is effective at this task. This is particularly useful where you don't have too many examples to use in the prompt.

這個簡單的提示能夠有效地完成這個任務,令人印象深刻。這在你沒有太多提示例子可用的情況下特別有用。