Dualformer: Controllable Fast and Slow Thinking by Learning with Randomized Reasoning Traces
作者: DiJia Su, Sainbayar Sukhbaatar, Michael Rabbat, Yuandong Tian, Qinqing Zheng
分类: cs.AI, cs.LG, cs.LO
发布日期: 2024-10-13 (更新: 2025-07-11)
🔗 代码/项目: GITHUB
💡 一句话要点
Dualformer:通过随机推理轨迹学习,实现可控的快慢思考
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 大型语言模型 推理 Transformer 快慢思考 随机推理轨迹 迷宫求解 数学推理
📋 核心要点
- 大型语言模型(LLMs)推理存在效率与质量的权衡,需要平衡快速直觉的“系统1”和慢速审慎的“系统2”两种模式。
- Dualformer通过在训练时随机丢弃推理轨迹的不同部分,使模型能够同时学习快速和慢速两种推理模式。
- 实验表明,Dualformer在迷宫和数学推理任务上,在快速、慢速和自动模式下均优于现有模型,并提高了计算效率。
📝 摘要(中文)
本文提出Dualformer,一个单一的Transformer模型,它通过在随机推理轨迹上进行训练,无缝集成了快速和慢速两种推理模式。在训练过程中,策略性地丢弃轨迹的不同部分。在推理时,Dualformer可以轻松配置为以快速或慢速模式执行,或者自动决定采用哪种模式(自动模式)。在所有三种模式下,Dualformer在性能和计算效率方面均优于基线:(1)在慢速模式下,Dualformer在未见过的30x30迷宫任务上实现了97.6%的最优率,超过了在完整推理轨迹数据上训练的Searchformer基线(93.3%),并且推理步骤减少了45.5%;(2)在快速模式下,Dualformer实现了80%的最优率,显著优于仅在解决方案数据上训练的Solution-Only模型,其最优率仅为30%;(3)在自动模式下,Dualformer实现了96.6%的最优率,并且比Searchformer减少了59.9%的步骤。此外,Dualformer比Searchformer产生更多样化的推理轨迹。对于数学推理问题,我们的技术也通过LLM微调实现了性能提升,证明了其在特定任务模型之外的泛化能力。我们的代码已开源。
🔬 方法详解
问题定义:现有的大型语言模型在推理时,要么只输出最终结果(快速模式),要么输出完整的推理过程和最终结果(慢速模式)。快速模式效率高但准确率低,慢速模式准确率高但计算成本高。如何让模型能够根据任务需求,灵活地选择合适的推理模式,同时兼顾效率和准确率是一个挑战。
核心思路:Dualformer的核心思想是让模型同时学习快速和慢速两种推理模式,并通过随机丢弃推理轨迹的方式,迫使模型学习在信息不完整的情况下进行推理。这样,模型就可以在推理时根据需要选择合适的模式,或者自动决定采用哪种模式。
技术框架:Dualformer是一个基于Transformer的模型,其训练数据包含完整的推理轨迹。在训练过程中,随机丢弃推理轨迹的不同部分,例如只保留最终结果,或者只保留部分推理步骤。这样,模型就可以学习在不同信息量的情况下进行推理。在推理时,可以通过控制推理轨迹的完整程度来选择快速或慢速模式。自动模式则通过一个策略网络来决定采用哪种模式。
关键创新:Dualformer的关键创新在于其训练方式,即通过随机丢弃推理轨迹的方式,使模型能够同时学习快速和慢速两种推理模式。这种训练方式可以有效地提高模型的泛化能力和计算效率。此外,Dualformer还引入了自动模式,使模型能够根据任务需求自动选择合适的推理模式。
关键设计:Dualformer使用标准的Transformer架构。训练时,使用交叉熵损失函数来优化模型。随机丢弃推理轨迹的概率是一个超参数,需要根据具体任务进行调整。自动模式的策略网络可以使用强化学习或者监督学习进行训练。
🖼️ 关键图片
📊 实验亮点
Dualformer在30x30迷宫任务上,慢速模式达到97.6%的最优率,超越Searchformer的93.3%,且推理步骤减少45.5%。快速模式下,Dualformer达到80%的最优率,远超Solution-Only模型的30%。自动模式下,Dualformer达到96.6%的最优率,步骤比Searchformer减少59.9%。
🎯 应用场景
Dualformer具有广泛的应用前景,例如可以应用于需要快速响应的场景,如对话系统和搜索引擎,也可以应用于需要高准确率的场景,如医疗诊断和金融分析。此外,Dualformer还可以用于提高机器人的决策能力,使其能够根据环境的变化选择合适的行动策略。
📄 摘要(原文)
In cognition theory, human thinking is governed by two systems: the fast and intuitive System 1 and the slower but more deliberative System 2. Analogously, Large Language Models (LLMs) can operate in two reasoning modes: outputting only the solutions (\emph{fast mode}) or both the reasoning chain and the final solution (\emph{slow mode}). We present \dualformer, a single Transformer model that seamlessly integrates both the fast and slow reasoning modes by training on randomized reasoning traces, where different parts of the traces are strategically dropped during training. At inference time, \dualformer can be easily configured to execute in either fast or slow mode, or automatically decide which mode to engage (\emph{auto mode}). It outperforms baselines in both performance and computational efficiency across all three modes: (1) in slow mode, \dualformer achieves $97.6\%$ optimal rate on unseen $30 \times 30$ maze tasks, surpassing the \searchformer baseline ($93.3\%$) trained on data with complete reasoning traces, with $45.5\%$ fewer reasoning steps; (2) in fast mode, \dualformer achieves $80\%$ optimal rate, significantly outperforming the Solution-Only model trained on solution-only data, which has an optimal rate of only $30\%$; (3) in auto mode, \dualformer achieves $96.6\%$ optimal rate with $59.9\%$ fewer steps than \searchformer. Moreover, \dualformer produces more diverse reasoning traces than \searchformer{}. For math reasoning problems, our techniques have also achieved improved performance with LLM fine-tuning, demonstrating its generalization beyond task-specific models. We open source our code at https://github.com/facebookresearch/dualformer.