arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2507.19271cs.SEcs.AIcs.PL
收藏

微调多语言语言模型用于代码审查:工业C#项目的实证研究

Fine-Tuning Multilingual Language Models for Code Review: An Empirical Study on Industrial C# Projects

Technical University Dortmund, Lovion GmbH(图鲁尼大学,洛维昂公司);Security\ Alliance Ruhr, Technical University Dortmund(安全联盟鲁尔,图鲁尼大学)

Igli Begolli, Meltem Aksoy, Daniel Neider

AI总结:

本研究通过微调CodeReviewer、CodeLlama-7B和DeepSeek-R1-Distill模型,在工业C#项目上实证发现单语微调优于多语言基线,能有效支持常规代码审查任务,但人类审查者在处理复杂变更时仍具优势。

摘要:

代码审查对于维护软件质量至关重要,但在工业环境中往往耗时且认知负担重。近期语言模型(LMs)的进展为自动化核心审查任务开辟了新途径。本研究对开源语言模型在三个关键自动化代码审查任务(代码变更质量评估、审查评论生成和代码精炼)上的单语微调性能进行了实证评估。我们在一个结合了公共基准和工业仓库的C#专用数据集上微调了三个不同的模型:CodeReviewer、CodeLlama-7B和DeepSeek-R1-Distill。我们研究了训练数据中编程语言和自然语言的不同配置如何影响语言模型的性能,特别是在评论生成方面。此外,我们将微调后的模型与自动化软件分析工具(ASAT)和人类审查者进行基准比较,以评估它们在实际场景中的实用性。我们的结果表明,与多语言基线相比,单语微调提高了模型的准确性和相关性。虽然语言模型能有效支持代码审查工作流,尤其是常规或重复性任务,但人类审查者在处理语义复杂或上下文敏感的变更方面仍然更胜一筹。我们的研究结果强调了语言对齐和任务特定适配在优化语言模型以用于自动化代码审查中的重要性。

英文摘要:

Code review is essential for maintaining software quality but often time-consuming and cognitively demanding, especially in industrial environments. Recent advancements in language models (LMs) have opened new avenues for automating core review tasks. This study presents the empirical evaluation of monolingual fine-tuning on the performance of open-source LMs across three key automated code review tasks: Code Change Quality Estimation, Review Comment Generation, and Code Refinement. We fine-tuned three distinct models, CodeReviewer, CodeLlama-7B, and DeepSeek-R1-Distill, on a C\# specific dataset combining public benchmarks with industrial repositories. Our study investigates how different configurations of programming languages and natural languages in the training data affect LM performance, particularly in comment generation. Additionally, we benchmark the fine-tuned models against an automated software analysis tool (ASAT) and human reviewers to evaluate their practical utility in real-world settings. Our results show that monolingual fine-tuning improves model accuracy and relevance compared to multilingual baselines. While LMs can effectively support code review workflows, especially for routine or repetitive tasks, human reviewers remain superior in handling semantically complex or context-sensitive changes. Our findings highlight the importance of language alignment and task-specific adaptation in optimizing LMs for automated code review.

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

↑