用扩散模型修复代码末尾缺陷,还能自动生成训练数据。
Diffusion is a code repair operator and generator
- 将噪声加回破损代码,让扩散模型逆向修复
- 在三个领域验证,修复成功率显著提升
- 适合需要高效生成修复样本的开发者
代码扩散模型通过逐步去除代码片段潜在表示中的噪声来生成代码。在扩散过程后期,当代码接近收敛时,不同离散表示间的差异类似于对错误或不完整代码的末尾修复。我们评估了这种相似性能否被用于解决末尾修复问题,提出了两个具有潜力的应用:一是对破损代码添加噪声后继续扩散过程以实现修复;二是通过从扩散过程中采样中间程序(输入)和最终程序(输出),高效生成大量用于末尾修复任务的训练数据。我们在Python、Excel和PowerShell三个领域进行了实验,并分析了相关性质。
原文摘要 · Abstract (English)
Code diffusion models generate code by iteratively removing noise from the latent representation of a code snippet. During later steps of the diffusion process, when the code snippet has almost converged, differences between discrete representations of these snippets look like last-mile repairs applied to broken or incomplete code. We evaluate the extent to which this resemblance can be exploited to leverage pre-trained code diffusion models for the problem of last-mile repair by considering two applications with significant potential. First, we can leverage the diffusion model for last-mile repair by adding noise to a broken code snippet and resuming the diffusion process. Second, we can leverage the diffusion model to generate arbitrary amount of training data for last-mile repair tasks (that are computationally more efficient) by sampling an intermediate program (input) and the final program (output) from the diffusion process. We perform experiments on 3 domains (Python, Excel and PowerShell) to evaluate applications, as well as analyze properties.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。