Migrating Code At Scale With LLMs At Google
作者: Celal Ziftci, Stoyan Nikolov, Anna Sjövall, Bo Kim, Daniele Codecasa, Max Kim
分类: cs.SE, cs.AI
发布日期: 2025-04-13
💡 一句话要点
利用LLM在Google规模化迁移代码,提升开发效率
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 代码迁移 大型语言模型 自动化 软件工程 代码生成
📋 核心要点
- 代码迁移是软件系统演进中的常见维护任务,但手动迁移耗时费力,开发者体验差,自动化需求强烈。
- 该论文提出一种基于变更位置发现和大型语言模型(LLM)的自动化迁移算法,旨在提升迁移效率。
- 实验结果表明,该方法能够显著减少人工干预,代码变更生成比例达74.45%,编辑生成比例达69.46%,并节省50%的时间。
📝 摘要(中文)
本文探讨了Google一项大规模、高成本且传统上依赖手动完成的代码迁移项目。针对此类迁移工作耗时费力、开发者积极性不高且耗时数年的问题,提出了一种新颖的自动化算法,该算法利用变更位置发现和大型语言模型(LLM)来辅助开发者进行迁移。通过对三位开发者在十二个月内进行的39项不同迁移的案例研究,结果表明共提交了595个代码变更,包含93,574处编辑,其中74.45%的代码变更和69.46%的编辑由LLM生成。开发者对自动化工具的满意度很高,并估计与之前的手动迁移相比,总花费时间减少了50%。研究结果表明,这种自动化的、LLM辅助的工作流程可以作为类似举措的典范。
🔬 方法详解
问题定义:论文旨在解决大规模代码迁移过程中,人工操作繁琐、耗时且容易出错的问题。现有的手动迁移方法效率低下,且开发者通常不愿意承担此类重复性工作。因此,如何利用自动化工具来提高代码迁移的效率和质量是本文要解决的核心问题。
核心思路:论文的核心思路是利用大型语言模型(LLM)的代码生成能力,结合变更位置发现技术,自动生成迁移所需的代码变更。通过分析代码库中的变更模式,LLM可以学习到迁移的规则和模式,从而自动完成大部分的迁移工作,减少人工干预。
技术框架:该方法主要包含两个阶段:变更位置发现和LLM代码生成。首先,通过分析代码库的历史变更记录,识别出需要进行迁移的代码位置。然后,利用LLM根据迁移规则和目标代码风格,自动生成相应的代码变更。开发者可以对LLM生成的代码进行审查和修改,最终完成迁移。
关键创新:该方法最重要的创新点在于将LLM应用于大规模代码迁移任务,并结合变更位置发现技术,实现了代码迁移的自动化。与传统的基于规则的迁移方法相比,该方法具有更强的泛化能力和适应性,能够处理更复杂的迁移场景。
关键设计:论文中未明确给出关键参数设置、损失函数、网络结构等技术细节。LLM的具体选择和训练方式未知,变更位置发现算法的具体实现也未知。这些细节可能属于Google内部的技术秘密。
🖼️ 关键图片
📊 实验亮点
实验结果表明,该方法在39项不同的迁移任务中,能够自动生成74.45%的代码变更和69.46%的编辑,开发者估计总花费时间减少了50%。开发者对自动化工具的满意度很高,表明该方法具有良好的实用性和用户体验。
🎯 应用场景
该研究成果可广泛应用于软件系统的现代化改造、框架升级、依赖更新等场景。通过自动化代码迁移,可以显著降低迁移成本,提高开发效率,并减少人工错误。该方法对于大型软件公司具有重要的实际价值,有助于加速技术栈的升级和演进,保持技术领先性。
📄 摘要(原文)
Developers often evolve an existing software system by making internal changes, called migration. Moving to a new framework, changing implementation to improve efficiency, and upgrading a dependency to its latest version are examples of migrations. Migration is a common and typically continuous maintenance task undertaken either manually or through tooling. Certain migrations are labor intensive and costly, developers do not find the required work rewarding, and they may take years to complete. Hence, automation is preferred for such migrations. In this paper, we discuss a large-scale, costly and traditionally manual migration project at Google, propose a novel automated algorithm that uses change location discovery and a Large Language Model (LLM) to aid developers conduct the migration, report the results of a large case study, and discuss lessons learned. Our case study on 39 distinct migrations undertaken by three developers over twelve months shows that a total of 595 code changes with 93,574 edits have been submitted, where 74.45% of the code changes and 69.46% of the edits were generated by the LLM. The developers reported high satisfaction with the automated tooling, and estimated a 50% reduction on the total time spent on the migration compared to earlier manual migrations. Our results suggest that our automated, LLM-assisted workflow can serve as a model for similar initiatives.