arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2504.00532cs.SEcs.CL
收藏

SRLCG:基于多维思维链与动态回溯的自纠错大规模代码生成

SRLCG: Self-Rectified Large-Scale Code Generation with Multidimensional Chain-of-Thought and Dynamic Backtracking

Beihang University(北京航空航天大学);Shandong University(山东大学);Qilu University of Technology (Shandong Academy of Sciences)(齐鲁工业大学(山东省科学院));Harbin Institute of Technology(哈尔滨工业大学)

Hongru Ma, Yanjie Liang, Jiasheng Si, Weiyu Zhang, Hongjiao Guan, Chaoqun Zheng, Bing Xu, Wenpeng Lu

AI总结:

针对LLMs难以生成完整大规模项目代码的问题,提出SRLCG框架,利用多维思维链、自我纠错与动态回溯算法生成完整多文件项目代码,其代码长度和正确性等均显著优于基线。

摘要:

大型语言模型(LLMs)彻底改变了代码生成,显著提升了开发者的生产力。然而,对于大量缺乏编码知识的用户,LLMs提供的支持有限,因为它们主要生成孤立的代码片段,而非完整的、大规模的项目代码。由于缺乏编码专业知识,这些用户难以解释、修改和迭代优化LLMs的输出,从而无法组装完整项目。为解决此问题,我们提出了自纠错大规模代码生成器(SRLCG),这是一个能从单一提示生成完整多文件项目代码的框架。SRLCG采用新颖的多维思维链(CoT)和自我纠错来引导LLMs生成正确且鲁棒的代码文件,随后使用我们提出的动态回溯算法将其整合为完整且连贯的项目。实验结果表明,SRLCG生成的代码长度是DeepSeek-V3的15倍、GPT-4的16倍,且至少是其他领先的基于CoT基线方法的10倍。此外,结果证实,在大规模代码生成中,与基线相比,其正确性、鲁棒性和性能均有所提升。

英文摘要:

Large language models (LLMs) have revolutionized code generation, significantly enhancing developer productivity. However, for a vast number of users with minimal coding knowledge, LLMs provide little support, as they primarily generate isolated code snippets rather than complete, large-scale project code. Without coding expertise, these users struggle to interpret, modify, and iteratively refine the outputs of LLMs, making it impossible to assemble a complete project. To address this issue, we propose Self-Rectified Large-Scale Code Generator (SRLCG), a framework that generates complete multi-file project code from a single prompt. SRLCG employs a novel multidimensional chain-of-thought (CoT) and self-rectification to guide LLMs in generating correct and robust code files, then integrates them into a complete and coherent project using our proposed dynamic backtracking algorithm. Experimental results show that SRLCG generates code 15x longer than DeepSeek-V3, 16x longer than GPT-4, and at least 10x longer than other leading CoT-based baselines. Furthermore, they confirm its improved correctness, robustness, and performance compared to baselines in large-scale code generation.

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

↑