arrow
返回

Self-Planning Code Generation with Large Language Models

使用大型语言模型的自规划代码生成

delete2024-09-27
delete0
delete
OA
AI
X
Xue Jiang
Y
Yihong Dong
L
L. F. Wang
F
Fang Zheng
Q
Qiwei Shang
G
Ge Li *
Z
Zhi Jin
W
Wenpin Jiao
DOI:10.1145/3672456delete
delete原文链接
delete分享
delete收藏
摘要

摘要

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
ACM Transactions on Software Engineering and Methodology
IF:
6.2
论文数:
1.4K
被引数:
4.5K

机构

北京大学 封面图
北京大学
学者数:
9.2K
论文数: 2.8K
被引数: 7.1W
引用论文

引用论文

High-resolution seismic reflection profiles from Lake Titicaca, Peru-Bolivia: Evidence for Holocene aridity in the tropical Andes
err1998-01-01
err0
PREAI
errGeoffrey O. Seltzer; Paul Baker; Scott Cross; Robert Dunbar; Sherilyn Fritz
err分享
err收藏
TECPR2 Associated Neuroaxonal Dystrophy in Spanish Water Dogs
err2015-11-10
err0
errOAAI
errKerstin Hahn; Cecilia Rohdin; Vidhya Jagannathan; Peter Wohlsein; Wolfgang Baumgärtner; Frauke Seehusen; Ingo Spitzbarth; Rodrigo Grandon; Cord Drögemüller; Karin Hultin Jäderlund
err分享
err收藏
In Vivo and In Vitro Mechanical Loading of Mouse Achilles Tendons and Tenocytes—A Pilot Study
err2020-02-15
err0
errOAAI
errViviane Fleischhacker; Franka Klatte-Schulz; Susann Minkwitz; Aysha Schmock; Maximilian Rummler; Anne Seliger; Bettina M. Willie; Britt Wildemann
err分享
err收藏
Design Space Approach for Preservative System Optimization of an Anti-Aging Eye Fluid Emulsion
err2015-10-15
err0
errOAAI
errFelipe Rebello Lourenço; Fabiane Lacerda Francisco; Márcia Regina Spuri Ferreira; Terezinha De Jesus Andreoli; Raimar Löbenberg; Nádia Bou-Chacra
err分享
err收藏
err分享
err收藏
err分享
err收藏
学者 查看更多内容