arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.26100cs.SEcs.AI
收藏

超越摘要:基于结构感知的代码变更标注与大型语言模型

Beyond Summaries: Structure-Aware Labeling of Code Changes with Large Language Models

Viterbi Faculty of Electrical and Computer Engineering(电气与计算机工程学院);IBM Research(IBM研究院)

Bar Weiss, Antonio Abu-Nassar, Adi Sosnovich, Karen Yorav

AI总结:

提出两阶段流水线,利用大型语言模型对代码补丁中的变更进行基于分类的标注,捕获结构关系和语义属性,以提升代码审查效率。

摘要:

代码审查是软件工程中的关键实践,然而现代项目中代码补丁的规模和频率不断增长,加上AI代码助手的广泛采用,使得人工审查越来越具有挑战性。识别补丁中的变更类型(如重命名、移动或逻辑修改)可以通过实现优先级排序、过滤和自动化来显著提高审查效率。然而,现有的基于LLM的代码审查方法主要集中在摘要和评论生成上,结构化代码审查尚未得到充分探索。在本文中,我们系统研究了使用大型语言模型(LLMs)对代码补丁中的代码变更进行基于分类的标注。我们引入了一个两阶段流水线,首先为差异块分配标签,然后对其进行细化以捕获结构关系和语义属性,例如重命名传播和类型变更。我们的方法采用少样本提示来生成与语言无关且可定制的标签,无需传统静态分析流水线的工程开销。我们在一个手动策划的自然和合成补丁基准上,跨多个上下文配置评估了四个LLM。我们的最佳配置实现了高达84%的召回率和81%的精确率,并在提取关系和属性元数据方面具有高准确性。这些结果表明,基于LLM的标注可以通过实现灵活、多语言和自动化友好的代码审查工作流,有效补充静态分析。

英文摘要:

Code review is a critical practice in software engineering, yet the growing scale and frequency of code patches in modern projects, together with the widespread adoption of AI code assistants, make manual review increasingly challenging. Identifying the types of changes within a patch, such as renames, moves, or logic modifications, can substantially improve review efficiency by enabling prioritization, filtering, and automation. However, existing LLM-based approaches to code review have largely focused on summarization and comment generation, leaving structured code reviews underexplored. In this paper, we present a systematic study of using large language models (LLMs) for taxonomy-based labeling of code changes in a code patch. We introduce a two-stage pipeline that assigns labels to diff hunks and then refines them to capture structural relationships and semantic attributes, such as rename propagation and type changes. Our approach employs few-shot prompting to produce language-agnostic and customizable labels, without the engineering overhead of traditional static-analysis pipelines. We evaluate four LLMs across multiple context configurations on a manually curated benchmark of natural and synthetic patches. Our best configuration achieves up to $84\%$ recall and $81\%$ precision, with high accuracy in extracting relational and attribute metadata. These results suggest that LLM-based labeling can effectively complement static analysis by enabling flexible, multilingual, and automation-friendly code review workflows.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑