返回
Self-Planning Code Generation with Large Language Models
使用大型语言模型的自规划代码生成
DOI:10.1145/3672456.png)
摘要
En 中文
Although large language models (LLMs) 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 solution steps prior to implementation. To this end, 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 approach with large language models, which consists of two phases, namely planning phase and implementation phase. Specifically, in the planning phase, LLM plans out concise solution steps from the intent combined with fewshot prompting. Subsequently, in the implementation phase, the model generates code step by step, guided by the preceding solution steps. We conduct extensive experiments on various code-generation benchmarks across multiple programming languages. Experimental results show that self-planning code generation achieves a relative improvement of up to 25.4% in Pass@1 compared to direct code generation, and up to 11.9% compared to Chain-of-Thought of code generation. Moreover, our self-planning approach also enhances the quality of the generated code with respect to correctness, readability, and robustness, as assessed by humans.
Keyword:
Code Generation
Large language models
Planning
期刊
A
IF:
6.2
论文数:
1.4K
被引数:
4.5K
机构
引用论文
High-resolution seismic reflection profiles from Lake Titicaca, Peru-Bolivia: Evidence for Holocene aridity in the tropical Andes
Geology
IF0
Geochemical evidence for sediment provenance in mudstones and fossil‐poor wackestones (Upper Jurassic, Majorca Island)泥岩和化石贫乏的泥岩沉积物来源的地球化学证据 (马略卡岛上侏罗纪)
Terra Nova
IF0
Elastic interaction of a point defect with a prismatic dislocation loop in hexagonal crystals六角形晶体中点缺陷与棱柱形位错环的弹性相互作用

