arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2509.11252cs.SEcs.AI
收藏

扩散大语言模型在代码生成中的潜力探索

Exploring the Potential of Diffusion Large Language Models in Code Generation

College of AI, Tsinghua University(清华大学人工智能学院);School of Computer Science, Nanjing University(南京大学计算机科学学院);School of Computer Science and Engineering, Beihang University(北航计算机科学与工程学院);School of Computer Science, Peking University(北京大学计算机科学学院)

Chengze Li, Yitong Zhang, Jia Li, Liyi Cai, Ge Li

AI总结:

本文首次实证研究扩散大语言模型在代码生成中的潜力,发现其与自回归模型竞争力相当且具更强长度外推能力,并提供了影响因素分析与改进方向。

摘要:

大语言模型(LLMs)已成为代码生成的主流方法。现有LLMs主要采用自回归生成,即从左到右逐token生成代码。然而,底层的自回归生成在代码生成中存在两个局限性。首先,自回归LLMs每一步仅生成一个token,在实践中效率较低。其次,编程是一个涉及反复编辑的非顺序过程,而自回归LLMs仅采用从左到右的生成顺序。这两个内在局限性阻碍了LLMs在代码生成中的进一步发展。近期,扩散LLMs作为一种有前景的替代方案出现。扩散LLMs通过两项进步解决了上述局限性,包括多token预测(即每一步生成多个token)和灵活的生成顺序(即灵活确定生成token的位置)。然而,目前尚无系统性研究探索扩散LLMs在代码生成中的应用。为弥补这一知识空白,我们首次对扩散LLMs用于代码生成进行了实证研究。我们的研究涉及9个具有代表性的扩散LLMs,并在4个广泛使用的基准上进行了实验。基于实验结果,我们总结了以下发现:(1)现有扩散LLMs与相似规模的自回归LLMs具有竞争力。(2)扩散LLMs比自回归LLMs具有更强的长度外推能力,在长代码理解方面表现更佳。(3)我们探索了影响扩散LLMs有效性和效率的因素,并提供了实用指导。(4)我们讨论了改进扩散LLMs在代码生成方面的几个有前景的未来方向。我们开源了所有源代码、数据和结果,以促进后续研究。代码可在以下https URL公开获取。

英文摘要:

LLMs have become the mainstream approaches to code generation. Existing LLMs mainly employ autoregressive generation, i.e. generating code token-by-token from left to right. However, the underlying autoregressive generation has two limitations in code generation. First, autoregressive LLMs only generate a token at each step, showing low efficiency in practice. Second, programming is a non-sequential process involving back-and-forth editing, while autoregressive LLMs only employ the left-to-right generation order. These two intrinsic limitations hinder the further development of LLMs in code generation. Recently, diffusion LLMs have emerged as a promising alternative. Diffusion LLMs address the above limitations with two advances, including multi-token prediction (i.e. generating multiple tokens at each step) and flexible generation order (i.e. flexibly determining which positions to generate tokens). However, there is no systematic study exploring diffusion LLMs in code generation. To bridge the knowledge gap, we present the first empirical study of diffusion LLMs for code generation. Our study involves 9 representative diffusion LLMs and conduct experiments on 4 widely used benchmarks. Based on the results, we summarize the following findings. (1) Existing diffusion LLMs are competitive with autoregressive LLMs with similar sizes. (2) Diffusion LLMs have a stronger length extrapolation ability than autoregressive LLMs and perform better in long code understanding. (3) We explore factors impacting the effectiveness and efficiency of diffusion LLMs, and provide practical guidance. (4) We discuss several promising further directions to improve diffusion LLMs on code generation. We open-source all source code, data, and results to facilitate the following research. The code is publicly available at https://github.com/zhangyitonggg/dllm4code.

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

↑