Self-planning Code Generation with Large Language Model
Authors: Xue Jiang, Yihong Dong, Lecheng Wang, Qiwei Shang, Ge Li
Abstract
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.
The papers around it, by date and closeness
Higher is closer to this paper; left is older. Lines join papers close to each other: groups of lines are sub-topics. Select a point to see why it is there. Back to the summary of this paper
Papers around this one
Ranked by how close their title and abstract are to this paper’s. Select some to read them together.
Closest papers
-
Planning with Large Language Models for Code GenerationShun Zhang, Zhenfang Chen, Yikang Shen et al. · 2023 · Machine Learning · cited 277 times · AI summary available
Planning-Guided Transformer Decoding uses lookahead planning to guide token decoding, while this paper plans solution steps before generating code.
Abstract
Existing large language model-based code generation pipelines typically use beam search or sampling algorithms during the decoding process. Although the programs they generate achieve high token-matching-based scores, they often fail to compile or generate incorrect outputs. The main reason is that conventional Transformer decoding algorithms may not be the best choice for code generation. In this work, we propose a novel Transformer decoding algorithm, Planning-Guided Transformer Decoding (PG-TD), that uses a planning algorithm to do lookahead search and guide the Transformer to generate better programs. Specifically, instead of simply optimizing the likelihood of the generated sequences, t…
-
A Self-Iteration Code Generation Method Based on Large Language ModelsTianyou Chang, Shi-Zhan Chen, Guo-Dong Fan et al. · 2023 · International Conference on Parallel and Distributed Systems · cited 5 times · Not summarized yet
A Self-Iteration Code Generation Method uses analyst, designer, developer, and tester roles to refine code in cycles, rather than planning steps before implementation.
Abstract
Although large language models (LLMs) have demonstrated impressive performance in code generation, they still face challenges when dealing with complex code generation tasks. In the software development process, humans often refine complex tasks iteratively and continuously modify and improve them. Inspired by this, we propose a self-iteration code generation framework based on large language models like ChatGPT. To realize this idea, we incorporated software development methodologies into the self-iteration framework. We introduced four roles into each cycle, including analyst, designer, developer, and tester. Each role performs different tasks during the self-iteration cycle, with analyst …
-
Planning-Driven Programming: A Large Language Model Programming WorkflowChao Lei, Yan-Chuan Chang, N. Lipovetzky et al. · 2024 · Annual Meeting of the Association for Computational Linguistics · cited 14 times · Not summarized yet
Planning-Driven Programming also generates a solution plan before coding, then adds visible-test verification to guide code refinement.
Abstract
The strong performance of large language models (LLMs) raises extensive discussion on their application to code generation. Recent research suggests continuous program refinements through visible tests to improve code generation accuracy in LLMs. However, these methods suffer from LLMs' inefficiency and limited reasoning capacity. In this work, we propose an LLM programming workflow (LPW) designed to improve both initial code generation and subsequent refinements within a structured two-phase workflow. Specifically, the solution generation phase formulates a solution plan, which is then verified through visible tests to specify the intended natural language solution. Subsequently, the code i…
-
Code Auto-generation System based on Large Language ModelsDan Liu, Junxiang He, Yun Shen et al. · 2025 · IEEE international Symposium on Broadband Multimedia Systems and Broadcasting · cited 1 time · Not summarized yet
Code Auto-generation System describes generating executable code from user needs, with a focus on professional development scenarios and custom components.
Abstract
This paper introduces a large-scale model-based code automatic generation system and its construction method. It aims to use deep learning and natural language processing techniques, based on pre trained large language models, to automatically understand user input and needs, and generate executable program code. In addition to supporting automatic generation of general code, this patent is more suitable for professional system development scenarios, especially those with specific requirements for generating code. For example, in the front-end development process, users need to use previously created custom controls, custom styles, or layouts in the automatically generated code; Or when acce…
-
Aligning User Requirement with Large Language Model in Code GenerationJ. Li, Rui-Qi Bai, Yang Luo et al. · 2026 · Proceedings of the 41st IEEE/ACM International Conference on Automated Software Engineering · Not summarized yet
REA-Coder addresses complex code-generation requests by aligning the model's understanding of user requirements, rather than decomposing them into planned implementation steps.
Abstract
Code generation refers to automatically producing executable programs from user requirements. Recently, researchers have explored approaches to enhance the correctness of generated code with advanced large language models. Although achieving improvements, existing approaches focus on designing reasoning strategies or post-refinement methods to enhance code generation performance. Despite their differences, all these methods share a common assumption: the LLM can correctly understand the given requirement. However, this assumption does not always hold. To fill this gap, we propose REA-Coder, a requirement alignment approach to enhance the code generation performance of LLMs. REA-Coder involve…
-
Code generation with large language models: a survey from neural program synthesis to autonomous software developmentBurak Gülmez · 2026 · Applied intelligence (Boston) · cited 10 times · Not summarized yet
The survey reviews code-generation research from program synthesis to large language models, including methods, evaluation, and security.
Abstract
Large language models have reshaped code generation, driving a transition from rule-based and statistical methods to transformer-based architectures pretrained on vast code corpora. This survey traces the intellectual lineage from classical program synthesis through pre-transformer neural approaches to contemporary large-scale models, examining code generation capabilities across model architectures, training strategies, task taxonomies, evaluation methodologies, security implications, and ethical considerations. Contemporary models show proficiency in function-level synthesis, program repair, and documentation generation, though performance varies across programming languages and task compl…
-
Enabling Programming Thinking in Large Language Models Toward Code GenerationJ. Li, Ge Li, Yong-Ming Li et al. · 2023 · arXiv.org · preprint, not peer reviewed · cited 44 times · Not summarized yet
Enabling Programming Thinking concerns programming-oriented reasoning in large language models for code generation.
-
Think Outside the Code: Brainstorming Boosts Large Language Models in Code GenerationXinyu Li, Jiang-Tian Xue, Zheng Xie et al. · 2023 · arXiv.org · preprint, not peer reviewed · cited 43 times · Not summarized yet
Brainstorm generates and selects possible solution blueprints for difficult code-generation tasks, while this paper plans steps and implements them sequentially.
Abstract
Code generation aims to automatically generate source code from high-level task specifications, which can significantly increase productivity of software engineering. Recently, approaches based on large language models (LLMs) have shown remarkable code generation abilities on simple tasks. However, generate code for more complex tasks, such as competition-level problems, remains challenging. In this paper, we introduce Brainstorm framework for code generation. It leverages a brainstorming step that generates and selects diverse thoughts on the problem to facilitate algorithmic reasoning, where the thoughts are possible blueprint of solving the problem. We demonstrate that Brainstorm signific…
Prior work it builds on
-
Teaching Large Language Models to Self-DebugXinyun Chen, Maxwell Lin, Nathanael Schärli et al. · 2023 · Computation and Language · cited 1,513 times · AI summary available
Self-Debugging teaches models to explain and identify errors in generated programs, rather than planning a solution before code generation.
Abstract
Large language models (LLMs) have achieved impressive performance on code generation. However, for complex programming tasks, generating the correct solution in one go becomes challenging, thus some prior works have designed program repair approaches to improve code generation performance. In this work, we propose Self-Debugging, which teaches a large language model to debug its predicted program via few-shot demonstrations. In particular, we demonstrate that Self-Debugging can teach the large language model to perform rubber duck debugging; i.e., without any feedback on the code correctness or error messages, the model is able to identify its mistakes by explaining the generated code in nat…
-
Program Synthesis with Large Language ModelsJacob Austin, Augustus Odena, Maxwell Nye et al. · 2021 · Programming Languages · preprint, not peer reviewed · cited 5,041 times · AI summary available
Program Synthesis with Large Language Models evaluates models synthesizing Python programs from natural-language descriptions on two benchmarks.
Abstract
This paper explores the limits of the current generation of large language models for program synthesis in general purpose programming languages. We evaluate a collection of such models (with between 244M and 137B parameters) on two new benchmarks, MBPP and MathQA-Python, in both the few-shot and fine-tuning regimes. Our benchmarks are designed to measure the ability of these models to synthesize short Python programs from natural language descriptions. The Mostly Basic Programming Problems (MBPP) dataset contains 974 programming tasks, designed to be solvable by entry-level programmers. The MathQA-Python dataset, a Python version of the MathQA benchmark, contains 23914 problems that evaluat…
-
Synchromesh: Reliable code generation from pre-trained language modelsGabriel Poesia, Oleksandr Polozov, Vu Le et al. · 2022 · International Conference on Learning Representations · cited 239 times · Not summarized yet
Synchromesh improves code-generation reliability by retrieving semantically similar examples and constraining outputs, rather than using a plan-first workflow.
Abstract
Large pre-trained language models have been used to generate code,providing a flexible interface for synthesizing programs from natural language specifications. However, they often violate syntactic and semantic rules of their output language, limiting their practical usability. In this paper, we propose Synchromesh: a framework for substantially improving the reliability of pre-trained models for code generation. Synchromesh comprises two components. First, it retrieves few-shot examples from a training bank using Target Similarity Tuning (TST), a novel method for semantic example selection. TST learns to recognize utterances that describe similar target programs despite differences in surf…
-
Structured Chain-of-Thought Prompting for Code GenerationJ. Li, Ge Li, Yong-Ming Li et al. · 2023 · ACM Transactions on Software Engineering and Methodology · cited 424 times · Not summarized yet
Structured CoT prompting inserts structured reasoning steps before code generation, sharing the use of intermediate reasoning but not the paper's solution-plan workflow.
Abstract
Large Language Models (LLMs) have shown impressive abilities in code generation. Chain-of-Thought (CoT) prompting is the state-of-the-art approach to utilizing LLMs. CoT prompting asks LLMs first to generate CoTs (i.e., intermediate natural language reasoning steps) and then output the code. However, the accuracy of CoT prompting still cannot satisfy practical applications. For example, gpt-3.5-turbo with CoT prompting only achieves 53.29% Pass@1 in HumanEval. In this article, we propose Structured CoTs (SCoTs) and present a novel prompting technique for code generation named SCoT prompting. Our motivation is that human developers follow structured programming. Developers use three programmi…
-
Self-Instruct: Aligning Language Models with Self-Generated InstructionsYizhong Wang, Yeganeh Kordi, Swaroop Mishra et al. · 2022 · Annual Meeting of the Association for Computational Linguistics · cited 3,884 times · AI summary available
Self-Instruct bootstraps instruction-following by generating and filtering training examples, rather than addressing code generation through planning.
Abstract
Large “instruction-tuned” language models (i.e., finetuned to respond to instructions) have demonstrated a remarkable ability to generalize zero-shot to new tasks. Nevertheless, they depend heavily on human-written instruction data that is often limited in quantity, diversity, and creativity, therefore hindering the generality of the tuned model. We introduce Self-Instruct, a framework for improving the instruction-following capabilities of pretrained language models by bootstrapping off their own generations. Our pipeline generates instructions, input, and output samples from a language model, then filters invalid or similar ones before using them to finetune the original model. Applying ou…
Papers that cite it
-
Knowledge-Aware Code Generation with Large Language ModelsTao Huang, Zhihong Sun, Zhi Jin et al. · 2024 · IEEE International Conference on Program Comprehension · cited 26 times · Not summarized yet
Knowledge-Aware Code Generation targets unfamiliar competition-level problems by incorporating knowledge, while this paper uses a plan-and-implement process.
Abstract
Large Language Models (LLMs) perform well on basic programming problems. However, they encounter challenges when dealing with complex tasks involving the use of diverse algorithmic and data structure skills, particularly programming competition-level problems. Notably, ChatGPT exhibits proficient performance on problems it has encountered during its pre-training phase, but this performance deteriorates when faced with novel problems. Consequently, enhancing the ability of LLMs to address unfamiliar problems has emerged as a pivotal research focus. The problem-solving process of LLMs mirrors human programmers’ approach to a certain extent. When confronted with new programming tasks, human pro…
-
Reliable Code Generation with Test Case Prioritization and Cognitive ValidationLingyun Huang, Xin Yin, Xin-Rui Li et al. · 2025 · Asia-Pacific Software Engineering Conference · Not summarized yet
PriGen uses prioritized test cases and cognitive validation to guide code generation, rather than planning solution steps from intent.
Abstract
Large Language Models (LLMs) have shown impressive capabilities in code generation. However, they often struggle in complex programming scenarios due to incomplete semantic understanding and limited ability to correct misunderstandinginduced errors. While recent efforts have incorporated test cases to guide task comprehension, they typically overlook the quality and relevance of the test cases, reducing their effectiveness in steering accurate code generation. To overcome these limitations, we present PriGen, a multiagent collaborative framework for prioritized and test case driven code generation. PriGen introduces a novel test case prioritization mechanism that selects a high-value subset …
-
A Comparative Empirical Study of Prompting Strategies for Code Generation with Large Language ModelsFanyi Zhao, Mingzhuo Yu, Chuan Luo · 2025 · Journal of Advanced Computing Systems · cited 1 time · Not summarized yet
The comparative study evaluates prompting strategies for code generation across models and benchmarks, providing empirical context for the paper's in-context planning approach.
Abstract
Large language models have demonstrated strong capabilities in automated code generation, yet the influence of prompting strategies on generation quality remains insufficiently characterized under controlled experimental conditions. This study presents a systematic comparative evaluation of five prompting strategies — direct instruction, few-shot, zero-shot chain-of-thought, few-shot chain-of-thought, and self-consistency — across seven code-oriented large language models spanning both open-source and proprietary families. Experiments are conducted on four established benchmarks: HumanEval, MBPP, HumanEval+, and MBPP+. Results measured by pass@1 indicate that self-consistency with ten sampli…
-
CodeCoR: An LLM-Based Self-Reflective Multi-Agent Framework for Code GenerationRu-Wei Pan, Hong-Yu Zhang, Chao Liu · 2025 · arXiv.org · preprint, not peer reviewed · cited 46 times · Not summarized yet
CodeCoR uses a self-reflective multi-agent workflow for code generation, whereas this paper has the model plan and then implement step by step.
Abstract
Code generation aims to produce code that fulfills requirements written in natural language automatically. Large Language Models (LLMs) like ChatGPT have demonstrated promising effectiveness in this area. Nonetheless, the LLMs often fail to ensure the syntactic and semantic correctness of the generated code. Recently, researchers proposed multi-agent frameworks that guide LLMs with different prompts to analyze programming tasks, generate code, and perform testing in a sequential workflow. However, the performance of the workflow is not robust as code generation depends on the performance of each agent. To address this challenge, we propose CodeCoR, a multi-agent framework that prunes interme…
-
RGD: Multi-LLM Based Agent Debugger via Refinement and Generation GuidanceHaolin Jin, Ze-Chao Sun, Hua-Ming Chen · 2024 · International Conference on Agents · cited 22 times · Not summarized yet
RGD guides code generation with multi-LLM refinement and debugging, rather than a single model's plan-first implementation workflow.
Abstract
Large Language Models (LLMs) have shown incredible potential in code generation tasks, and recent research in prompt engineering have enhanced LLMs’ understanding of textual information. However, ensuring the accuracy of generated code often requires extensive testing and validation by programmers. While LLMs can typically generate code based on task descriptions, their accuracy remains limited, especially for complex tasks that require a deeper understanding of both the problem statement and the code generation process. This limitation is primarily due to the LLMs’ need to simultaneously comprehend text and generate syntactically and semantically correct code, without having the capability …
Go further
How are these papers found?
We compare the title and abstract of this paper with those of every paper summarized on this site, and with the papers Semantic Scholar recommends, those it cites and those citing it (for a much-cited paper, its most recent citations and, from OpenAlex, the most cited ones). Among the prior work and the follow-ups, the papers that use each other in depth, a method it uses and the much-cited follow-ups come a little higher. The levels (very close, close, related) come from the similarity of the texts, not from a judgment of quality; * marks a paper without an abstract, compared by its title. The sentence under a paper is written by an AI from the two abstracts: check it in the papers. A paper marked not relevant by three readers leaves the list.
Updated on 6 November 2026.