We use a few cookies

Essential cookies keep the library working. With your permission, we'd also like to use analytics to see what's useful and improve the experience. Read our Privacy Policy or Cookie Policy.

Skip to main content
Home/e-Resources/Computer Science & Information Technology/Self-Planning Code Generation with Large Language Models
PeriodicalsComputer Science & Information Technology

Self-Planning Code Generation with Large Language Models

Checking your access to this record.

Abstract & Overview

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 few-shot 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.

Cite this record

Xue Jiang, Yihong Dong, L. F. Wang, Zheng Fang, Qiwei Shang, Ge Li, et al. (2024). Self-Planning Code Generation with Large Language Models. ACM Transactions on Software Engineering and Methodology, 33(7), 1–30. https://doi.org/10.1145/3672456

Copy in another style

Jiang, X., Dong, Y., Wang, L. F., Fang, Z., Shang, Q., Li, G., Jin, Z. G., & Jiao, W. (2024). Self-Planning Code Generation with Large Language Models. ACM Transactions on Software Engineering and Methodology, 33(7), 1–30. https://doi.org/10.1145/3672456
Author names are used as deposited, so check their order before you submit.

Metadata is harvested from open-access indexes and can be incomplete. Check a citation against the published version before relying on it — see our open access & attribution policy.