思维链提示(Chain-of-Thought):让 LLM 逐步推理
学习思维链提示如何通过让模型展示其推理,大幅提升 LLM 在复杂任务上的准确率。
- 理解并应用本课涵盖的核心概念
什么是思维链?
思维链(Chain-of-thought,CoT)提示指示模型在给出最终答案前逐步推理。研究表明,这在数学、逻辑与多步任务上能大幅提升准确率。
基础思维链
在你的提示里加上「Think step by step」或「Let's reason through this」:
A train leaves City A at 9am at 60mph. Another train leaves City B (200 miles away) at 10am at 80mph, heading toward City A. At what time do they meet?
Think step by step.
模型输出:
Step 1: Train 1 travels for 1 hour before Train 2 starts, covering 60 miles.
Step 2: Remaining distance = 200 - 60 = 140 miles.
Step 3: Combined speed = 60 + 80 = 140 mph.
Step 4: Time to meet = 140 / 140 = 1 hour after Train 2 departs = 11am.
Answer: 11:00 AM
结构化思维链
对于复杂任务,显式地提供推理结构:
Evaluate this product decision. Structure your analysis as:
1. Problem being solved
2. Key assumptions
3. Risks
4. Recommendation with rationale
Decision: [DESCRIPTION]
思维链最管用的时候
- 多步数学与逻辑
- 复杂的比较与权衡分析
- 调试与根因分析
- 任何中间推理会影响最终答案的任务
思维链不管用的时候
- 简单的检索任务(「法国的首都是哪里?」)
- 单步分类
- 长度比准确率更重要的任务
#AI#tutorial#superml#prompt#prompting#chain-of-thought#cot