融合规则引擎与大模型,生成更准更全的代码审查建议
Combining Large Language Models with Static Analyzers for Code Review Generation
- 在数据、推理、输出三阶段融合静态分析知识
- 相比纯规则或纯模型方法,审查建议相关性与完整性提升
- 适合需要高精度与广覆盖的工程化代码审查场景
代码审查是软件开发中关键但复杂、主观且耗时的环节。早期方法依赖基于规则的知识系统(KBS),可提供精确反馈,但在上下文复杂的场景下表现不足;近期工作转向微调预训练语言模型(LBS),虽覆盖范围广,但精度下降。本文提出一种混合方法,结合KBS与LBS优势,生成高质量、全面的代码审查意见。通过在语言模型流程的三个阶段融入知识:数据准备阶段(数据增强训练,DAT)、推理阶段(检索增强生成,RAG)和后处理阶段(输出简单拼接,NCO)。我们在真实世界数据集上评估该方法,结果表明,混合策略显著提升了评论的相关性、完整性和整体质量,有效弥合了规则工具与深度学习模型之间的差距。
原文摘要 · Abstract (English)
Code review is a crucial but often complex, subjective, and time-consuming activity in software development. Over the past decades, significant efforts have been made to automate this process. Early approaches focused on knowledge-based systems (KBS) that apply rule-based mechanisms to detect code issues, providing precise feedback but struggling with complex, context-dependent cases. More recent work has shifted toward fine-tuning pre-trained language models for code review, enabling broader issue coverage but often at the expense of precision. In this paper, we propose a hybrid approach that combines the strengths of KBS and learning-based systems (LBS) to generate high-quality, comprehensive code reviews. Our method integrates knowledge at three distinct stages of the language model pipeline: during data preparation (Data-Augmented Training, DAT), at inference (Retrieval-Augmented Generation, RAG), and after inference (Naive Concatenation of Outputs, NCO). We empirically evaluate our combination strategies against standalone KBS and LBS fine-tuned on a real-world dataset. Our results show that these hybrid strategies enhance the relevance, completeness, and overall quality of review comments, effectively bridging the gap between rule-based tools and deep learning models.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。