Assessing the Latent Automated Program Repair Capabilities of Large Language Models using Round-Trip Translation
作者: Fernando Vallecillos Ruiz, Anastasiia Grishina, Max Hort, Leon Moonen
分类: cs.SE, cs.CL, cs.LG
发布日期: 2024-01-15 (更新: 2025-10-15)
备注: Accepted for publication in ACM Transactions on Software Engineering and Methodology (TOSEM)
DOI: 10.1145/3771922
💡 一句话要点
通过往返翻译评估大型语言模型的自动程序修复能力
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 自动程序修复 大型语言模型 机器翻译 往返翻译 代码补丁生成
📋 核心要点
- 现有的自动程序修复方法在处理特定类型的错误时效果有限,尤其是对于不常见的错误模式。
- 本文提出通过往返翻译(RTT)利用大型语言模型的潜在能力,来生成更自然的程序修复补丁。
- 实验结果表明,使用GPT-4的RTT方法在HumanEval-Java基准上生成了100个合理补丁,其中97个被手动评估为正确。
📝 摘要(中文)
研究表明,使用语言模型将文本翻译成另一种语言再翻译回来可以纠正自然语言中的错误。本文探讨这种潜在的修正能力在自动程序修复(APR)中的应用,通过往返翻译(RTT)将代码从一种编程语言翻译成另一种编程或自然语言再翻译回来。我们假设RTT通过回归均值恢复在LLM训练语料中最常见的模式,用更频繁、自然的无错误代码替换不常见的错误。我们使用九个LLM和四个常见的Java APR基准进行详细的定量和定性分析,发现GPT-4通过英语生成了164个错误中的100个合理补丁,其中97个在人工评估中被认为是正确的。此外,RTT独特地为46个被专门微调的LLM遗漏的错误生成了合理补丁。尽管RTT在APR中显示出可行性,但我们也观察到其局限性,如整体修复率低于最先进的方法,并稀释了原始编码风格。我们分析了这些局限性的影响,并讨论了将RTT作为APR框架补充组件的潜力。
🔬 方法详解
问题定义:本文旨在解决现有自动程序修复方法在处理不常见错误时的局限性,尤其是缺乏有效的补丁生成能力。
核心思路:通过往返翻译(RTT)将代码翻译成另一种语言再翻译回来,利用大型语言模型的训练数据生成更自然的补丁,替换不常见的错误。
技术框架:整体流程包括将源代码翻译为目标语言,再将其翻译回源语言,最后生成补丁。主要模块包括翻译模型、补丁生成模块和评估模块。
关键创新:RTT方法的创新在于其利用语言模型的训练数据生成补丁,特别是生成了46个被专门微调的LLM遗漏的补丁,展示了其独特的修复能力。
关键设计:在实验中使用了九个大型语言模型,结合四个Java APR基准进行评估,采用定量和定性分析方法来验证生成补丁的有效性和合理性。
🖼️ 关键图片
📊 实验亮点
实验结果显示,GPT-4通过英语生成了100个合理补丁,97个被手动评估为正确。此外,RTT方法独特地为46个被专门微调的LLM遗漏的错误生成了补丁,展示了其在APR中的潜力和优势。
🎯 应用场景
该研究的潜在应用领域包括软件开发中的自动程序修复工具,能够提高代码修复的效率和准确性。未来,RTT方法可能成为APR框架中的一个重要补充组件,帮助开发者更快速地解决代码中的错误。
📄 摘要(原文)
Research shows that errors in natural language can be corrected by translating texts to another language and back using language models. We explore to what extent this latent correction capability extends to Automated Program Repair (APR) by investigating Round-Trip Translation (RTT): translating code from one programming language into another programming or natural language and back, using Large Language Models (LLMs). We hypothesize that RTT restores patterns most commonly seen in the LLM's training corpora through regression toward the mean, replacing infrequent bugs with more frequent, natural, bug-free code. To test this hypothesis, we employ nine LLMs and four common APR benchmarks in Java, and perform a detailed quantitative and qualitative analysis of RTT-generated patches. We find that RTT through English generates plausible patches for 100 of 164 bugs with GPT-4 on the HumanEval-Java benchmark, and 97 are found to be correct in our manual assessment. Moreover, RTT uniquely generates plausible patches for 46 bugs that were missed by LLMs specifically fine-tuned for APR. While this demonstrates the viability of RTT for APR, we also observe limitations, such as a lower overall bug fix rate than the state-of-the-art and diluting the original coding style. We analyze the impact of these limitations and discuss the potential of using RTT as a complementary component in APR frameworks. A replication package is available for download from https://doi.org/10.5281/zenodo.10500593. Keywords: automated program repair, large language model, machine translation