ReCode: Unify Plan and Action for Universal Granularity Control
本文提出了ReCode,一种基于递归代码生成的全新范式,通过统一规划和行动在单一代码表示中实现通用粒度控制,显著提高了推理性能和训练效率。
更新于 2025-11-11。作者:Zhaoyang Yu、Jiayi Zhang、Huixue Su、Yufan Zhao、Yifan Wu、Mingyi Deng、Jinyu Xiang、Yizhang Lin、Lingxiao Tang、Yingchao Li、Yuyu Luo、Bang Liu、Chenglin Wu。
中文摘要
现实世界的任务需要在不同的粒度上进行决策,人类通过利用统一的认知表示,将规划本质理解为一种高级行动形式,在此方面表现出色。然而,基于当前大型语言模型(LLM)的智能体缺乏在决策粒度上流畅操作的关键能力。这种限制源于现有范式强制实施的严格分离高级规划和低级行动,这损害了动态适应性并限制了泛化能力。我们提出了ReCode(递归代码生成)这一新颖范式,通过在单一代码表示中统一规划和行动来解决这一限制。在这种表示中,ReCode将高级计划视为抽象占位函数,智能体随后将其递归分解成更细粒度的子函数,直到达到原始行动。这种递归方法消除了计划和行动之间的严格边界,使智能体能够动态控制其决策粒度。此外,递归结构本身生成了丰富、多粒度的训练数据,使模型能够学习分层决策过程。广泛的实验表明,ReCode在推理性能上显著超越先进基线,并在训练中表现出卓越的数据效率,验证了我们的核心洞察,即通过递归代码生成统一规划和行动是实现通用粒度控制的一种强大而有效的方法。代码可在https://github.com/FoundationAgents/ReCode找到。
英文摘要
Real-world tasks require decisions at varying granularities, and humans excel at this by leveraging a unified cognitive representation where planning is fundamentally understood as a high-level form of action. However, current Large Language Model (LLM)-based agents lack this crucial capability to operate fluidly across decision granularities. This limitation stems from existing paradigms that enforce a rigid separation between high-level planning and low-level action, which impairs dynamic adaptability and limits generalization. We propose ReCode (Recursive Code Generation), a novel paradigm that addresses this limitation by unifying planning and action within a single code representation. In this representation, ReCode treats high-level plans as abstract placeholder functions, which the agent then recursively decomposes into finer-grained sub-functions until reaching primitive actions. This recursive approach dissolves the rigid boundary between plan and action, enabling the agent to dynamically control its decision granularity. Furthermore, the recursive structure inherently generates rich, multi-granularity training data, enabling models to learn hierarchical decision-making processes. Extensive experiments show ReCode significantly surpasses advanced baselines in inference performance and demonstrates exceptional data efficiency in training, validating our core insight that unifying planning and action through recursive code generation is a powerful and effective approach to achieving universal granularity control. The code is available at https://github.com/FoundationAgents/ReCode.
解读
一句话总结
本文提出了ReCode,一种基于递归代码生成的全新范式,通过统一规划和行动在单一代码表示中实现通用粒度控制,显著提高了推理性能和训练效率。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:现实任务需要在不同粒度上进行决策,而当前基于大型语言模型(LLM)的智能体缺乏灵活控制决策粒度的能力。
- 现有方案不足:现有方法将高级规划和低级行动严格分离,限制了智能体的动态适应性和泛化能力。
- 研究目标:提出ReCode,通过在单一代码表示中统一规划和行动,实现智能体对不同粒度决策的灵活控制。
问题2:论文的核心创新点是什么?
- 技术创新:提出ReCode,通过递归地将高级计划分解为更细粒度的子函数,直至达到原始行动,实现规划和行动的统一。
- 方法改进:ReCode的递归结构天然生成丰富的多粒度训练数据,使模型能够学习层次化决策过程。
- 优势:ReCode在推理性能和训练效率方面均显著优于现有方法,同时提高了数据效率。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:在ALFWorld、WebShop和ScienceWorld三个环境中进行实验,比较ReCode与其他基线方法。
- 性能提升:ReCode在平均奖励率方面显著优于ReAct和CodeAct,提高了平均性能。
- 对比结果:ReCode在三个环境中的平均奖励率分别为83.57%、96.27%和42.78%,均优于基线方法。
问题4:这个研究的实际应用价值是什么?
- 应用场景:ReCode适用于需要在不同粒度上进行决策的复杂环境,如家庭环境、在线购物和科学实验。
- 实施建议:ReCode可以通过集成到现有LLM框架中来部署,并可以通过专门的前训练目标或综合微调策略来提高其性能。
- 局限与展望:ReCode的有效性取决于基模型的推理能力和少量示例的质量。未来的工作可以集中在提高模型在ReCode框架中的理解和操作能力上,并探索更鲁棒的生成错误处理和自动课程学习。
来源
机器可读索引:llms.txt