What it is
Chain-of-thought prompting asks a language model to write out its intermediate reasoning steps before the final answer. Wei and colleagues showed that giving a few worked examples with the reasoning written out improves results on arithmetic, common-sense and symbolic problems for large enough models. Newer models are trained to reason this way by themselves.
What it is for
Multi-step problems: maths, logic puzzles, planning, code debugging, questions where the answer depends on several facts. It also makes the answer easier for you to check, since you can read the steps. The written steps are not always a faithful picture of how the model got there, so do not treat them as proof.
How to do it
- State the problem completely and ask for step-by-step reasoning before the answer ("think through it step by step, then give the final answer on its own line").
- For harder or unusual tasks, add one or two worked examples showing the style of reasoning you want.
- Read the steps and find the first wrong one; a single early error spoils everything after it.
- Ask the model to check its own result, or compute it a second way, or use a tool such as a calculator for exact arithmetic.
- Compare several attempts: if the answers differ, trust the one most attempts reach and look again at the disagreements.
- For simple questions skip it: extra reasoning costs time and money and can add confusion.