[논문 리뷰] AceCoder: Utilizing Existing Code to Enhance Code Generation
AceCoder는 프롬프트에 guided code generation과 예시 검색을 도입하여 MBPP, MBJP, MBJSP 벤치마크에서 여러 LLM과 언어에 걸쳐 코드 생성 정확도를 크게 향상시킨다.
Large Language Models (LLMs) have shown great success in code generation. LLMs take as the input a prompt and output the code. A key question is how to make prompts (i.e., Prompting Techniques). Existing prompting techniques are designed for natural language generation and have low accuracy in code generation. In this paper, we propose a new prompting technique named AceCoder. Our motivation is that code generation meets two unique challenges (i.e., requirement understanding and code implementation). AceCoder contains two novel mechanisms (i.e., guided code generation and example retrieval) to solve these challenges. (1) Guided code generation asks LLMs first to analyze requirements and output an intermediate preliminary (e.g., test cases). The preliminary is used to clarify requirements and tell LLMs "what to write". (2) Example retrieval selects similar programs as examples in prompts, which provide lots of relevant content (e.g., algorithms, APIs) and teach LLMs "how to write". We apply AceCoder to three LLMs (e.g., Codex) and evaluate it on three public benchmarks using the Pass@k. Results show that AceCoder can significantly improve the performance of LLMs on code generation. (1) In terms of Pass@1, AceCoder outperforms the state-of-the-art baseline by up to 56.4% in MBPP, 70.7% in MBJP, and 88.4% in MBJSP. (2) AceCoder is effective in LLMs with different sizes (i.e., 6B to 13B) and different languages (i.e., Python, Java, and JavaScript). (3) Human evaluation shows human developers prefer programs from AceCoder.
연구 동기 및 목표
- 코드 생성에서 요구 이해 및 코드 구현의 두 가지 고유한 과제로 인해 전문 프롬팅의 필요성에 대한 동기를 제시한다.
- 두 가지 메커니즘—guided code generation과 example retrieval—을 통해 이 도전들을 해결할 AceCoder를 제안한다.
- 공개 벤치마크와 인간 평가를 사용하여 여러 LLM과 프로그래밍 언어에 걸친 효과를 입증한다.
- 각 AceCoder 모듈의 기여를 보여주기 위한 절감 및 설계 인사이트를 제공한다.
제안 방법
- Lucene을 통한 BM25 기반 코퍼스에서 유사한 <요구사항, 코드> 쌍을 검색한다.
- n-그램 중복 감소 및 decay 기반 점수 매개 루프(알고리즘 1)를 통해 검색된 예시의 중복성을 필터링하는 선택기(Selector).
- 예시에서 preliminaries(예: 테스트 케이스)를 추출하여 <요구사항, 예비, 코드> 트리플로 변환하는 분석기(Analyzer).
- LLM이 먼저 예비(예: 테스트 케이스)를 생성한 뒤 최종 코드를 작성하도록 프롬프트에 트리플 예시를 주입하는 프롬프트 구성.
- 구성된 프롬트를 사용하여 예비 및 코드 순으로 생성하는 3단계 코드 생성.
- 세 가지 기본 LLM(CodeGeeX-13B, CodeGen-6B, InCoder-6B)에서 MBPP(Python), MBJP(Java), MBJSP(JavaScript)로 Pass@k(k=1,3,5) 평가.
실험 결과
연구 질문
- RQ1RQ1: AceCoder가 기존 프롬프팅 기술보다 코드 생성에서 더 정확한가?
- RQ2RQ2: AceCoder가 검색 기반 벤치마크에 비해 어떤 차이가 있는가?
- RQ3RQ3: 인간 개발자는 AceCoder가 생성한 코드를 선호하는가?
- RQ4RQ4: AceCoder의 세 가지 모듈(Retriever, Selector, Analyzer)의 기여는 무엇인가?
- RQ5RQ5: 세 모듈의 설계 선택 중 어떤 것이 성능을 극대화하는가?
주요 결과
| Base model | Prompting | MBPP Pass@1 | MBPP Pass@3 | MBPP Pass@5 | MBJP Pass@1 | MBJP Pass@3 | MBJP Pass@5 | MBJSP Pass@1 | MBJSP Pass@3 | MBJSP Pass@5 |
|---|---|---|---|---|---|---|---|---|---|---|
| CodeGeeX-13B | Zero-shot prompting | 5.20 | 13.80 | 19.40 | 4.46 | 11.97 | 18.26 | 0.20 | 0.20 | 0.41 |
| CodeGeeX-13B | CoT prompting | 12.60 | 23.40 | 30.20 | 14.40 | 28.19 | 33.67 | 11.35 | 21.10 | 25.96 |
| CodeGeeX-13B | Few-shot prompting | 20.40 | 30.60 | 36.00 | 16.63 | 26.17 | 34.48 | 11.16 | 19.88 | 25.56 |
| CodeGeeX-13B | AceCoder | 26.74 | 36.43 | 41.13 | 28.38 | 36.79 | 41.54 | 21.03 | 31.44 | 36.04 |
| CodeGen-6B | Zero-shot prompting | 10.40 | 19.40 | 24.40 | 14.81 | 25.76 | 31.44 | 8.72 | 19.67 | 22.92 |
| CodeGen-6B | CoT prompting | 13.00 | 21.00 | 26.00 | 13.59 | 25.35 | 31.24 | 11.56 | 20.08 | 24.54 |
| CodeGen-6B | Few-shot prompting | 14.60 | 24.00 | 30.20 | 18.25 | 30.02 | 34.68 | 9.94 | 19.88 | 23.12 |
| CodeGen-6B | AceCoder | 22.83 | 34.58 | 40.16 | 22.45 | 34.27 | 40.96 | 16.45 | 27.31 | 32.16 |
| InCoder-6B | Zero-shot prompting | 4.20 | 11.40 | 16.20 | 2.23 | 5.88 | 9.13 | 3.65 | 5.88 | 8.11 |
| InCoder-6B | CoT prompting | 3.99 | 10.65 | 15.31 | 1.83 | 4.46 | 7.10 | 1.22 | 2.03 | 4.67 |
| InCoder-6B | Few-shot prompting | 12.80 | 22.80 | 28.20 | 10.95 | 23.53 | 26.17 | 12.78 | 22.52 | 27.79 |
| InCoder-6B | AceCoder | 20.16 | 31.44 | 34.10 | 16.37 | 29.89 | 34.74 | 15.97 | 27.13 | 30.65 |
- AceCoder는 Pass@1에서 최첨단 벤치마크 대비 MBPP에서 최대 56.4%, MBJP에서 최대 70.7%, MBJSP에서 최대 88.4%의 성능 향상을 보인다.
- AceCoder는 Pass@1에서 검색 기반 벤치마크 대비 MBPP에서 최대 13.1%, MBJP에서 23.44%, MBJSP에서 15.8%의 향상을 거둔다.
- AceCoder는 6B에서 13B까지의 LLM 크기 및 Python, Java, JavaScript 전반에 걸쳐 개선을 보인다.
- 인간 평가에서 개발자들은 정확성, 코드 냄새, 유지 관리성 측면에서 AceCoder로 생성된 프로그램을 선호한다.
- 절삭(ablation)은 세 모듈(Retriever, Selector, Analyzer) 모두가 성능 향상에 기여한다는 것을 보여주며, 설계된 변형들이 비교되었다.
더 나은 연구,지금 바로 시작하세요
연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.
카드 등록 없음 · 무료 플랜 제공
이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.