Skip to main content
QUICK REVIEW

[論文レビュー] Exploring the Potential of ChatGPT in Automated Code Refinement: An Empirical Study

Qi Guo, Junming Cao|arXiv (Cornell University)|Sep 15, 2023
Software Engineering Research被引用数 9
ひとこと要約

本論文は、レビューコメントに基づくコード改良のためのChatGPTを実証的に評価し、新しいデータセットでCodeReviewerより一般化性能が高いことを示す一方で改善の余地があることを示し、プロンプト・温度設定・エラーの根本原因を分析している。

ABSTRACT

Code review is an essential activity for ensuring the quality and maintainability of software projects. However, it is a time-consuming and often error-prone task that can significantly impact the development process. Recently, ChatGPT, a cutting-edge language model, has demonstrated impressive performance in various natural language processing tasks, suggesting its potential to automate code review processes. However, it is still unclear how well ChatGPT performs in code review tasks. To fill this gap, in this paper, we conduct the first empirical study to understand the capabilities of ChatGPT in code review tasks, specifically focusing on automated code refinement based on given code reviews. To conduct the study, we select the existing benchmark CodeReview and construct a new code review dataset with high quality. We use CodeReviewer, a state-of-the-art code review tool, as a baseline for comparison with ChatGPT. Our results show that ChatGPT outperforms CodeReviewer in code refinement tasks. Specifically, our results show that ChatGPT achieves higher EM and BLEU scores of 22.78 and 76.44 respectively, while the state-of-the-art method achieves only 15.50 and 62.88 on a high-quality code review dataset. We further identify the root causes for ChatGPT's underperformance and propose several strategies to mitigate these challenges. Our study provides insights into the potential of ChatGPT in automating the code review process, and highlights the potential research directions.

研究の動機と目的

  • 最新鋭のCodeReviewerと比較して、レビューコメントに基づくコード改良能力をChatGPTが有するか評価する。
  • ChatGPTの性能を最大化する設定(プロンプトと温度)を特定する。
  • ChatGPTが性能を発揮できない状況を検討し、根本原因を明らかにする。
  • 対策案を提案し、一般化評価のための高品質なCodeReview-Newデータセットを作成する。

提案手法

  • CodeReviewをベースラインとして用い、一般化を検証するためにCodeReview-Newを構築する。
  • 複数データセットでCodeReviewerと比較して、ゼロショットのGPT-3.5-TurboでChatGPTを評価する。
  • EMとBLEU指標への影響を評価するために、プロンプトと温度を系統的に変化させる。
  • 実務的なコード改良の結果をより適切に反映するためにEM-trimとBLEU-trimを導入する。
  • 失敗ケースの定性的分析を行い、根本原因と対策を特定する。
  • RQ4で不調ケースについて任意でGPT-4を比較する。
Figure 1. Overview of our study
Figure 1. Overview of our study

実験結果

リサーチクエスチョン

  • RQ1RQ1: 異なるChatGPTのプロンプトと温度設定は、コード改良の性能にどう影響するか。
  • RQ2RQ2: 標準データセットと新しいデータセットにおいて、ChatGPTは最先端のCodeReviewerとどのように比較されるか。
  • RQ3RQ3: ChatGPTが良好に機能するケースと悪化するケースはどのようなもので、どんな定性的パターンが現れるか。
  • RQ4RQ4: ChatGPTの低性能ケースの根本原因は何で、どのように緩和できるか。

主な発見

データセットツールサンプルEMEM-TBLEUBLEU-T
CRCodeReviewer13,10432.4932.5583.3983.50
CRChatGPT16.7019.4768.2675.12
CRNCodeReviewer14,56814.8415.5062.2562.88
CRNChatGPT19.5222.7872.5676.44
CRNTCodeReviewer9,11715.7516.3162.0162.47
CRNTChatGPT19.6022.4472.9076.55
CRNLCodeReviewer5,45113.2114.0562.6763.61
CRNLChatGPT19.3923.4071.9776.25
  • 低温度(0)と簡潔なプロンプトは、一般に最も強力で安定した結果をもたらす。
  • シナリオ説明を含むプロンプトのバリエーション(P2,P5)は他より優れており、過度に詳細なプロンプト(P3)は性能を損なう可能性がある。
  • CodeReview-Newデータセットでは、EM-TとBLEU-TでChatGPTがCodeReviewerを上回る(EM-T: 22.78 vs 15.50; BLEU-T: 76.44 vs 62.88)。
  • ChatGPTがCodeReview-NewにおけるEMとBLEUをCodeReviewより高く、未知の言語やレビューへの一般化が向上していることを示唆している。
  • CodeReview(CR)でのChatGPTのEMは16.70(EM)、19.47(EM-T);BLEUは68.26、BLEU-Tは75.12で、既存ベンチマークの改善余地を示している。
  • 根本原因分析では、レビューの理解、過剰削除、追加修正、真実値の曖昧さを主要な失敗モードとして特定している。
Figure 2. Construction strategies of Prompt 1 and Prompt 2
Figure 2. Construction strategies of Prompt 1 and Prompt 2

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

論文設計から論文執筆まで、研究時間を劇的に削減しましょう。

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

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