用C#工业代码微调语言模型,提升代码审查自动化效果
Fine-Tuning Multilingual Language Models for Code Review: An Empirical Study on Industrial C# Projects
- 在C#数据集上单语言微调模型,提升代码审查任务表现
- 微调后模型在评论生成等任务上准确率优于多语言基线
- 适合用于重复性审查任务,复杂语义仍需人类把关
代码审查对保障软件质量至关重要,但在工业环境中往往耗时且认知负担重。近年来语言模型(LMs)的发展为自动化核心审查任务提供了新可能。本研究对开源语言模型在三个关键自动化代码审查任务中的表现进行了实证评估:代码变更质量评估、评审意见生成和代码优化。我们在结合公开基准与工业仓库的C#专用数据集上,对CodeReviewer、CodeLlama-7B和DeepSeek-R1-Distill三款模型进行了单语言微调。研究探讨了训练数据中编程语言与自然语言配置对模型性能的影响,尤其关注意见生成效果。此外,我们将微调后的模型与自动化软件分析工具(ASAT)及人工评审员进行对比,评估其在真实场景中的实用性。结果表明,单语言微调相比多语言基线显著提升了模型的准确性和相关性。尽管语言模型能有效支持常规或重复性审查流程,但人类评审者在处理语义复杂或上下文敏感的修改时仍具优势。研究强调了语言一致性与任务特异性适配在优化语言模型用于自动化代码审查中的重要性。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。