Skip to main content
QUICK REVIEW

[論文レビュー] AgentCoder: Multi-Agent-based Code Generation with Iterative Testing and Optimisation

Dong Huang, Jie M. Zhang|arXiv (Cornell University)|Dec 20, 2023
Software Engineering ResearchComputer Science被引用数 16
ひとこと要約

AgentCoder はプログラマー、テスト設計者、テスト実行者の三エージェント・フレームワークを用い、コードとテストを反復的に生成・ローカルで実行し、実行フィードバックに基づいて洗練化する。これにより、単一エージェントおよびベースライン手法を、複数のデータセットと LLM において上回る。

ABSTRACT

The advancement of natural language processing (NLP) has been significantly boosted by the development of transformer-based large language models (LLMs). These models have revolutionized NLP tasks, particularly in code generation, aiding developers in creating software with enhanced efficiency. Despite their advancements, challenges in balancing code snippet generation with effective test case generation and execution persist. To address these issues, this paper introduces Multi-Agent Assistant Code Generation (AgentCoder), a novel solution comprising a multi-agent framework with specialized agents: the programmer agent, the test designer agent, and the test executor agent. During the coding procedure, the programmer agent will focus on the code generation and refinement based on the test executor agent's feedback. The test designer agent will generate test cases for the generated code, and the test executor agent will run the code with the test cases and write the feedback to the programmer. This collaborative system ensures robust code generation, surpassing the limitations of single-agent models and traditional methodologies. Our extensive experiments on 9 code generation models and 12 enhancement approaches showcase AgentCoder's superior performance over existing code generation models and prompt engineering techniques across various benchmarks. For example, AgentCoder (GPT-4) achieves 96.3\% and 91.8\% pass@1 in HumanEval and MBPP datasets with an overall token overhead of 56.9K and 66.3K, while state-of-the-art obtains only 90.2\% and 78.9\% pass@1 with an overall token overhead of 138.2K and 206.5K.

研究の動機と目的

  • コードとテスト品質を同時に最適化する堅牢なコード生成の必要性を動機づける。
  • コード作成、テスト設計、実行の関心事を分離するマルチエージェントアーキテクチャを提案する。
  • エージェント間の協調が、単一エージェント構成よりコードの正確性とテスト網羅性を高めることを示す。

提案手法

  • 三つの専門エージェントが連続して機能する:コード生成を担当するプログラマーエージェント、多様なテストケース作成を担うテストデザイナーエージェント、ローカルでの実行とフィードバックを担当するテスト実行エージェント。
  • プログラマーエージェントはチェーンオブソート(思考過程)プロンプトを用い、理解→アルゴリズム選択→擬似コード→実装という段階的なプログラミングをシミュレートする。
  • テストデザイナーエージェントには、正確性と性能を検証するための基本テスト、エッジケーステスト、大規模テストを作成するよう促される。
  • テスト実行エージェントはデザイナーが作成したテストを用いてローカル環境でコードを実行し、実行時間とアサーションのフィードバックを返して洗練化を促す。
  • すべてのテストがパスするまで、または予算が尽きるまで反復ループを継続する。
  • 評価は 12 の LLM と 13 の最適化アプローチを、4つのデータセット(HumanEval、MBPP およびその強化版)で実施する。
Figure 1: Pipeline of AgentCoder with a code generation example from HumanEval
Figure 1: Pipeline of AgentCoder with a code generation example from HumanEval

実験結果

リサーチクエスチョン

  • RQ1RQ1: AgentCoder は基本的な LLM およびベースラインと比較してどのように性能を示すか?
  • RQ2RQ2: 三つのエージェントは効果にどう寄与するか?
  • RQ3RQ3: コードの洗練化反復は性能にどう影響するか?
  • RQ4RQ4: テストデザイナーエージェントが生成するテストの正確さはどの程度か?
  • RQ5RQ5: テストはコード網羅性の観点でどれくらい適切か?
  • RQ6RQ6: プログラマーとテストデザイナーの役割を別々のエージェントに分離すべきか?

主な発見

  • AgentCoder は、すべてのデータセットとモデルにおいて、基礎的な LLM および最適化ベースラインを一貫して上回る。
  • GPT-4 では、AgentCoder はデータセット全体で平均 pass@1 が 91.5% を達成(GPT-4 単独は 59.7%)。
  • AgentCoder は GPT-3.5-turbo を大幅に改善:HumanEval および MBPP で 79.9% の pass@1、GPT-3.5-turbo 単独の 57.3% と比較。
  • テストデザイナーエージェントは高い正確性のテストケースを生み出す(HumanEval 87.8%、MBPP 89.9%)と高いコードカバレッジ(最初の五つのテストで 84.7–87.5%)を示す。
  • 単一エージェント構成は、pass@1、テストの正確性、テスト網羅性の点でマルチエージェント設計より劣る。
  • アブレーションにより、コード生成とテスト設計の別々の役割が、統合した単一エージェント構成より大きな性能向上をもたらすことが示される。
Figure 2: A case illustration of CodeCoT and AgentCoder generated code for HumanEval task. CodeCoT ignores to use of abs() function to check further the absolute values are lower than the threshold, while AgentCoder employs it to handle the negative values.
Figure 2: A case illustration of CodeCoT and AgentCoder generated code for HumanEval task. CodeCoT ignores to use of abs() function to check further the absolute values are lower than the threshold, while AgentCoder employs it to handle the negative values.

この論文を読む

Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。

Nubintでこの論文を読む

このレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。