Search

Chain-of-Thought Reasoning

In prompt engineering, chain-of-thought refers to a technique for prompting large language models (LLMs) to solve problems by explicitly guiding them through a series of intermediate steps. This forces the LLM to reason about the problem rather than simply answering using its default pipeline of reasoning. This leads to more accurate and transparent results.

Note: We use Chain-of-thought prompting and Chain-of-thought reasoning interchangeably, although there is the obvious subtle difference.

Example:

The following examples have been taken from this publication: https://arxiv.org/pdf/2311.09277.pdf. I have added color commentary to make it easier to follow in this glossary format.

First we demonstrate how it behaves without chain-of-thought prompting. Then, we demonstrate the same scenario with chain-of-thought prompting.

Bard’s output WITHOUT chain-of-thought prompting: ( You can see it in action by clicking on this public prompt: https://g.co/bard/share/f0c538aa9082. Generated on 12-17-23)

I entered this prompt:

Question: James has 30 teeth. His dentist drills 4 of them and caps 7 more teeth than he drills. What percentage of James’ teeth does the dentist fix?

Bard’s response:

Sure, I can help with that.

First find the total number of teeth the dentist fixes: 7 teeth + 4 teeth = 11 teeth

Then divide the number of teeth fixed by the total number of teeth and multiply by 100% to express the answer as a percentage: 11 teeth / 30 teeth * 100% = 36.67%

So the answer is 36.67

 

Bard’s output WITH chain-of-thought prompting:

(You can see it in action by clicking on this public prompt: https://g.co/bard/share/72deb73c21b7. Generated on 12-17-23)

I entered this prompt:

Question : James writes a 3-page letter to 2 different friends twice a week. How many pages does he write a year? 

Explanation: He writes each friend 3*2=6 pages a week. So he writes 6*2=12 pages every week. That means he writes 12*52=624 pages a year. 

Wrong Explanation: He writes each friend 12*52=624 pages a week. So he writes 3*2=6 pages every week. That means he writes 6*2=12 pages a year. 

Question: James has 30 teeth. His dentist drills 4 of them and caps 7 more teeth than he drills. What percentage of James’ teeth does the dentist fix?

 

Bard’s response:

You’re right, the second explanation for the first question is incorrect. Here’s the corrected explanation:

* James writes 3 pages to each friend, twice a week, so that’s 3 pages/friend * 2 times/week = 6 pages/friend/week.

* He writes to 2 friends, so that’s 6 pages/friend/week * 2 friends = 12 pages/week.

* In a year, he writes 12 pages/week * 52 weeks/year = 624 pages.

Therefore, James writes 624 pages a year, not 12.

For the second question, your explanation is correct. Here’s a summary:

* The dentist drills 4 teeth.

* The dentist caps 7 more teeth than he drills, so 4 drilled teeth + 7 capped teeth = 11 capped teeth.

* In total, the dentist fixes 4 drilled teeth + 11 capped teeth = 15 teeth.

* James has 30 teeth, so the dentist fixes 15 fixed teeth / 30 total teeth * 100% = 50% of his teeth.

So, the dentist fixes 50% of James’ teeth, not 37.5%.

I hope this clarifies things! Let me know if you have any other questions.

Analysis

Even for a human, the sentence “His dentist drills 4 of them and caps 7 more teeth than he drills” is ambiguous. “Is every tooth that is drilled also capped?” is a question that is not clear in the prompt that was supplied. Therefore it is natural to see the LLM also not be able to give us a clear answer at the first go. LLMs are undergoing rapid improvements. With newer releases of LLMs I expect that the need for careful chain-of-thought will diminish.

See Also: Prompt Chaining

<< Return to Glossary

Subscribe to our newsletter

Join over 1,000+ other people who are mastering AI in 2024

You will be the first to know when we publish new articles

Subscribe to our newsletter

Join over 1,000+ other people who are mastering AI in 2024