arXiv:2605.26100cs.SEcs.AI2026-05

用大模型自动识别代码修改类型,提升审查效率。

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

论文配图:Beyond Summaries: Structure-Aware Labeling of Code Changes with Large Language Models
图 1 · 摘自论文原文
  • 分两阶段标注代码变更,捕捉结构关系与语义属性
  • 最高84%召回率、81%精确度,准确提取关联与属性信息
  • 无需工程开发,支持多语言和自动化审查流程

代码审查是软件工程中的关键实践,但现代项目中代码补丁规模与频率不断增长,加之AI代码助手的普及,使得人工审查日益困难。识别补丁中代码变更的类型(如重命名、移动、逻辑修改)可显著提升审查效率,实现优先级排序、过滤与自动化。然而,现有基于大模型的代码审查方法主要聚焦于摘要生成与注释,对结构化审查关注不足。本文系统研究了使用大语言模型(LLM)对代码补丁进行分类标签标注的方法。提出一种两阶段流程:先为diff hunks分配标签,再通过上下文推理优化以捕捉结构关系与语义属性(如重命名传播、类型变化)。该方法采用少样本提示(few-shot prompting),生成语言无关且可定制的标签,避免传统静态分析流水线的工程开销。在人工整理的自然与合成补丁基准上,评估四种LLM在多种上下文配置下的表现。最佳配置达到84%召回率与81%精确度,并在提取关系与属性元数据方面保持高准确性。结果表明,基于大模型的标签化可有效补充静态分析,推动灵活、多语言、可自动化的代码审查工作流。

原文摘要 · Abstract (English)

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.

代码审查大模型结构标注自动化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。