Skip to main content
QUICK REVIEW

[論文レビュー] GitHub Copilot: the perfect Code compLeeter?

Ilja Siroš, Dave Singelée|arXiv (Cornell University)|Jun 17, 2024
Distributed and Parallel Computing Systems被引用数 4
ひとこと要約

本稿は、自動化されたフレームワークを用いて、Java、C++、Python3、Rustの4言語で1,760問のLeetCode問題に対してGitHub Copilotのコード生成品質を評価している。CopilotはJavaとC++において最も信頼性が高く、平均的な人間の提出物よりも効率的なコードを生成するが、Python3とRustでは正しさと一貫性に欠ける。また、上位ランクの提案が常に最良ではないことも判明した。

ABSTRACT

This paper aims to evaluate GitHub Copilot's generated code quality based on the LeetCode problem set using a custom automated framework. We evaluate the results of Copilot for 4 programming languages: Java, C++, Python3 and Rust. We aim to evaluate Copilot's reliability in the code generation stage, the correctness of the generated code and its dependency on the programming language, problem's difficulty level and problem's topic. In addition to that, we evaluate code's time and memory efficiency and compare it to the average human results. In total, we generate solutions for 1760 problems for each programming language and evaluate all the Copilot's suggestions for each problem, resulting in over 50000 submissions to LeetCode spread over a 2-month period. We found that Copilot successfully solved most of the problems. However, Copilot was rather more successful in generating code in Java and C++ than in Python3 and Rust. Moreover, in case of Python3 Copilot proved to be rather unreliable in the code generation phase. We also discovered that Copilot's top-ranked suggestions are not always the best. In addition, we analysed how the topic of the problem impacts the correctness rate. Finally, based on statistics information from LeetCode, we can conclude that Copilot generates more efficient code than an average human.

研究の動機と目的

  • プログラミング問題のコード生成におけるGitHub Copilotの信頼性、正しさ、効率性を体系的かつ評価すること。
  • 言語、問題の難易度、トピック、提案順位ごとのコード品質の違いを調査すること。
  • 時間的・メモリ的効率性において、Copilotが生成したコードと平均的な人間の提出物を比較すること。
  • プロンプトの文脈や、トレーニングデータからの再現(レシターション)がCopilot出力に与える影響を評価すること。
  • LeetCodeをテストベッドとして用い、AI生成コードの評価の再現可能性を確保する自動化されたベンチマークを提供すること。

提案手法

  • 4言語(Java、C++、Python3、Rust)における、公開済みの単一関数型LeetCode問題全般に対して、Copilotの提案を自動生成・テストするフレームワーク。
  • 各問題について、複数回の問い合わせを行い、すべての提案された解決策を収集。その後、LeetCodeの自動テストスイートに提出。
  • 正しさはLeetCodeのテスト結果により判断。効率性は、LeetCodeが提供する実行時間およびメモリ消費量のメトリクスで測定。
  • 統計的分析により、言語、問題難易度(簡単/中級/難易度)および問題トピックごとのCopilotのパフォーマンスを比較。
  • レシターション検出には、Copilot出力にLeetCodeのリンクが含まれるかを検索し、トレーニングデータからの漏洩の可能性を特定。
  • 1,760問の問題ごとに結果を集約し、2か月間にわたり50,000件を超える提出物が得られた。
Figure 1: Example of a LeetCode problem. On the left part of the figure, the problem description is shown and some examples are mentioned together with the constraints imposed on the solution by LeetCode. The right part of the figure shows the solution template for the chosen programming language, c
Figure 1: Example of a LeetCode problem. On the left part of the figure, the problem description is shown and some examples are mentioned together with the constraints imposed on the solution by LeetCode. The right part of the figure shows the solution template for the chosen programming language, c

実験結果

リサーチクエスチョン

  • RQ1RQ1: コード生成段階におけるCopilotの信頼性はどの程度か。また、言語ごとに提案数と失敗率はどのように変化するか。
  • RQ2RQ2: コードの正しさは、言語、問題の難易度、提案順位、問題トピックにどのように依存するか。
  • RQ3RQ3: Copilotが生成した正解コードの時間的・メモリ的効率性は、LeetCodeにおける平均的な人間の提出物と比べてどの程度か。
  • RQ4RQ4: 特にLeetCode問題に関して、レシターション(既知の解決策の繰り返し)がCopilotの出力にどの程度発生しているか。

主な発見

  • CopilotはJavaとC++において、Python3とRustよりもコード生成の信頼性が高く、生成失敗が少なく、1問題あたりの提案数も多かった。
  • 全言語において、正しさの割合は72%を超えており、特にJavaとC++ではPython3とRustよりも顕著に高い成功率を示した。
  • 上位ランクのCopilot提案が常に最良ではなかった。最適な解決策を見つけるには複数の提案を検討する必要があった。
  • 問題トピック別では、バケットソートが最も高い正しさを示した一方、木関連の問題では最も低い正しさを示した。
  • Copilotが生成したコードは、LeetCodeにおける平均的な人間の提出物よりも時間的・メモリ的効率性に優れており、効率性指標において優れたパフォーマンスを示した。
  • レシターションは1,760問中5問で観察され、すべてPython3で発生。Copilotが出力に動作しないLeetCodeのリンクを含めており、トレーニングデータへの露出の可能性が示唆された。
Figure 2: The code of the problem before invoking Copilot. The problem’s description is added as a comment above the code template to give Copilot a context to generate a solution. Before invoking Copilot, the mouse cursor is placed inside the function that we want Copilot to generate. In this examp
Figure 2: The code of the problem before invoking Copilot. The problem’s description is added as a comment above the code template to give Copilot a context to generate a solution. Before invoking Copilot, the mouse cursor is placed inside the function that we want Copilot to generate. In this examp

より良い研究を、今すぐ始めましょう

論文の読解から最終レビューまで、研究時間を劇的に削減しましょう。

クレジットカード登録不要

このレビューはAIが作成し、人間の編集者が確認しました。