Test-Driven Development for Code Generation

要約

最近のラージ言語モデル (LLM) は、問題ステートメントから直接コード スニペットを生成する重要な機能を実証しています。
この自動化プロセスは、要件に応じてコードが記述されることが多い従来の人間主導のソフトウェア開発を反映しています。
歴史的には、テスト駆動開発 (TDD) のメリットが証明されており、開発者は機能コードの前にテストを作成し、最初の問題ステートメントとの整合性を確保する必要があります。
LLM ベースのコード生成に TDD 原則を適用すると、開発者が生成されたコードの正確性を事前定義されたテストに対して検証できるという明確な利点が 1 つあります。
このペーパーでは、TDD を AI 支援コード生成プロセスに組み込むことができるかどうか、またどのように組み込むことができるかを調査します。
GPT-4 や Llama 3 などの LLM に問題ステートメントに加えてテストを提供すると、コード生成の結果が向上するという仮説を実験的に評価します。
MBPP や HumanEval など、確立された関数レベルのコード生成ベンチマークを実験しました。
私たちの結果は、テスト ケースを含めることで、プログラミングの課題解決の成功率が高まることを一貫して示しています。
TDD は、LLM によって生成されたコードが要件を効果的に捕捉することを保証するのに役立つ有望なパラダイムであると私たちは主張します。

要約(オリジナル)

Recent Large Language Models (LLMs) have demonstrated significant capabilities in generating code snippets directly from problem statements. This increasingly automated process mirrors traditional human-led software development, where code is often written in response to a requirement. Historically, Test-Driven Development (TDD) has proven its merit, requiring developers to write tests before the functional code, ensuring alignment with the initial problem statements. Applying TDD principles to LLM-based code generation offers one distinct benefit: it enables developers to verify the correctness of generated code against predefined tests. This paper investigates if and how TDD can be incorporated into AI-assisted code-generation processes. We experimentally evaluate our hypothesis that providing LLMs like GPT-4 and Llama 3 with tests in addition to the problem statements enhances code generation outcomes. We experimented with established function-level code generation benchmarks such as MBPP and HumanEval. Our results consistently demonstrate that including test cases leads to higher success in solving programming challenges. We assert that TDD is a promising paradigm for helping ensure that the code generated by LLMs effectively captures the requirements.

arxiv情報

著者 Noble Saji Mathews,Meiyappan Nagappan
発行日 2024-06-11 15:53:35+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

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