[논문 리뷰] Self-planning Code Generation with Large Language Models
본 논문은 의도를 코드 생성 전 계획으로 분해하는 두 단계의 자기 계획(self-planning) 접근법을 도입합니다. 이를 통해 직접 생성 대비 최대 25.4% Pass@1 향상과 Code CoT 대비 최대 11.9% 향상을 코드 벤치마크에서 달성합니다. 또한 코드 품질과 다국어 기능의 향상을 보여줍니다.
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 outlines concise and formatted planning steps from the intent. Subsequently, in the implementation phase, the model generates code step by step, guided by the preceding planning 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 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.
연구 동기 및 목표
- 복잡한 프로그래밍 의도를 코드 생성에서 다루기 위한 계획의 필요성 제기.
- LLM이 먼저 계획을 수립하고 그 계획에 맞춰 구현하는 두 단계 프레임워크를 제안.
- 계획 수립이 문제 분해와 코드 합성 지시를 강화하는 방법을 보여줌.
- 다국어 및 다언어 벤치마크에서 사람 평가를 통한 코드 품질 평가를 수행.
제안 방법
- 두 단계 추론: 계획 단계에서 의도에서 간결한 계획을 도출하기 위해 패-shot 프롬프트를 사용합니다.
- 구현 단계에서 계획을 의도에 첨부하고 계획에 따라 단계별로 코드를 생성합니다.
- 계획 및 구현 분리의 형식화로 P(z|x,C) ∝ P(z|y,x) 및 P(y|x,C) 를 포함합니다.
- 실행 가능한 고수준의 단계가 담긴 선택적 조건/반복 구조를 포함한 패-shot 계획 프롬프트를 설계합니다.
- 基선(Direct, Few-shot, Code CoT) 및 실제 계획 upper bound를 대비 비교합니다.
- Pass@k, AvgPassRatio, CodeBLEU를 사용해 Python, Java, Go, JavaScript 벤치마크를 평가합니다.
실험 결과
연구 질문
- RQ1RQ1: 자기 계획이 기본 코드 생성 방식과 비교해 어떤 차이가 있는가?
- RQ2RQ2: 서로 다른 LLM들에서 자기 계획은 어떻게 성능을 보이는가?
- RQ3RQ3: 자기 계획 접근의 최적 설계(단계, 샷, 단계 수)는 무엇인가?
- RQ4RQ4: 다국어 코드 생성에서 자기 계획은 어떻게 작동하는가?
- RQ5RQ5: 문제 복잡도는 자기 계획의 이점에 어떤 영향을 미치는가?
주요 결과
- 자기 계획은 직접 생성 및 Code CoT를 능가하며 평가된 벤치마크에서 Direct 대비 최대 25.4% Pass@1 향상, Code CoT 대비 최대 11.9% 향상을 달성합니다.
- 정답 계획(ground-truth planning)은 상한치의 상당한 이점을 제공합니다(예: HumanEval에서 >50%, MBPP-ET에서 >30%); 실제 계획 접근은 이러한 이점에 근접합니다.
- 자기 계획은 대형 모델에서 예측되는 출현적( emergent ) 행동을 보이며, 특히 175B 규모에서 여러 기본 LLM에 걸쳐 계획의 이점이 확장됩니다.
- 1단계 대 2단계 설계의 경우, 주의 깊은 프롬프트링으로 2단계가 견고하게 동작하지만, 다회전 계획은 LLM의 자름(truncation) 문제로 종종 실패합니다. 간결한 계획이 매우 효과적일 수 있습니다.
- 계획 수립은 코드의 가독성 및 견고성 측면에서 품질 향상을 보여주며, 인간 평가에서도 단순 정답성 이상의 품질 향상을 시사합니다.
더 나은 연구,지금 바로 시작하세요
연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.
카드 등록 없음 · 무료 플랜 제공
이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.