SWR-Bench: Assessing LLM Performance in Real-World Code Review Comment Generation

Zhengran Zeng, Ruikai Shi, Keke Han, Yixin Li, Kaicheng Sun, Yidong Wang, Zhuohao Yu, Rui Xie, Wei Ye, Shikun Zhang

TL;DR

SWR-Bench is a new, realistic benchmark consisting of 1,000 manually verified GitHub Pull Requests designed to evaluate Large Language Models (LLMs) on automated code review with full codebase context. To solve the flaws of subjective evaluation metrics, it introduces an objective, fact-matching evaluation framework that aligns closely with human judgment. Finally, the paper demonstrates that a simple multi-review aggregation strategy can dramatically boost an LLM's code review performance by up to 43.67%.

What Problem Does This Paper Address?

Automated Code Review (ACR) is essential for maintaining software quality, but existing benchmarks fail to simulate real-world development environments. Most current benchmarks evaluate models on isolated "diff hunks" or single methods without providing the full project context. This narrow scope prevents models from catching critical inter-dependency bugs across different files.

Furthermore, traditional evaluation metrics like BLEU or Exact-Match only measure superficial textual similarity, while subjective "LLM-as-judge" ratings are prone to inherent biases. To bridge this gap, the authors introduce a PR-centric benchmark with full codebase context and an objective evaluation methodology.

A comparison of traditional hunk-level review versus the proposed PR-level review paradigm with full codebase context.

Methods

The authors developed a comprehensive pipeline to construct SWR-Bench and evaluate modern LLMs:

  1. Benchmark Construction Pipeline: They scraped pull requests, utilized Gemini-2.5-Pro with a majority-voting mechanism to extract structured "change-actions," applied the SZZ algorithm to filter out missed defects, and conducted rigorous manual verification using five expert annotators.
  2. Objective LLM-based Evaluation: Instead of relying on subjective quality scores (e.g., grading a comment from 1 to 10), they designed a fact-based matching task. An LLM judge objectively verifies whether specific, structured ground-truth issues are successfully "hit" (semantically identified) by the generated review text.
  3. Multi-Review Aggregation Strategy: To combat the stochastic nature and inconsistency of single-pass LLM outputs, the authors proposed Multi-Review. This technique runs an ACR tool multiple times to generate independent draft reviews and then uses a meta-LLM prompt to synthesize them into a single, high-quality review report. They validated two approaches: Self-Aggregation (using the same model) and Multi-Aggregation (cross-model synthesis).
The SWR-Bench construction pipeline, including scraping, LLM verification, filtering, and human verification.

Datasets

The paper introduces SWR-Bench, which contains 1,000 manually verified PR instances sourced from 12 popular open-source Python projects (originally from the SWE-bench dataset). The dataset is perfectly balanced to allow robust evaluation:

  • 500 Change-PRs: Pull requests containing at least one verified, non-trivial change-action (issue).
  • 500 Clean-PRs: Pull requests explicitly verified to be free of known defects, serving as a strict testbed for measuring false-positive rates.

Key Insights and Ideas

  • Code Critique $\neq$ Code Generation: Models optimized purely for code generation underperform on code review tasks. Reviewing code demands logical deduction, counterfactual reasoning, and cross-file dependency analysis rather than simple pattern completion.
  • Reasoning Models Excel: LLMs trained with explicit reasoning-focused approaches (such as DeepSeek-R1, GPT-o3, and Gemini-2.5-Pro) consistently demonstrate superior code review capabilities.
  • Functional vs. Evolutionary Changes: Current ACR tools are significantly better at detecting functional errors (e.g., logic bugs, broken interfaces) than evolutionary improvements (e.g., documentation updates, code style adjustments). This is largely because evolutionary changes are inherently subjective, making human-model alignment difficult.
  • Cheaper Models Can Outperform Larger Ones: Aggregating multiple runs of a smaller, cheaper model (like Gemini-2.5-Flash) can cost-effectively match or exceed the code review accuracy of a single run from a larger, more expensive model (like Gemini-2.5-Pro).

Key Results

  • Current Tools Underperform: Even when paired with advanced LLMs, state-of-the-art ACR tools struggle on real-world PRs. The top-performing baseline combination (PR-Review with Gemini-2.5-Pro) achieved an overall F1 score of just 19.38%, heavily plagued by high false-positive rates.
  • High Human Alignment: The proposed objective fact-matching evaluation method achieved an exceptionally high agreement rate with human experts (~90% agreement, Cohen's Kappa up to 86.7), proving its reliability as an automated metric.
  • Massive Performance Boost via Multi-Review: Applying the Self-Aggregation strategy ($n=10$) to Gemini-2.5-Flash boosted its F1 score by 43.67% (reaching 21.91%) and increased its recall by 118.83%, demonstrating that systematic output integration dramatically mitigates LLM randomness.

Limitations and Future Work

The authors acknowledge a few key limitations and areas for future exploration:

  • Language Constraint: SWR-Bench is currently limited to Python repositories.
  • SZZ Heuristic Flaws: The initial filtering phase relies on the SZZ algorithm, which has known precision and recall limitations in identifying bug-introducing commits.
  • Context and False Positives: To mitigate the high false-positive rates observed in current models, future ACR systems must find ways to integrate historical repository data to learn implicit project-specific coding norms.
  • Training Objectives: The authors suggest moving beyond prompt engineering to explore dedicated training objectives for code critique, such as reinforcement learning with process reward models.

Summary updated

BibTeX
@article{zeng2026swr,
  author = {Zhengran Zeng and Ruikai Shi and Keke Han and Yixin Li and Kaicheng Sun and Yidong Wang and Zhuohao Yu and Rui Xie and Wei Ye and Shikun Zhang},
  title = {{SWR-Bench: Assessing LLM Performance in Real-World Code Review Comment Generation}},
  journal = {Proc. ACM Softw. Eng.},
  year = {2026},
  doi = {10.1145/3808144},
}
Figure