A Note on the Code Quality Score System: LLMs for Maintainable Large Codebases

Jalaj Bhandari, Sherman Wong, Fan YangDL4C @ NeurIPS 2025

TL;DR

Meta researchers have developed the Code Quality Score (CQS) system, a novel approach using fine-tuned Llama 3 LLMs to automatically detect and flag code quality issues in large codebases. This system, which incorporates a multi-agent design and human feedback for continuous improvement, has achieved a 60% weekly user-reported helpfulness rate among Meta developers, demonstrating its practical value in maintaining code quality at scale.

What Problem Does This Paper Address?

Maintaining high code quality in massive, concurrently developed software systems is a significant hurdle. Traditional static analysis tools often fall short in identifying nuanced issues like code modularity, readability, and error handling. While human code reviews are effective, they are time-consuming and can become a bottleneck, especially in large organizations. This paper tackles the challenge of automating code quality evaluation and review generation in a scalable and developer-friendly manner, aiming to reduce the burden on human reviewers and improve overall codebase health.

Methods

The CQS system employs a multi-agent architecture built upon Llama 3 LLMs. It breaks down the code review process into three key tasks:

  1. Issue Collection: An "issue collector" agent, fine-tuned using Supervised Fine-Tuning (SFT) and offline Reinforcement Learning (RL) via Direct Preference Optimization (DPO), identifies potential code quality issues. This agent is trained on human-reviewed diffs and uses a set of predefined tags and rules to categorize issues.
  2. Issue Validation: An "issue validator" agent, also powered by a fine-tuned LLM (referred to as an "LLM-judge"), critically assesses the relevance and correctness of the issues flagged by the collector. It assigns a score from 0-10 to each issue.
  3. Post-processing: A "post-processing" agent applies hand-crafted rules and thresholds to further filter out low-scoring or invalid issues before presenting them to developers.

The LLM-judge model is crucial for both generating preference pairs for DPO training and for validating issues. It's trained on developer feedback, including critiques and thumbs up/down signals, to improve its ability to assess code review quality.

Datasets

  • Training Data: The CQS system was trained on a dataset of 5000 (diff, code review) pairs collected from Meta's internal codebase, covering multiple programming languages. This data was curated to include only high-quality issues derived from human comments. For DPO training, preference pairs were generated using LLM-judge scores.
  • Evaluation Data: For evaluation, the authors collected 200 diffs across various projects and languages. Code reviews for these diffs were generated by state-of-the-art LLMs (GPT-40, Claude 3.7 Sonnet, Gemini-2.5-pro). These candidate reviews were then manually validated by multiple senior engineers to establish a ground truth, with only issues where engineers agreed being kept.

Key Insights and Ideas

  • LLMs as Code Reviewers: The paper demonstrates that fine-tuned LLMs can effectively automate significant parts of the code quality evaluation process, moving beyond simple linting to nuanced issue detection.
  • Multi-Agent System for Robustness: The three-agent architecture (collector, validator, post-processor) is key to achieving high precision. The validator and post-processing steps act as crucial sanity checks, filtering out incorrect or irrelevant suggestions from the initial collector.
  • The Power of LLM-Judge: The "LLM-judge" model, fine-tuned on developer feedback, is instrumental. It not only helps in creating preference data for DPO but also serves as a critical component for validating issues, outperforming off-the-shelf models in this specialized task.
  • Developer Feedback as a Flywheel: The system is designed to continuously improve by leveraging developer feedback. This feedback loop is essential for aligning the LLM's output with actual developer preferences and for identifying new types of issues.
  • Precision Over Recall for Trust: The system prioritizes precision to build developer trust, meaning it's better to miss some issues (lower recall) than to flag incorrect ones (low precision). This is reflected in the system's design and evaluation metrics.

Key Results

  • Impressive Precision: The CQS system, after incorporating the validator and post-processing agents, achieved a precision rate of 78.20%, a significant improvement over just the issue collector agent (13.48%).
  • High User Helpfulness: The system has been rolled out to over 5000 engineers at Meta and consistently achieves a 60% weekly user-reported helpfulness rate.
  • SFT + DPO Synergy: Combining Supervised Fine-Tuning (SFT) with Direct Preference Optimization (DPO) for the issue collector agent yielded the best results, improving both precision (13.48%) and recall (9.25%) compared to other fine-tuning recipes.
  • LLM-Judge Performance: The fine-tuned LLM-judge model showed a 62% accuracy in evaluating code reviews, outperforming a base Llama 3.1-70b Instruct model (56%).

Limitations and Future Work

  • Evaluation Dataset Bias: The authors acknowledge that their evaluation dataset is biased towards the LLMs used to generate candidate reviews (GPT-40, Claude 3.7 Sonnet, Gemini-2.5-pro), and that human validation might also be influenced by this.
  • LLM-Judge Importance: The performance of the LLM-judge model is critical for DPO training, highlighting the importance of high-quality reward models, even with limited human annotations.
  • Extracting Actionable Comments: Extracting high-quality, actionable code review comments remains a challenge.
  • Future Directions: The team plans to further enhance CQS by leveraging online developer feedback for continuous improvement. They also aim to expand its capabilities beyond code quality to identify complex issues like security vulnerabilities and performance problems. Exploring alternative LLMs and more sophisticated training techniques for the LLM-judge are also on the horizon.

Summary updated

BibTeX
@inproceedings{bhandari2025note,
  author = {Jalaj Bhandari and Sherman Wong and Fan Yang},
  title = {{A Note on the Code Quality Score System: LLMs for Maintainable Large Codebases}},
  booktitle = {DL4C @ NeurIPS},
  year = {2025},
  url = {https://openreview.net/forum?id=9HgWk7tKPi},
}
Figure