LLMs have shown strong potential for automating code review, yet their practical utility depends heavily on the design of generation and context strategies. In this paper, we investigate how to improve LLM-based code review through generation strategy and contextual augmentation. We first propose an issue-list review paradigm, in which LLMs enumerate all potential issues rather than reporting only the single most important one (i.e., primary-issue review). We then systematically compare three types of code context augmentation -- neighboring, LSP-based semantics, and IR-based similar co-change context -- and study how they influence issue discovery. Finally, we integrate candidates from no-context and context-enhanced generation to improve review coverage, and introduce refinement-guided pruning to keep the candidate list at a practical size. We evaluate our approach on 1,438 Go review instances using downstream code refinement as the main metric, i.e., how often the candidate list contains at least one comment inducing the same code change as the final human revision. For comparison, we evaluate comments by CodeReviewer, a model trained specifically for review comment generation, as well as ground-truth human review comments (as a practical upper bound), under the same refinement-based evaluation. The results show that our best configuration, combining issue-list review, neighboring and similar co-change context, and candidate integration, reaches 28.00% refinement exact match, a statistically significant gain of +10.85 percentage points over primary-issue review without any additional context (17.15%), substantially outperforming CodeReviewer (15.02%) and approaching the human-oracle ceiling of 36.09%. Our refinement-guided pruning reduces the average candidate count from 7.2 to 3.1 at top-5 while retaining nearly the full benefit, making the candidate list easier to inspect.


翻译:大语言模型在自动化代码审查方面展现出强大潜力,但其实际效用高度依赖于生成与上下文策略的设计。本文研究如何通过生成策略与上下文增强来改进基于LLM的代码审查。我们首先提出一种基于问题列表的审查范式,要求LLM列举所有潜在问题而非仅报告最重要的单一问题(即主问题审查)。随后系统比较三类代码上下文增强——邻域代码、基于LSP的语义信息及基于IR的相似共变更上下文——并探究其对问题发现的影响。最后,我们将无上下文与上下文增强生成结果进行集成以提升审查覆盖率,并引入精炼引导剪枝策略使候选列表保持实用规模。我们在1,438个Go语言审查实例上评估该方法,以下游代码精炼为核心评估指标,即候选列表中至少包含一个能催生与最终人工修订完全一致代码变更的评论的频次。作为对比,我们采用相同精炼指标评估CodeReviewer(专为审查评论生成训练的模型)生成的评论及人工审查评论(作为实际基准上限)。结果表明,结合问题列表审查、邻域与相似共变更上下文及候选集集成的最佳配置,在精炼精确匹配率达28.00%,相较于无辅助上下文的主问题审查(17.15%)实现+10.85个百分点的统计显著提升,显著超越CodeReviewer(15.02%)并逼近人工预测上限(36.09%)。精炼引导剪枝策略在Top-5候选集中将平均候选数量从7.2降至3.1,同时保持近乎完整的收益,使候选列表更易审查。

0
下载
关闭预览

相关内容

大语言模型中的检索与结构化增强生成综述
专知会员服务
34+阅读 · 2025年9月17日
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
如何检测LLM内容?UCSB等最新首篇《LLM生成内容检测》综述
万字长文: 检索增强 LLM
专知会员服务
111+阅读 · 2023年9月17日
高效的文本生成方法 — LaserTagger 现已开源
TensorFlow
30+阅读 · 2020年2月27日
强化学习与文本生成
微信AI
41+阅读 · 2019年4月4日
最新论文解读 | 基于预训练自然语言生成的文本摘要方法
微软研究院AI头条
57+阅读 · 2019年3月19日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
6+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
7+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
4+阅读 · 6月17日
相关VIP内容
相关基金
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员