From: aidotengineer
Chain of Thought prompting is a revolutionary technique in prompt engineering, particularly impactful for its efficiency in test time compute [00:00:30].
What is Chain of Thought Prompting?
Chain of Thought prompting involves instructing a language model to reason or “think” about a problem or solution before directly providing the final answer [00:02:27]. This approach breaks down complex problems into smaller, manageable sub-problems [00:02:38].
Benefits of Chain of Thought Prompting
- Troubleshooting Insights: It provides a glimpse into the model’s thought process, which can be valuable for troubleshooting and understanding its output [00:02:41].
- Wide Applicability: It is widely applicable across various models [00:02:47].
- Ease of Implementation: This technique is relatively easy to implement [00:02:51].
- Built-in Capability: It is so powerful that it is now being integrated into reasoning models, making explicit instruction often unnecessary for those models [00:02:52].
Implementation Methods
Zero-Shot Chain of Thought
The classic zero-shot method involves adding a simple phrase to your prompt that encourages the model to think before generating the output [00:03:00]. This prompts the model to generate a “reasoning token” beforehand [00:03:07]. Common phrases include:
- “think step by step” [00:03:08]
- “take a breath and take it through things” [00:03:10]
Few-Shot Chain of Thought
Another popular method is to provide few-shot examples that demonstrate the desired reasoning steps [00:03:17]. For instance, when solving math problems, you can include another math problem in the prompt, showing the step-by-step reasoning process you want the model to mimic [00:03:22].
Automated Chain of Thought
Large Language Models (LLMs) can also be used to generate these reasoning chains automatically [00:03:30].
- Automatic Chain of Thought: A more involved framework that uses LLMs to generate reasoning chains [00:03:33].
- Auto-Reason: A single prompt where you pass your task or question, and it generates reasoning chains, often including few-shot examples of these chains [00:03:39]. This can be tried out on Prompt Hub [00:03:49].
- Training Templates: DeepSeek’s R1 model training template generated its thinking process within “think” tags, then used these generated reasoning chains to train the model for effective Chain of Thought capabilities [00:03:53]. This template is also available on Prompt Hub [00:04:07].
When to Use Chain of Thought Prompting
Chain of Thought prompting is especially helpful when dealing with complex problems [00:04:31].
Chain of Thought with Reasoning Models
Reasoning models are different in how they work and how they are prompted [00:06:51]. While Chain of Thought prompting is beneficial, providing additional examples (as in few-shot prompting) can sometimes degrade performance with these models [00:07:09]. Researchers at Microsoft (with their MedPrompt framework) and DeepSeek (with R1) observed this phenomenon, where few-shot examples led to worse performance [00:07:00]. OpenAI also noted that overcomplicating context can confuse the model [00:07:18].
For reasoning models, strategies include:
- Minimal Prompting: Focus on a clear task description [00:08:09].
- Encourage Reasoning: If encountering performance issues, encouraging the model to reason more can be helpful [00:08:17]. Research shows that more reasoning often leads to better output and increased accuracy [00:07:34].
- Avoid Excessive Few-Shot Prompting: If using few-shot examples, start with only one or two [00:08:24].
- No Explicit Reasoning Instructions: Avoid instructing the model how to reason, as it’s built-in, and doing so can hurt performance [00:08:32].
Resources
A wide range of Chain of Thought and other reasoning model templates are available for free on Prompt Hub [00:02:21]. There are also articles on the Prompt Engineering Substack and blog posts that provide further information [00:08:41].