[Paper Review] Exploring the Potential of ChatGPT in Automated Code Refinement: An Empirical Study
The paper empirically evaluates ChatGPT for code refinement based on review comments, showing better generalization than CodeReviewer on new datasets but with room for improvement, and analyzes prompts, temperature, and root causes of errors.
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.
Motivation & Objective
- Assess ChatGPT's ability to refine code based on review comments compared to the state-of-the-art CodeReviewer.
- Identify settings (prompts and temperature) that maximize ChatGPT performance.
- Examine situations where ChatGPT underperforms and uncover root causes.
- Propose mitigation strategies and create a high-quality CodeReview-New dataset for generalization assessment.
Proposed method
- Use CodeReview as a baseline and construct CodeReview-New to test generalization.
- Evaluate ChatGPT with zero-shot GPT-3.5-Turbo against CodeReviewer on multiple datasets.
- Systematically vary prompts and temperature to assess impact on EM and BLEU metrics.
- Introduce EM-trim and BLEU-trim to better reflect practical code refinement outcomes.
- Perform qualitative analysis on failure cases to identify root causes and mitigation strategies.
- Optionally compare GPT-4 (GPT-4) in RQ4 for underperforming cases.

Experimental results
Research questions
- RQ1RQ1: How do different ChatGPT prompts and temperature settings affect code refinement performance?
- RQ2RQ2: How does ChatGPT compare to the state-of-the-art CodeReviewer on standard and new datasets?
- RQ3RQ3: In which cases does ChatGPT perform well or poorly, and what qualitative patterns emerge?
- RQ4RQ4: What are the root causes of ChatGPT underperforming cases and how can they be mitigated?
Key findings
- Lower temperature (0) and concise prompts generally yield the strongest and most stable results.
- Prompt variants with scenario descriptions (P2, P5) outperform others, while overly detailed prompts (P3) can hurt performance.
- On the CodeReview-New dataset, ChatGPT outperforms CodeReviewer in EM-T and BLEU-T (EM-T: 22.78 vs 15.50; BLEU-T: 76.44 vs 62.88).
- ChatGPT achieves higher EM and BLEU on CodeReview-New compared to CodeReview, indicating better generalization to unseen languages and reviews.
- ChatGPT's EM on CodeReview (CR) is 16.70 (EM), 19.47 (EM-T); BLEU 68.26, BLEU-T 75.12, highlighting room for improvement on existing benchmarks.
- Root-cause analysis identifies understanding reviews, over-deletion, extra modifications, and ground-truth ambiguities as key failure modes.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.