Compete in HackAPrompt 2.0, the world's largest AI Red-Teaming competition!

Check it out โ†’
Prompt Engineering Guide
๐Ÿ˜ƒ Basics
๐Ÿ’ผ Applications
๐Ÿง™โ€โ™‚๏ธ Intermediate
๐Ÿค– ะะณะตะฝั‚ั‹
โš–๏ธ Reliability
๐Ÿ–ผ๏ธ Image Prompting
๐Ÿ”“ Prompt Hacking
๐Ÿ”จ Tooling
๐Ÿ’ช Prompt Tuning
๐ŸŽฒ Miscellaneous
๐Ÿ“š Bibliography
Resources
๐Ÿ“ฆ Prompted Products
๐Ÿ›ธ Additional Resources
๐Ÿ”ฅ Hot Topics
โœจ Credits
๐Ÿง™โ€โ™‚๏ธ Intermediate๐ŸŸข Chain of Thought Prompting

Chain of Thought Prompting

๐ŸŸข This article is rated easy
Reading Time: 2 minutes
Last updated on August 7, 2024

Sander Schulhoff

Chain of Thought (CoT) prompting is a recently developed prompting method, which encourages the LLM to explain its reasoning. The below image shows a few shot standard prompt (left) compared to a chain of thought prompt (right).

Regular Prompting vs CoT (Wei et al.)

The main idea of CoT is that by showing the LLM some few shot exemplars where the reasoning process is explained in the exemplars, the LLM will also show the reasoning process when answering the prompt. This explanation of reasoning often leads to more accurate results.

Example

Here are a few demos. The first shows GPT-3 (davinci-003) failing to solve a simple word problem. The second shows GPT-3 (davinci-003) succesfully solving the same problem, by using CoT prompting.

Incorrect

Correct

Results

CoT has been shown to be effective in improving results on tasks like arithmetic, commonsense, and symbolic reasoning tasks. In particular, prompted PaLM 540B achieves 57% solve rate accuracy on GSM8K (SOTA at the time).

Comparison of models on the GSM8K benchmark (Wei et al.)

Limitations

Importantly, according to Wei et al., "CoT only yields performance gains when used with models of โˆผ100B parameters". Smaller models wrote illogical chains of thought, which led to worse accuracy than standard prompting. Models usually get performance boosts from CoT prompting in a manner proportional to the size of the model.

Notes

No language models were hurt finetuned in the process of writing this chapter ๐Ÿ˜Š.

Sander Schulhoff

Sander Schulhoff is the CEO of HackAPrompt and Learn Prompting. He created the first Prompt Engineering guide on the internet, two months before ChatGPT was released, which has taught 3 million people how to prompt ChatGPT. He also partnered with OpenAI to run the first AI Red Teaming competition, HackAPrompt, which was 2x larger than the White House's subsequent AI Red Teaming competition. Today, HackAPrompt partners with the Frontier AI labs to produce research that makes their models more secure. Sander's background is in Natural Language Processing and deep reinforcement learning. He recently led the team behind The Prompt Report, the most comprehensive study of prompt engineering ever done. This 76-page survey, co-authored with OpenAI, Microsoft, Google, Princeton, Stanford, and other leading institutions, analyzed 1,500+ academic papers and covered 200+ prompting techniques.

Footnotes

  1. Wei, J., Wang, X., Schuurmans, D., Bosma, M., Ichter, B., Xia, F., Chi, E., Le, Q., & Zhou, D. (2022). Chain of Thought Prompting Elicits Reasoning in Large Language Models. โ†ฉ โ†ฉ2 โ†ฉ3

  2. Chowdhery, A., Narang, S., Devlin, J., Bosma, M., Mishra, G., Roberts, A., Barham, P., Chung, H. W., Sutton, C., Gehrmann, S., Schuh, P., Shi, K., Tsvyashchenko, S., Maynez, J., Rao, A., Barnes, P., Tay, Y., Shazeer, N., Prabhakaran, V., โ€ฆ Fiedel, N. (2022). PaLM: Scaling Language Modeling with Pathways. โ†ฉ

  3. Cobbe, K., Kosaraju, V., Bavarian, M., Chen, M., Jun, H., Kaiser, L., Plappert, M., Tworek, J., Hilton, J., Nakano, R., Hesse, C., & Schulman, J. (2021). Training Verifiers to Solve Math Word Problems. โ†ฉ