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

生命周期感知的代码生成:在大语言模型中利用软件工程阶段

Lifecycle-Aware code generation: Leveraging Software Engineering Phases in LLMs

School of Computer Science, Fudan University(复旦大学计算机科学学院)

Xing Xing, Wei Wang, Lipeng Ma, Weidong Yang, Junjie Zheng

AI总结:

针对现有LLM代码生成忽略软件工程实践的问题,提出融入需求分析等中间产物的生命周期感知框架,通过微调与多步推理显著提升代码生成质量,且训练数据需求低、鲁棒性强。

摘要:

大语言模型(LLM)的最新进展推动了自动代码生成的发展,但大多数方法依赖于从问题描述到代码的直接单步转换,忽略了结构化的软件工程实践。我们提出了一个生命周期感知框架,该框架将需求分析、状态机建模和伪代码等中间产物系统性地融入训练和推理阶段。这种设计使代码生成与标准软件开发阶段保持一致,并实现更结构化的推理。实验表明,与微调前的同一模型相比,生命周期级微调将代码正确率提升了高达75%,且性能提升在各中间阶段逐步累积。多步推理始终优于单步生成,证明了中间脚手架的有效性。值得注意的是,开源LLM在我们的框架下微调后,性能与在代码上预训练的模型相当或略有超越。将该框架应用于DeepSeek-Coder-1.3B时,其CodeBLEU值相较于ChatGPT-3.5、ChatGPT-4o-mini、DeepSeek-R1和LLaMA-8B分别相对提升了34.3%、20.0%、11.2%和22.3%。我们的流水线在训练数据减少多达80%的情况下仍表现稳健,证实了其鲁棒性。消融研究进一步表明,每个中间产物对最终代码质量都有独特贡献,其中状态机建模的影响最为显著。我们的源代码和详细实验数据可在https://anonymous.4open.science/r/Lifecycle-Aware-3CCB获取。

英文摘要:

Recent progress in large language models (LLMs) has advanced automatic code generation, yet most approaches rely on direct, single-step translation from problem descriptions to code, disregarding structured software engineering practices. We introduce a lifecycle-aware framework that systematically incorporates intermediate artifacts such as requirements analysis, state machine modeling, and pseudocode into both the training and inference stages. This design aligns code generation with standard software development phases and enables more structured reasoning. Experiments show that lifecycle-level fine-tuning improves code correctness by up to 75% over the same model before fine-tuning, with performance gains compounding across intermediate stages. Multi-step inference consistently surpasses single-step generation, demonstrating the effectiveness of intermediate scaffolding. Notably, open-source LLMs, once fine-tuned under our framework, match or slightly outperform models pretrained on code. When applied to DeepSeek-Coder-1.3B, our framework yields relative CodeBLEU improvements of 34.3%, 20.0%, 11.2%, and 22.3% over ChatGPT-3.5, ChatGPT-4o-mini, DeepSeek-R1, and LLaMA-8B, respectively. Our pipeline also proves robust with up to 80\% less training data, confirming its resilience. Ablation studies further reveal that each intermediate artifact contributes distinctly to final code quality, with state machine modeling yielding the most substantial impact. Our source code and detailed experimental data are available at https://anonymous.4open.science/r/Lifecycle-Aware-3CCB.

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

↑