Harnessing Large Language Models for Curated Code Reviews

Oussama Ben Sghaier, Martin Weyssow, Houari SahraouiarXiv 2025

TL;DR

AI models designed to automate code reviews are severely bottlenecked by the noisy, unrefined nature of open-source datasets. This paper introduces an automated, LLM-driven curation pipeline that filters out irrelevant reviews and reformulates the remaining comments for clarity and civility. Fine-tuning downstream models on this newly curated dataset yields a 46% improvement in automated comment generation and a 22% boost in code refinement accuracy.

What Problem Does This Paper Address?

Automating code reviews using deep learning could drastically reduce the manual workload of software developers. However, current models suffer from a classic machine learning trap: garbage in, garbage out.

Existing code review datasets are typically scraped raw from public repositories. As a result, they are riddled with noise—ranging from vague or overly verbose remarks to outright uncivil comments (e.g., "this is gross"). This lack of structure and clarity hinders an AI's ability to learn how to generate high-quality, actionable feedback or successfully modify code based on a reviewer's instructions. The authors set out to systematically evaluate and clean the largest publicly available code review dataset to see if better data quality directly translates to smarter code-analysis models.

Methods

The authors developed a two-phase approach: an evaluation framework and a curation pipeline.

  1. Evaluation Framework: They established a multi-dimensional schema to categorize comments by Type (e.g., Bugfix, Refactoring), Nature (Prescriptive, Descriptive, Clarification), and Civility (Civil vs. Uncivil). Comments were also scored from 1 to 10 on Relevance, Clarity, and Conciseness.
  2. LLM-as-a-Judge & Editor: Because manually labeling 176,613 samples is impossible, they leveraged Llama-3.1-70B to automatically score and categorize the dataset. A human sanity check on a subset validated that the LLM's judgments closely aligned with human consensus.
  3. The Curation Pipeline: Comments scoring below a threshold for relevance were purged. The remaining comments were passed back to Llama-3.1-70B with explicit instructions to rewrite them—improving clarity, conciseness, and professionalism while strictly preserving the original engineering intent.

Finally, to prove the value of this curation, they fine-tuned DeepSeek-6.7B-Instruct using Low-Rank Adaptation (LoRA) on both the raw and curated datasets to compare performance on downstream tasks.

Fig. 1: Overview of our methodology. We use a large code review dataset of samples comprising pre-commit and post-commit codes along with review comments. For each sample, we use LLM-as-a-Judge with Llama-3.1-70B to generate a reformulated review comment, a categorization of the review, and a score for the original review comment. Next, we use the reformulated review comments to create our curated dataset, while filtering out irrelevant samples. Finally, we compare the effectiveness of LLMs fine-tuned on the original and curated datasets on two downstream tasks: comment generation and code refinement.

Datasets

The study utilizes the largest publicly available multilingual code review dataset (originally introduced by Li et al.), which contains 176,613 samples spanning nine programming languages (including Python, Java, C++, and Go).

After running the curation pipeline, the authors introduced CuRev, a filtered and polished version of the dataset containing 170,718 high-quality samples.

Key Insights and Ideas

  • The "Form" Matters for Code Fixes: Intriguingly, rewriting a comment to be clearer and more professional doesn't just help models generate better comments; it also helps code refinement models implement the requested fixes more accurately. Clearer instructions reduce semantic ambiguity for the AI.
  • Shifting to Actionable Feedback: The curation pipeline caused a massive shift in the dataset's composition, moving it from 62.6% to 90.2% "Prescriptive" comments. This means the dataset evolved from passive descriptions of code states to active, directive guidance.
  • LLMs are Inherently Verbose: While the pipeline drastically improved comment clarity (jumping from an average score of 6.89 to 8.96), the improvement in conciseness was much more modest (7.71 to 8.05). This highlights a known trait of LLMs: their tendency to generate elaborate, well-padded text by default.
Fig. 2: Overview of our evaluation framework.

Key Results

The downstream impacts of training on the curated CuRev dataset versus the original raw dataset were stark:

  • Comment Generation: The model fine-tuned on CuRev achieved a BLEU score of 11.26, compared to 7.71 on the original dataset—a 46% relative improvement in generating accurate text.
  • Code Refinement: When the model was tasked with actually fixing code based on a review comment, using the curated comments pushed the CodeBLEU score from 0.36 to 0.44 (a 22% improvement).
  • Exact Matches: The number of code refactorings that perfectly matched the ground-truth code changes grew from 408 to 445.
  • Civility: Uncivil comments were completely eliminated, resulting in a 100% professional dataset.

Limitations and Future Work

A primary limitation is the reliance on a single LLM (Llama-3.1-70B) as both the judge and the editor, which can introduce subtle model-specific biases into the dataset.

To address this, the authors propose incorporating multiple LLMs as a jury in future iterations to foster more diverse and robust review styles. They also plan to explore prioritization strategies, helping automated tools flag pull requests based on urgency and relevance rather than treating all code changes equally.

Summary updated

BibTeX
@misc{sghaier2025harnessing,
  author = {Oussama Ben Sghaier and Martin Weyssow and Houari Sahraoui},
  title = {{Harnessing Large Language Models for Curated Code Reviews}},
  year = {2025},
  eprint = {2502.03425},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.03425},
}
Figure