[論文レビュー] AceCoder: Utilizing Existing Code to Enhance Code Generation
AceCoder はガイド付きコード生成と例の取得をプロンプトに導入し、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.
研究の動機と目的
- コード生成における要件理解とコード実装という二つの固有の課題のため、専門的なプロンプト付与の必要性を動機づける。
- ガイド付きコード生成と例取得という AceCoder の二つの機構を提案し、これらの課題に対処する。
- 公的ベンチマークと人間評価を用いて、複数のLLMと言語に渡る有効性を示す。
- 各 AceCoder モジュールの貢献を示すアブレーションと設計洞察を提供する。
提案手法
- BM25 via Lucene を用いたコーパスからの同様の <requirement, code> ペアの取得。
- n-gram の重複を減らすことで retrieved examples をフィルタリングするセレクタ(アルゴリズム 1)と decay ベースのスコアリングループ。
- retrieved programs を <requirement, preliminary, code> の三つ組に変換するアナライザ(例から preliminaries を抽出(例:テストケース))。
- Prompt 構築は三つ組の例をプロンプトに注入し、LLM がまず preliminaries(例:テストケース)を生成し、その後最終コードを生成する。
- 三段階のコード生成で、LLM が構築されたプロンプトを用いて preliminaries を出力し、その後コードを出力する。
- MBPP(Python)、MBJP(Java)、MBJSP(JavaScript)各ベース LLM(CodeGeeX-13B、CodeGen-6B、InCoder-6B)で Pass@k(k=1,3,5)を評価。
実験結果
リサーチクエスチョン
- RQ1RQ1: AceCoder はコード生成の既存プロンプティング技術より正確か?
- RQ2RQ2: AceCoder は取得ベースのベースラインと比較してどうか?
- RQ3RQ3: 人間の開発者は AceCoder 生成コードを好むか?
- RQ4RQ4: 三つの AceCoder モジュール(Retriever、Selector、Analyzer)の貢献は?
- RQ5RQ5: 三つのモジュールのデザイン選択はどれが性能を最大化する?
主な発見
| ベースモデル | プロンプト設計 | 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 で取得ベースラインを最大 13.1%、MBPP 23.44%、MBJSP 15.8% 上回る。
- AceCoder は 6B から 13B までの LLMS サイズと Python、Java、JavaScript の間で改善をもたらす。
- 人間の評価では、開発者は正確性、コードの匂い、保守性の点で AceCoder 生成プログラムを好む。
- アブレーションにより三つのモジュール(Retriever、Selector、Analyzer)すべてが性能向上に寄与することが示され、設計されたバリアントと比較した。
より良い研究を、今すぐ始めましょう
論文設計から論文執筆まで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。