↓ 跳过正文

由简入繁提示词(Least-to-Most):拆解复杂推理的实用指南

·738 字·2 分钟·
Rafael Yu
作者
Rafael Yu
软件开发者 & AI 爱好者
目录

什么是 Least-to-Most(由简入繁)提示词?
#

本质上,这是一种两阶段推理方法(在部分场景下也可以合并进单个提示词中完成):

  • 第一步:把复杂问题拆解成若干更简单的子问题;
  • 第二步:按顺序逐一求解子问题,并将前一步的结论作为下一步的上下文。

单轮提示词示例
#

Q: 约翰用积木搭一座塔需要 3 分钟,推倒需要 2 分钟。游戏时间还有 20 分钟结束,他在结束前最多可以搭好并推倒几次? A: 要解决「约翰在游戏时间结束前可以搭好并推倒几次」这个问题,我们需要:

  • 先计算完成一个完整周期(搭塔 + 推倒)所需的总时间;
  • 再计算 20 分钟内最多能完成几个完整周期。

Q: 艾米爬上滑梯顶部需要 4 分钟,滑下来需要 1 分钟。水上滑梯 15 分钟后关闭,她在关闭前最多能滑几次? A:

相比普通的思维链(CoT),我更喜欢这种方法,因为它会显式地把大问题拆成可控的小步骤,几乎可以迁移到任何复杂任务上。而且在多项对比实验中,Least-to-Most 的表现也稳定优于常规思维链。

可直接复用的三段式提示词模板
#

我整理了 3 条通用提示词,你可以直接套用到任何复杂问题上:

模板 1:生成用于演示「如何拆解问题」的 Few-Shot 示例
#

Your job is to generate few-shot examples for the following task: {{ task }}

Your few-shot examples should contain two parts: A problem, and the decomposed subproblems. It should follow the structure below:

"""
Problem: Problem description

Decomposed subproblems:
- Subproblem 1
- Subproblem 2
- Subproblem 3
"""

Your output should contain only the examples, no preamble.

模板 2:将当前任务拆解为子问题(附带模板 1 生成的示例)
#

{{ task }}

List only the decomposed subproblems that must be solved before solving the task listed above. Your output should contain only the decomposed subproblems, no preamble.

Here are a few examples of problems and their respective decomposed subproblems: {{ few-shot-examples }}

模板 3:传入子问题列表并逐步求解最终任务
#

Solve the following task by addressing the subproblems listed below.

Task: {{ task }}
Subproblems: {{ sub-problems }}

相关推理技巧
#