用结构化计划引导LLM生成完整深度学习项目代码
Empowering AI to Generate Better AI Code: Guided Generation of Deep Learning Projects with LLMs
- 先生成项目结构计划,再检索相似代码构建模板
- 在自建数据集上实现CodeBLEU提升9.7%、人工评估提升3.6%
- 适合需要完整深度学习项目生成的开发者和研究者
尽管大型语言模型(LLMs)已广泛用于代码生成,但在生成完整的深度学习项目时仍面临挑战,这类项目具有复杂结构、较长函数和强领域依赖性。通用领域LLM往往缺乏特定项目的连贯上下文指导和领域知识,难以产出完全满足用户需求的完整代码。本文提出一种面向深度学习项目生成的规划引导方法DLCodeGen。该方法首先预测结构化解决方案计划,为LLM提供全局指导;随后利用该计划检索语义相似的代码样本,并抽象出代码模板;最后通过对比学习机制融合多种检索增强技术生成最终代码。我们在自建的深度学习代码生成数据集上验证了该方法的有效性。实验结果表明,与现有基线相比,DLCodeGen在CodeBLEU指标上提升9.7%,在人工评估中提升3.6%。
原文摘要 · Abstract (English)
While large language models (LLMs) have been widely applied to code generation, they struggle with generating entire deep learning projects, which are characterized by complex structures, longer functions, and stronger reliance on domain knowledge than general-purpose code. An open-domain LLM often lacks coherent contextual guidance and domain expertise for specific projects, making it challenging to produce complete code that fully meets user requirements. In this paper, we propose a novel planning-guided code generation method, DLCodeGen, tailored for generating deep learning projects. DLCodeGen predicts a structured solution plan, offering global guidance for LLMs to generate the project. The generated plan is then leveraged to retrieve semantically analogous code samples and subsequently abstract a code template. To effectively integrate these multiple retrieval-augmented techniques, a comparative learning mechanism is designed to generate the final code. We validate the effectiveness of our approach on a dataset we build for deep learning code generation. Experimental results demonstrate that DLCodeGen outperforms other baselines, achieving improvements of 9.7% in CodeBLEU and 3.6% in human evaluation metrics.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。