AceCoder: Utilizing Existing Code to Enhance Code Generation

要約

大規模言語モデル (LLM) は、コード生成において大きな成功を収めています。
LLM はプロンプトを入力として受け取り、コードを出力します。
重要な問題は、プロンプトを作成する方法 (つまり、プロンプト テクニック) です。
既存のプロンプト手法は自然言語生成用に設計されており、コード生成の精度が低いです。
この論文では、AceCoder という名前の新しいプロンプト手法を提案します。
私たちの動機は、コード生成が 2 つの固有の課題 (つまり、要件の理解とコードの実装) に対処することです。
AceCoder には、これらの課題を解決するための 2 つの新しいメカニズム (つまり、ガイド付きコード生成とサンプル取得) が含まれています。
(1) ガイド付きコード生成では、最初に LLM に要件を分析し、中間の予備的なもの (テスト ケースなど) を出力するよう求めます。
暫定版は、要件を明確にし、LLM に「何を書くべきか」を指示するために使用されます。
(2) サンプル検索では、類似したプログラムがプロンプト内のサンプルとして選択され、多くの関連コンテンツ (アルゴリズム、API など) が提供され、LLM に「書き方」を教えられます。
AceCoder を 3 つの LLM (Codex など) に適用し、Pass@k を使用して 3 つの公開ベンチマークで評価します。
結果は、AceCoder がコード生成における LLM のパフォーマンスを大幅に向上できることを示しています。
(1) Pass@1 に関して、AceCoder は最先端のベースラインを MBPP で最大 56.4%、MBJP で 70.7%、MBJSP で 88.4% 上回っています。
(2) AceCoder は、さまざまなサイズ (つまり、6B ~ 13B) およびさまざまな言語 (つまり、Python、Java、および JavaScript) の LLM で有効です。
(3) 人間による評価は、人間の開発者が AceCoder のプログラムを好むことを示しています。

要約(オリジナル)

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.

arxiv情報

著者 Jia Li,Yunfei Zhao,Yongmin Li,Ge Li,Zhi Jin
発行日 2023-09-07 11:29:44+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.AI, cs.SE パーマリンク