超越摘要:用LLM对代码变更进行结构化标签标注

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

精选理由

代码审查团队终于有了更智能的辅助——LLM自动标注变更类型(重命名/移动/逻辑修改),比人工逐行看diff高效太多,做代码审查或CI/CD集成的开发者可以直接参考。

AI 摘要

本文提出了一种基于大语言模型的两阶段流水线,用于对代码补丁中的变更进行结构化标签标注(如重命名、移动、逻辑修改等),以提升代码审查效率。该方法先对diff块进行标签分配,再精炼以捕捉结构关系和语义属性,采用少样本提示实现语言无关和可定制的标签,无需传统静态分析管线的工程开销。在人工标注的基准上,最佳配置达到了84%的召回率和81%的精确度。研究表明,LLM标签标注能有效补充静态分析,支持灵活、多语言、可自动化的代码审查工作流。

原文 · arXiv cs.AI

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

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.

超越摘要:用LLM对代码变更进行结构化标签标注 · AI 热点