# Self-planning Code Generation with Large Language Model

**Authors:** Xue Jiang, Yihong Dong, Lecheng Wang, Qiwei Shang, Ge Li  
**arXiv:** [2303.06689](https://arxiv.org/abs/2303.06689)  
**Date:** 2023-03-12  
**Summary page:** https://www.summarizepaper.com/en/paper/2303.06689v1/

## Key points

- The paper proposes a self-planning code generation method with large language models (LLMs) to generate complex code from human intent.
- The approach consists of two phases: planning and implementation.
- In the planning phase, the LLM plans out solution steps from the provided intent combined with in-context learning.
- In the implementation phase, the model generates code step by step guided by the solution steps.
- The self-planning code generation has been evaluated on multiple datasets and demonstrated superiority over naive direct generation approaches with LLMs.
- However, some problems were discovered during practice that need further attention, such as limited information in provided intent and unstable performance due to sensitivity to examples.
- The paper suggests exploring beyond code writing into requirements analysis and incorporating requirements engineering methodology with LLMs for software development.
- A case study validates this approach's effectiveness but highlights its limitations as a forward and limited solution.

## Summary

This paper proposes a self-planning code generation method with large language models (LLMs) to address the difficulty of generating complex code from human intent. The proposed approach consists of two phases: planning and implementation. In the planning phase, the LLM plans out solution steps from the provided intent combined with in-context learning. Then, in the implementation phase, 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 datasets, demonstrating a marked superiority over naive direct generation approaches with LLMs. However, during practice some problems were discovered that need further attention. One issue is that the plan-based approach is still limited by a lack of information in the provided intent. Adding more information such as usage examples or detailed descriptions can improve performance. Another problem is unstable performance due to sensitivity to examples, making it difficult to control what the model learns from prompts. Additionally, replicating irrelevant steps in prompts can occur if there is not enough confidence to generate a plan. The paper suggests exploring beyond code writing into requirements analysis and incorporating requirements engineering methodology with LLMs for software development. Furthermore, solving real-world problems through programs using similar methods as this paper could provide logical and well-thought-out solutions. A case study validates this approach's effectiveness but highlights its limitations as a forward and limited solution. In conclusion, this paper proposes an effective self-planning approach for code generation that outperforms naive direct generation on multiple datasets and discusses promising future works for advancing software engineering one step forward.
