paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Automating Zero-Shot Patch Porting for Hard Forks

自动化硬分叉的零样本补丁移植
ISSTA Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis2024匹配度 3/10 · 论文研究基于LLM的补丁移植,属于LLM在代码生成/软件维护的应用,与用户关注的静态分析、形式化验证、浮点或贝叶斯程序分析无直接关联。虽然使用LLM作为工具,但任务本身不是静态分析或形式化验证,因此匹配度较低。引用 10 inbox
Shengyi Pan, You Wang, Zhongxin Liu, Xing Hu, Xin Xia, Shanping Li
crossref: 2026-09-12

AI 速览

一句话:提出基于大语言模型的零样本补丁移植方法 PPatHF,通过代码精简与指令微调自动将 Vim 补丁移植到 Neovim。

硬分叉通过复制并修改代码库实现代码复用,但维护时需跨分叉移植补丁,因同一功能实现存在差异而十分复杂。本文首次研究零样本设置下的自动补丁移植:先对十年来从 Vim 移植到 Neovim 的补丁开展实证分析,再提出基于大语言模型的 PPatHF。该方法由精简模块和移植模块组成,精简模块删除与补丁无关的代码片段,移植模块利用 LLM 将补丁应用到目标项目函数,并采用提示模板与指令微调注入任务知识。在 310 个 Neovim 补丁上评估,PPatHF 显著优于基线,可正确移植 131 个补丁(42.3%),并自动完成开发者所需人工编辑的 57%。

问题
硬分叉维护中跨分叉移植补丁需针对同一功能的不同实现进行适配,过程复杂且缺少零样本自动化方法。
方法
提出 PPatHF:先用精简模块移除与补丁无关的代码,再用 LLM 移植模块结合提示模板和指令微调完成函数级补丁移植。
评估
在 310 个从 Vim 移植到 Neovim 的补丁上评估,正确移植 131 个(42.3%),自动化 57% 的人工编辑,显著优于基线。
原文摘要(Abstract)

Forking is a typical way of code reuse, which provides a simple way for developers to create a variant software (denoted as hard fork) by copying and modifying an existing codebase. Despite of the benefits, forking also leads to duplicate efforts in software maintenance. Developers need to port patches across the hard forks to address similar bugs or implement similar features. Due to the divergence between the source project and the hard fork, patch porting is complicated, which requires an adaption regarding different implementations of the same functionality. In this work, we take the first step to automate patch porting for hard forks under a zero-shot setting. We first conduct an empirical study of the patches ported from Vim to Neovim over the last ten years to investigate the necessities of patch porting and the potential flaws in the current practice. We then propose a large language model (LLM) based approach (namely PPatHF) to automatically port patches for hard forks on a function-wise basis. Specifically, PPatHF is composed of a reduction module and a porting module. Given the pre- and post-patch versions of a function from the reference project and the corresponding function from the target project, the reduction module first slims the input functions by removing code snippets less relevant to the patch. Then, the porting module leverages a LLM to apply the patch to the function from the target project. To better elicit the power of the LLM on patch porting, we design a prompt template to enable efficient in-context learning. We further propose an instruction-tuning based training task to better guide the LLM to port the patch and inject task-specific knowledge. We evaluate PPatHF on 310 Neovim patches ported from Vim. The experimental results show that PPatHF outperforms the baselines significantly. Specifically, PPatHF can correctly port 131 (42.3%) patches and automate 57% of the manual edits required for the developer to port the patch.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8487,
  title = {Automating Zero-Shot Patch Porting for Hard Forks},
  author = {Shengyi Pan and You Wang and Zhongxin Liu and Xing Hu and Xin Xia and Shanping Li},
  booktitle = {ISSTA},
  year = {2024},
  doi = {10.1145/3650212.3652134}
}