Meta用AI自动修复代码评审意见,提升效率并避免拖慢开发流程。
AI-Assisted Fixes to Code Review Comments at Scale
- 基于6.4万条数据微调Llama模型,生成符合工程规范的补丁。
- 生产环境应用后,可操作建议转化为实际修改率达19.7%,比GPT-4o高9.2个百分点。
- 通过用户界面优化避免影响评审速度,适合大规模工程团队使用。
Meta每周处理数万条代码评审意见。我们开发了用于代码评审的AI助手MetaMateCR,支持在生产环境中大规模应用。为训练模型,构建了包含64,000个<评审意见, 补丁>的数据集,并微调Llama模型。离线测试中,大型微调模型(LargeLSFT)生成完全匹配补丁的比例达68%,优于GPT-4o的59个百分点。该模型更倾向于使用现代的Hack函数,而非GPT-4o推荐的PHP函数。在安全试验中,初始版本导致评审时间增加超5%;经调整仅向作者展示补丁后,评审时间恢复稳定。正式上线后,大型模型使可操作建议转化为实际修改的比例达到19.7%,较GPT-4o提升9.2个百分点。结果表明,安全试验对防止AI意外降低开发效率至关重要,且该系统已在大规模生产中成功运行。
原文摘要 · Abstract (English)
Aim. There are 10s of thousands of code review comments each week at Meta. We developed Metamate for Code Review (MetaMateCR) that provides AI-assisted fixes for reviewer comments in production at scale. Method. We developed an internal benchmark of 64k <review comment, patch> data points to fine-tune Llama models. Once our models achieve reasonable offline results, we roll them into production. To ensure that our AI-assisted fixes do not negatively impact the time it takes to do code reviews, we conduct randomized controlled safety trials as well as full production experiments. Offline Results. As a baseline, we compare GPT-4o to our small and large Llama models. In offline results, our LargeLSFT model creates an exact match patch 68% of the time outperforming GPT-4o by 9 percentage points (pp). The internal models also use more modern Hack functions when compared to the PHP functions suggested by GPT-4o. Safety Trial. When we roll MetaMateCR into production in a safety trial that compares no AI patches with AI patch suggestions, we see a large regression with reviewers taking over 5% longer to conduct reviews. After investigation, we modify the UX to only show authors the AI patches, and see no regressions in the time for reviews. Production. When we roll LargeLSFT into production, we see an ActionableToApplied rate of 19.7%, which is a 9.2pp improvement over GPT-4o. Our results illustrate the importance of safety trials in ensuring that AI does not inadvertently slow down engineers, and a successful review comment to AI patch product running at scale.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。