让大模型像人一样灵活控制决策粒度,统一规划与执行
ReCode: Unify Plan and Action for Universal Granularity Control
- 用递归代码统一规划与动作,高阶计划作为抽象函数逐步细化
- 在多任务测试中显著优于基线模型,训练数据效率提升明显
- 适合需要动态调整决策精细程度的智能体系统研发
现实任务需在不同粒度下做出决策,人类通过统一认知表征实现这一能力,其中规划本质上是高层动作。当前基于大语言模型的智能体缺乏跨粒度灵活操作的能力,根源在于高阶规划与低阶动作被严格分离,影响动态适应性与泛化能力。本文提出ReCode(递归代码生成)新范式,将规划与动作统一于单一代码表示中:高阶计划作为抽象占位函数,由智能体递归分解为更细粒度子函数,直至生成原始动作。该递归结构打破规划与动作的僵硬边界,支持动态粒度控制,并天然生成多层次训练数据,助力模型学习层级决策过程。大量实验表明,ReCode在推理性能上显著超越先进基线,在训练数据效率方面表现优异,验证了通过递归代码生成统一规划与动作是实现通用粒度控制的有效路径。代码已开源。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。