Skip to main content
QUICK REVIEW

[論文レビュー] Evaluating the Code Quality of AI-Assisted Code Generation Tools: An Empirical Study on GitHub Copilot, Amazon CodeWhisperer, and ChatGPT

Burak Yetiştiren, Işık Özsoy|arXiv (Cornell University)|Apr 21, 2023
Software Engineering ResearchComputer Science被引用数 68
ひとこと要約

HumanEvalベンチマークを用いて、GitHub Copilot、Amazon CodeWhisperer、ChatGPT のコード品質を実証的に比較し、validity(妥当性)、correctness(正確性)、security(セキュリティ)、reliability(信頼性)、maintainability(保守性)を測定する。

ABSTRACT

Context: AI-assisted code generation tools have become increasingly prevalent in software engineering, offering the ability to generate code from natural language prompts or partial code inputs. Notable examples of these tools include GitHub Copilot, Amazon CodeWhisperer, and OpenAI's ChatGPT. Objective: This study aims to compare the performance of these prominent code generation tools in terms of code quality metrics, such as Code Validity, Code Correctness, Code Security, Code Reliability, and Code Maintainability, to identify their strengths and shortcomings. Method: We assess the code generation capabilities of GitHub Copilot, Amazon CodeWhisperer, and ChatGPT using the benchmark HumanEval Dataset. The generated code is then evaluated based on the proposed code quality metrics. Results: Our analysis reveals that the latest versions of ChatGPT, GitHub Copilot, and Amazon CodeWhisperer generate correct code 65.2%, 46.3%, and 31.1% of the time, respectively. In comparison, the newer versions of GitHub CoPilot and Amazon CodeWhisperer showed improvement rates of 18% for GitHub Copilot and 7% for Amazon CodeWhisperer. The average technical debt, considering code smells, was found to be 8.9 minutes for ChatGPT, 9.1 minutes for GitHub Copilot, and 5.6 minutes for Amazon CodeWhisperer. Conclusions: This study highlights the strengths and weaknesses of some of the most popular code generation tools, providing valuable insights for practitioners. By comparing these generators, our results may assist practitioners in selecting the optimal tool for specific tasks, enhancing their decision-making process.

研究の動機と目的

  • 実世界のプロンプトに対する主要なAI支援コード生成ツールの全体的なコード品質を評価する。
  • 生成コードの妥当性、正確性、セキュリティ、信頼性、保守性の強みと弱みを把握する。
  • ドックストリングと意味のある関数名がコード品質に与える影響を検討する。
  • ツールのバージョン間での進化を追跡し、改善点を理解する。

提案手法

  • 評価基盤として、関数プロンプト、ドックストリング、単体テストを含むHumanEvalデータセットを使用する。
  • GitHub Copilot、Amazon CodeWhisperer、ChatGPTを通常のIDE/ブラウザ環境でコードを生成する。
  • Pythonにおける直接実行によって構文/実行時エラーを検出し、コードの妥当性を評価する。
  • 単体テストを用いてコードの正確性を評価する;Code Correctness Scoreを「合格したテスト数 / 総テスト数」として算出する。
  • SonarQubeを使用してCode Security(脆弱性)、Code Reliability(バグ)、Code Maintainability(コードの匂い)を測定する。
  • 追加の2つの実験を実施する: (i) inputsの影響を測るためにドックストリングを削除する(RQ2)、 (ii) ダミーの関数名に置換して命名の影響を測る(RQ3)。
  • ツールの更新版をテストして時間経過による性能を比較する(RQ4)。
Figure 1: Example Problem (ID: 0) from HumanEval dataset
Figure 1: Example Problem (ID: 0) from HumanEval dataset

実験結果

リサーチクエスチョン

  • RQ1RQ1: ツールが生成するコードの品質は、妥当性、正確性、セキュリティ、信頼性、保守性の観点でどの程度か。
  • RQ2RQ2: ドックストリングは生成コードの品質にどのような影響を与えるか。
  • RQ3RQ3: 意味のある関数名を使用することは生成コードの品質にどのような影響を与えるか。
  • RQ4RQ4: バージョン間でコード生成ツールはどのように進化するか。

主な発見

  • ChatGPT は、3つのツールの中で最高の妥当性(93.3%)、正確性(65.2% 正解)、および平均正確性(78.1%)を生み出した。
  • GitHub Copilot は問題のうち 91.5% で有効なコードを生成し、解の 46.3% が正解だった。30.5% は不正確で、23.2% は部分的に正解だった。
  • Amazon CodeWhisperer は問題のうち 90.2% で有効なコードを生成し、解の 31.1% が正解だった。28.7% は不正確で、40.2% は部分的に正解だった。
  • Code Quality は security/reliability/maintainability に関して、いずれのツールも最大閾値を下回るセキュリティ評価にはならず、Copilot、CodeWhisperer、および ChatGPT はそれぞれの問題の一部で小さなバグやコードの匂いを伴った(Copilot: 3つのバグ; CodeWhisperer: 1つのバグ; ChatGPT: 2つのバグ; maintainabilityの匂いはツール間で異なる)。
  • ドックストリングを除去する(RQ2)は、関数のシグネチャだけが与えられた場合、正確性を大幅に低下させた(例: Copilot の正解率は 46.3% → 20.1% に低下; CodeWhisperer は 31.1% → 14.6% に低下; ChatGPT は 65.2% → 22.0% に低下)。
  • ダミーの関数名を使用する(RQ3)は、一般に妥当性と正確性を低下させる傾向だが、ある程度の有用性を維持した。妥当性は高いままだったが、正確性は低下した(例: Copilot は元の 46.3% 正解 → ダミー名使用時 42.1%)。
  • 時間とともに(RQ4)、Copilot の妥当性は新しいバージョンで約 91.5% を維持した。一方、CodeWhisperer は初期の結果から 95.1% から 90.2% に低下した。
Figure 2: Experimental Setup
Figure 2: Experimental Setup

この論文を読む

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

Nubintでこの論文を読む

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