SWE-Fixer: Training Open-Source LLMs for Effective and Efficient GitHub Issue Resolution

📄 arXiv: 2501.05040v3 📥 PDF

作者: Chengxing Xie, Bowen Li, Chang Gao, He Du, Wai Lam, Difan Zou, Kai Chen

分类: cs.CL

发布日期: 2025-01-09 (更新: 2025-05-07)

备注: Our code, data, and model will be released at https://github.com/InternLM/SWE-Fixer

🔗 代码/项目: GITHUB


💡 一句话要点

SWE-Fixer:训练开源LLM以高效解决GitHub问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 代码修复 大型语言模型 开源框架 GitHub问题 软件工程

📋 核心要点

  1. 现有代码修复方法依赖于封闭的LLM,限制了可复现性、可访问性和透明度,阻碍了软件工程领域的进步。
  2. SWE-Fixer框架通过代码文件检索和代码编辑两个模块,利用开源LLM实现高效的GitHub问题修复。
  3. 实验表明,SWE-Fixer在SWE-Bench基准测试中取得了与现有开源模型相比具有竞争力的性能,并显著提升了效率。

📝 摘要(中文)

大型语言模型(LLMs)在各种复杂任务中表现出卓越的能力。LLM的一个重要应用是解决软件工程挑战,特别是通过修复代码来解决GitHub上的实际问题。然而,目前许多方法依赖于专有LLM,这限制了可重复性、可访问性和透明度。用于解决软件工程问题的LLM的关键组成部分以及如何有效增强其能力仍不清楚。为了应对这些挑战,我们引入了SWE-Fixer,这是一个新颖的开源框架,旨在有效且高效地解决GitHub问题。SWE-Fixer包含两个基本模块:代码文件检索模块和代码编辑模块。检索模块采用BM25以及轻量级模型来实现由粗到精的文件检索。随后,代码编辑模块利用另一个模型为已识别的文件生成补丁。为了缓解公开可用数据集的缺乏,我们编译了一个包含11万个GitHub问题及其相应补丁的广泛数据集,并分别训练SWE-Fixer的两个模型。我们在SWE-Bench Lite和Verified基准上评估了我们的方法,在开源模型中取得了具有竞争力的性能,得分分别为22.0%和30.2%。此外,SWE-Fixer通过PASS_TO_PASS(P2P)过滤达到了最先进的性能(Lite上为24.7%,Verified上为32.8%)。此外,我们的方法每个实例仅需要两次模型调用,这使其比现有方法效率更高。这些结果突出了SWE-Fixer在实际代码修复场景中的有效性。我们将公开我们的模型、数据集和代码,网址为https://github.com/InternLM/SWE-Fixer。

🔬 方法详解

问题定义:论文旨在解决GitHub issue的自动修复问题,现有方法主要依赖于闭源的LLM,存在可复现性差、成本高昂等问题,限制了其在实际软件开发中的应用。同时,如何有效地利用开源LLM来解决代码修复问题也是一个挑战。

核心思路:论文的核心思路是构建一个开源的、高效的、可复现的代码修复框架SWE-Fixer。该框架通过解耦代码检索和代码编辑两个步骤,并分别训练相应的模型,从而降低了任务的复杂度,提高了修复的效率。

技术框架:SWE-Fixer框架主要包含两个模块:代码文件检索模块和代码编辑模块。首先,代码文件检索模块使用BM25算法和一个轻量级模型进行粗到精的文件检索,确定需要修改的文件。然后,代码编辑模块利用另一个模型,基于检索到的文件和issue描述,生成代码补丁。

关键创新:该论文的关键创新在于提出了一个完全开源的代码修复框架,并针对代码修复任务的特点,将问题分解为代码检索和代码编辑两个子任务,并分别进行优化。此外,论文还构建了一个大规模的GitHub issue修复数据集,用于训练模型。

关键设计:代码文件检索模块采用BM25算法进行初步检索,然后使用一个轻量级模型(具体模型未知)进行精细检索。代码编辑模块使用另一个模型(具体模型未知)生成代码补丁。论文还使用了PASS_TO_PASS (P2P) filtering来进一步提升性能。模型训练使用了包含11万个GitHub issue及其对应补丁的数据集,具体损失函数和网络结构等细节未知。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

SWE-Fixer在SWE-Bench Lite和Verified基准测试中分别取得了22.0%和30.2%的修复成功率,在开源模型中具有竞争力。通过PASS_TO_PASS (P2P) filtering,SWE-Fixer的性能进一步提升至24.7% (Lite) 和 32.8% (Verified),达到了state-of-the-art水平。此外,SWE-Fixer每个实例仅需两次模型调用,显著提高了效率。

🎯 应用场景

SWE-Fixer具有广泛的应用前景,可用于自动化代码修复、软件质量保证、以及辅助软件开发人员进行问题定位和修复。该研究有助于降低软件维护成本,提高开发效率,并促进开源软件生态系统的发展。未来,该框架可以集成到IDE或CI/CD流程中,实现更智能化的代码修复。

📄 摘要(原文)

Large Language Models (LLMs) have demonstrated remarkable proficiency across a variety of complex tasks. One significant application of LLMs is in tackling software engineering challenges, particularly in resolving real-world tasks on GitHub by fixing code based on the issues reported by the users. However, many current approaches rely on proprietary LLMs, which limits reproducibility, accessibility, and transparency. The critical components of LLMs for addressing software engineering issues and how their capabilities can be effectively enhanced remain unclear. To address these challenges, we introduce SWE-Fixer, a novel open-source framework designed to effectively and efficiently resolve GitHub issues. SWE-Fixer comprises two essential modules: a code file retrieval module and a code editing module. The retrieval module employs BM25 along with a lightweight model to achieve coarse-to-fine file retrieval. Subsequently, the code editing module utilizes the other model to generate patches for the identified files. To mitigate the lack of publicly available datasets, we compile an extensive dataset that includes 110K GitHub issues along with their corresponding patches and train the two models of SWE-Fixer separately. We assess our approach on the SWE-Bench Lite and Verified benchmarks, achieving competitive performance among open-source models with scores of 22.0% and 30.2%. Furthermore, SWE-Fixer reaches state-of-the-art performance (24.7% on Lite and 32.8% on Verified) with PASS_TO_PASS (P2P) filtering. Additionally, our approach requires only two model calls per instance, making it significantly more efficient than existing methods. These results highlight the effectiveness of SWE-Fixer in real-world code-fixing scenarios. We will make our model, dataset, and code publicly available at https://github.com/InternLM/SWE-Fixer.