arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.04177cs.SEcs.AIcs.LG
收藏

CodeTaste:LLM能否生成人类级别的代码重构?

CodeTaste: Can LLMs Generate Human-Level Code Refactorings?

University of California, Berkeley(加州大学伯克利分校);ETH Zurich(苏黎世联邦理工学院)

Alex Thillen, Niels Mündler, Veselin Raychev, Martin Vechev

AI总结:

研究LLM代理在代码重构中的能力,通过CodeTaste基准测试发现,代理在详细指定重构时表现良好,但难以自主发现人类选择的重构,提出“先提议后实现”分解可改善对齐。

摘要:

LLM编码代理可以生成可工作的代码,但它们的解决方案往往积累复杂性、重复和架构债务。人类开发者通过重构来解决这些问题:行为保持的程序转换,改善结构和可维护性。我们研究代理是否(i)能够可靠地执行重构,以及(ii)识别人类开发者在实际代码库中实际选择的重构。为此,我们构建了CodeTaste,一个从大型多文件开源重构中挖掘的基准测试。为了评分解决方案,我们结合了测量功能正确性的仓库测试套件和定制的静态检查,这些检查使用数据流推理验证不期望模式的移除和期望模式的引入。我们的结果显示了一个明显的差距:代理在实现详细指定的重构时表现良好,但当给定变更的关注区域时,往往无法发现人类的重构选择。先提议后实现的分解改善了对齐,而在实现之前选择最佳对齐的提议可以带来进一步的收益。CodeTaste为在现实代码库中将编码代理与人类重构决策对齐提供了评估目标和潜在的偏好信号。我们发布了基准测试、排行榜和代码。

英文摘要:

LLM coding agents can generate working code, but their solutions often accumulate complexity, duplication, and architectural debt. Human developers address such issues through refactoring: behavior-preserving program transformations that improve structure and maintainability. We investigate whether agents (i) can execute refactorings reliably and (ii) identify the refactorings that human developers actually chose in real codebases. To this end, we construct CodeTaste, a benchmark mined from large multi-file open-source refactorings. To score solutions, we combine repository test suites that measure functional correctness with tailored static checks that verify removal of undesired and introduction of desired code patterns using dataflow reasoning. Our results show a clear gap: agents perform well at implementing refactorings that are specified in detail, but often fail to discover the human refactoring choices when given a focus area for changes. A propose-then-implement decomposition improves alignment, and selecting the best-aligned proposal before implementation can yield further gains. CodeTaste provides an evaluation target and a potential preference signal for aligning coding agents with human refactoring decisions in realistic codebases. We release the benchmark, leaderboard, and code.

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

↑