Although large language models have demonstrated impressive ability in code generation, they are still struggling to address the complicated intent provided by humans. It is widely acknowledged that humans typically employ planning to decompose complex problems and schedule the solution steps prior to implementation. Thus we introduce planning into code generation to help the model understand complex intent and reduce the difficulty of problem solving. This paper proposes a self-planning code generation method with large language model, which consists of two phases, namely planning phase and implementation phase. Specifically, in the planning phase, the language model plans out the solution steps from the intent combined with in-context learning. Then it enters the implementation phase, where the model generates code step by step, guided by the solution steps. The effectiveness of self-planning code generation has been rigorously evaluated on multiple code generation datasets and the results have demonstrated a marked superiority over naive direct generation approaches with language model. The improvement in performance is substantial, highlighting the significance of self-planning in code generation tasks.
翻译:尽管大型语言模式在代码生成方面表现出了令人印象深刻的能力,但它们仍然在努力解决人类提供的复杂意图。人们普遍承认,人类通常利用规划来分解复杂问题和安排实施前的解决方案步骤。因此,我们将规划引入代码生成,以帮助模型理解复杂意图并减少解决问题的难度。本文件建议采用自规划代码生成方法,使用大语言模式,包括两个阶段,即规划阶段和实施阶段。具体地说,在规划阶段,语言模式计划从意图中排除解决方案步骤,同时结合同文学习。然后,它进入执行阶段,在解决方案步骤的指导下,该模式一步一步地生成代码步骤。对多代码生成数据集进行了严格评估,对自规划代码生成的有效性进行了评估,结果显示出明显优于使用语言模型的天真直接生成方法。绩效的改善是显著的,突出了在代码生成任务中自我规划的重要性。</s>