DayOne
Journal
Today I Learned

Day 30 - Prompting Techniques - Chain of Thought

Chain of Thought (CoT)

Chain of Thought (CoT) prompting is a technique for improving the reasoning capabilities of LLMs by generating intermediate reasoning steps. This helps the LLM generate more accurate answers. You can combine it with few-shot prompting to get better results on more complex tasks that require reasoning before responding as it’s a challenge with a zero-shot chain of thought.

The LLM response includes the chain of thought reasoning, which means more output tokens, which means predictions cost more money and take longer.

Generally, any task that can be solved by talking through is a good candidate for a chain of thought.

Chain of Thought prompting can be very powerful when combined with a single-shot or few-shot:

Prompt

Q: When my brother was 2 years old, I was double his age. Now
I am 40 years old. How old is my brother? Let's think step
by step.

A: When my brother was 2 years, I was 2 * 2 = 4 years old.
That's an age difference of 2 years and I am older. Now I am 40
years old, so my brother is 40 - 2 = 38 years old. The answer
is 38.

Q: When I was 3 years old, my partner was 3 times my age. Now,
I am 20 years old. How old is my partner? Let's think step
by step.

A:

Output:

When I was 3 years old, my partner was 3 * 3 = 9 years old. That’s an age
difference of 6 years and my partner is older. Now I am 20 years old, so my
partner is 20 + 6 = 26 years old. The answer is 26.