Planning-Coding Separation in LLM-Based Code Generation: An Empirical Study

📄 arXiv: 2611.04320v1 📥 PDF

作者: Wentao Wang, Zeyu Sun, Ruwei Pan, Yueyi Xiao, Qingyuan Liang, Lu Zhang

分类: cs.AI, cs.SE

发布日期: 2026-11-03

备注: 21 pages, 4 figures


💡 一句话要点

提出规划与编码分离以提升LLM代码生成效果

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 代码生成 规划与编码 模型组合 机器学习

📋 核心要点

  1. 现有方法对规划能力与编码能力的交互研究不足,尤其是在不同LLM之间的组合效果尚未明确。
  2. 本文提出将规划与编码分离,探索不同规划者与编码者的组合,以提高代码生成的有效性。
  3. 实验结果显示,几乎所有组合的效果与同一LLM相当,且强者组合通常能实现更好的性能提升。

📝 摘要(中文)

规划被认为是提升大型语言模型(LLM)代码生成的重要因素。然而,规划能力与编码能力之间的相互作用仍然未被充分探讨,尤其是当这两种能力来自不同的LLM时。本文首次进行了全面的实证研究,探讨了LLM代码生成中的规划-编码交互,具体研究了不同的规划者-编码者组合,分析了编码者如何利用来自不同规划者的规划信息及进一步训练对组合的影响。结果表明,几乎所有的规划者-编码者组合在效果上与使用同一LLM进行规划和编码相当,且强规划者与强编码者的组合通常能实现更好的效果。使用大型模型作为规划者并与较小模型作为编码者的组合,有时也能与使用大型模型作为规划者和编码者的效果相当,进一步训练编码者通常能提升各种组合的效果。这些发现为LLM代码生成中的规划与编码分离提供了实证依据,可能为构建代码生成系统提供更灵活的方式。

🔬 方法详解

问题定义:本文旨在解决规划能力与编码能力之间的交互问题,现有方法未能充分探讨不同LLM组合的效果,导致代码生成的效率和质量受到限制。

核心思路:论文提出将规划与编码分离,研究不同规划者与编码者的组合,以便更灵活地利用各自的优势,提高代码生成的效果。

技术框架:整体架构包括两个主要模块:规划者和编码者。规划者负责生成代码的高层次规划,而编码者则根据规划信息生成具体代码。通过不同组合的实验,评估其效果。

关键创新:最重要的创新点在于首次系统性地研究了规划与编码的分离,证明了不同LLM组合的有效性,挑战了传统上认为规划与编码必须由同一模型完成的观点。

关键设计:在实验中,采用了多种规划者与编码者的组合,评估了不同模型规模的影响,并通过进一步训练编码者来提升组合效果,具体参数设置和损失函数设计在实验部分详细说明。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,几乎所有规划者-编码者组合在效果上与使用同一LLM相当,强规划者与强编码者的组合通常能实现更好的效果。此外,使用大型模型作为规划者与小型模型作为编码者的组合,效果有时与使用大型模型作为两者时相当,进一步训练编码者通常能提升组合效果。

🎯 应用场景

该研究的潜在应用领域包括自动代码生成、智能编程助手和软件开发工具等。通过规划与编码的分离,可以构建更灵活和高效的代码生成系统,提升开发者的生产力,并为未来的编程教育和工具开发提供新的思路。

📄 摘要(原文)

Planning has been identified as an important factor for improved code generation with Large Language Models (LLMs). However, the interaction between planning capability and coding capability remains largely underexplored, especially when the two capabilities are from different LLMs. In this paper, we conduct the first comprehensive empirical study of planning-coding interaction in LLM-based code generation, where planning and coding are assigned to different LLMs (i.e., planning-coding separation). Specifically, we explore different planner-coder combinations to investigate the effectiveness for coders to utilize planning information from various planners and the impact of further training of coders on planner-coder combinations. Our results demonstrate that almost all planner-coder combinations are as competitive as using the same LLM for planning and coding, and the combination of a stronger planner and a stronger coder typically achieves improved effectiveness. Furthermore, using a large model as the planner paired with a much smaller model as the coder can sometimes be as competitive as using the large model as both the planner and the coder, and further training of the coder can typically boost various planner-coder combinations. These findings provide empirical evidence that planning and coding can be separated to a considerable extent in LLM-based code generation, which may offer a more flexible way to construct code-generation systems.