arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.03712cs.SE
收藏

SWE-Refactor:一个面向真实世界的基于大语言模型的代码重构仓库级基准

SWE-Refactor: A Repository-Level Benchmark for Real-World LLM-Based Code Refactoring

Concordia University(康考迪亚大学)

Yisen Xu, Jinqiu Yang, Tse-Hsun, Chen

AI总结:

SWE-Refactor是一个面向真实世界的基于大语言模型的代码重构仓库级基准,通过1099个Java项目中的重构实例评估九种LLMs,揭示复杂重构的失败率较高。

摘要:

大型语言模型(LLMs)最近引起了广泛关注,用于解决软件工程任务。与代码生成不同,重构要求精确、语义保持的编辑,以改进程序结构,这也使得自动化评估具有挑战性。然而,现有的重构基准通常存在三个不足:重构场景覆盖有限,包含混合重构与无关更改的实例,以及缺乏足够的仓库级上下文以进行现实评估。为缓解这些问题,我们引入了SWE-Refactor,一个新的用于基于大语言模型的代码重构的基准。SWE-Refactor包含1,099个开发者编写的行为保持的重构,这些重构从18个Java项目中挖掘而来,包括922个原子实例和177个复合实例。每个实例通过编译、测试执行和自动化重构检测工具进行验证,以确保正确性。我们对九种广泛使用的LLMs在SWE-Refactor上进行了评估,涵盖GPT-4o-mini、DeepSeek-V3和CodeLLaMa等模型,以提供代表性的参考结果。我们的结果表明,复杂和复合的重构仍然是失败的主要来源;值得注意的是,一个OpenAI Codex代理在复合实例上的成功率为39.4%。我们发布了SWE-Refactor和所有评估结果,以促进未来基于大语言模型的代码重构研究。

英文摘要:

Large Language Models (LLMs) have recently attracted wide interest for tackling software engineering tasks. In contrast to code generation, refactoring demands precise, semantics-preserving edits that improve program structure, which also makes automated evaluation challenging. However, existing refactoring benchmarks commonly suffer from three shortcomings: limited coverage of refactoring scenarios, the inclusion of instances that mix refactoring with unrelated changes, and insufficient repository-level context for realistic assessment. To mitigate these issues, we introduce SWE-Refactor, a new benchmark for LLM-based code refactoring. SWE-Refactor comprises 1,099 developer-written, behavior-preserving refactorings mined from 18 Java projects, including 922 atomic and 177 compound instances. Each instance is validated via compilation, test execution, and automated refactoring detection tools to ensure correctness. We evaluate nine widely used LLMs on SWE-Refactor, covering models such as GPT-4o-mini, DeepSeek-V3, and CodeLLaMa, to provide representative reference results. Our results show that complex and compound refactorings remain the primary source of failures; notably, an OpenAI Codex agent achieves only 39.4% success on compound instances. We release SWE-Refactor and all evaluation results to facilitate future research on LLM-based code refactoring.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑