让大模型在写代码和文字推理间智能切换,提升任务解决效率
Steering Large Language Models between Code Execution and Textual Reasoning
- 设计三种方法引导模型在代码与文本推理间精准切换
- 发现模型越复杂反而越少用代码,出现反向缩放现象
- 适用于需要高效执行复杂任务的AI研发人员
尽管近期研究聚焦于通过优化多智能体框架或推理链来增强大语言模型(LLM)的文字推理能力,但多项基准任务可通过直接编程100%解决,更具可扩展性且避免了文字迭代与搜索带来的计算开销。文字推理在数学、逻辑、优化和搜索类任务上存在固有局限,仅靠模型和数据规模扩大难以突破。OpenAI GPT Code Interpreter及AutoGen等多智能体框架已展示出整合代码生成与执行的强大能力。然而,在7种主流方法、14个任务、6种LLM(含O1-preview)的单轮与多轮实验中,目前尚无最优方法能准确引导模型在需要时生成代码。我们发现,随着任务复杂度和模型规模增加,模型使用代码的倾向反而下降,呈现出惊人的反向缩放行为。此外,即使任务可由代码解决,模型生成的代码结果也未必优于纯文字推理。为此,我们提出三种改进方法,显著提升代码/文本生成的引导效果,并系统分析了各类方法的词元长度与运行时间成本。我们认为,如何有效引导大模型进行代码与文本生成是未来研究的关键课题,仍有巨大优化空间。项目主页、数据集与代码见 https://yongchao98.github.io/CodeSteer/。
原文摘要 · Abstract (English)
While a lot of recent research focuses on enhancing the textual reasoning capabilities of Large Language Models (LLMs) by optimizing the multi-agent framework or reasoning chains, several benchmark tasks can be solved with 100\% success through direct coding, which is more scalable and avoids the computational overhead associated with textual iterating and searching. Textual reasoning has inherent limitations in solving tasks with challenges in math, logics, optimization, and searching, which is unlikely to be solved by simply scaling up the model and data size. The recently released OpenAI GPT Code Interpreter and multi-agent frameworks such as AutoGen have demonstrated remarkable proficiency of integrating code generation and execution to solve complex tasks using LLMs. However, based on our experiments on 7 existing popular methods for steering code/text generation in both single- and multi-turn settings with 14 tasks and 6 types of LLMs (including the new O1-preview), currently there is no optimal method to correctly steer LLMs to write code when needed. We discover some interesting patterns on when models use code vs. textual reasoning with the evolution to task complexity and model sizes, which even result in an astonishingly inverse scaling behavior. We also discover that results from LLM written code are not always better than using textual reasoning, even if the task could be solved through code. To mitigate the above issues, we propose three methods to better steer LLM code/text generation and achieve a notable improvement. The costs of token lengths and runtime are thoroughly discussed for all the methods. We believe the problem of steering LLM code/text generation is critical for future research and has much space for further improvement. Project Page, Datasets, and Codes are available at https://yongchao98.github.io/CodeSteer/.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。