arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2512.05498cs.SE
收藏

一种混合方法用于EMF代码生成:代码模板与大型语言模型的结合

A Hybrid Approach for EMF Code Generation:Code Templates Meet Large Language Models

University of Science and Technology Beijing(北京科技大学);Beijing Institute of mechanical and Electrical Engineering(北京机电工程研究所)

Xiao He, Ru Chen, Zeqing Zhang, Yanling Wang, Qiuyan Dong

AI总结:

本文提出iEcoreGen,结合EMF和LLM,通过模板生成初始代码并利用LLM完善方法,提升代码生成效率与准确性。

摘要:

基于模板和基于LLM的代码生成都是自动化软件开发的关键推动因素。前者提供正确性保证,但对复杂需求过于僵化;而LLM虽然具有高灵活性,但可能生成错误代码。本文提出了iEcoreGen,一种将Eclipse Modeling Framework(EMF)与LLM相结合的混合方法。在EMF中,Ecore模型定义系统结构,并作为代码生成的蓝图。iEcoreGen将需求分解以推导操作规范,使用EMF的模板生成器生成初始Java代码,并将规范序列化为文档字符串。随后,LLM被调用以完成和修复未实现的方法。我们对二十个代码生成任务在五个LLM上进行了评估。iEcoreGen在pass@k指标上优于仅LLM的基线,在compilation@k指标上与之相当。消融研究澄清了iEcoreGen各组件的贡献。总体而言,研究结果表明,LLM增强的模型驱动开发是实现更高效软件自动化的重要途径。

英文摘要:

Template-based and LLM-based code generation are both key enablers of automated software development. The former provides correctness guarantees but are rigid for complex requirements, whereas LLMs offer high flexibility at the risk of producing faulty code.This paper proposes iEcoreGen, a hybrid approach that integrates Eclipse Modeling Framework (EMF) and LLMs. In EMF, an Ecore model defines a system structure and acts as a blueprint for code-generation.iEcoreGen decomposes requirements to derive operation specifications, uses EMF's template-based generator to produce initial Java code, and serializes specifications into docstrings. LLMs are then invoked to complete and fix unimplemented methods. We assessed iEcoreGen on twenty code-generation tasks across five LLMs. It surpasses LLM-only baselines on pass@k and performs on par with them on compilation@k. An ablation study clarified the contribution of each component of iEcoreGen. Overall, the findings indicate that LLM-enhanced model-driven development is a promising path toward more efficient software automation.

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

↑