arXiv:2410.18489cs.AIcs.ET2024-10被引 7

用大模型生成代码,结合建模语言提升准确性和可维护性。

LLM as a code generator in Agile Model Driven Development

  • 以UML+OCL+FIPA构建约束模型,减少自然语言描述的歧义。
  • 用GPT4生成兼容JADE/PADE框架的Java/Python代码,结构正确。
  • 引入语义约束后代码复杂度可控,适合敏捷开发中的动态调整。

利用GPT4等大语言模型自动生成代码虽具前景,但自然语言描述的模糊性仍带来挑战。本文提出一种敏捷模型驱动开发(AMDD)方法,通过UML建模并结合对象约束语言(OCL)进行代码结构建模,以及FIPA本体语言实现通信语义建模,显著降低模型歧义。基于此,利用GPT4生成与JADE和PADE框架兼容的Java和Python代码。评估表明生成代码行为符合预期,且代理间交互得到优化。对比仅含OCL约束与同时包含OCL与FIPA约束的模型生成代码,结果显示后者代码结构更复杂,但环路复杂度仍在可管理范围内,说明可安全引入更多元的元模型约束而不突破高风险阈值。

原文摘要 · Abstract (English)

Leveraging Large Language Models (LLM) like GPT4 in the auto generation of code represents a significant advancement, yet it is not without its challenges. The ambiguity inherent in natural language descriptions of software poses substantial obstacles to generating deployable, structured artifacts. This research champions Model Driven Development (MDD) as a viable strategy to overcome these challenges, proposing an Agile Model Driven Development (AMDD) approach that employs GPT4 as a code generator. This approach enhances the flexibility and scalability of the code auto generation process and offers agility that allows seamless adaptation to changes in models or deployment environments. We illustrate this by modeling a multi agent Unmanned Vehicle Fleet (UVF) system using the Unified Modeling Language (UML), significantly reducing model ambiguity by integrating the Object Constraint Language (OCL) for code structure meta modeling, and the FIPA ontology language for communication semantics meta modeling. Applying GPT4 auto generation capabilities yields Java and Python code that is compatible with the JADE and PADE frameworks, respectively. Our thorough evaluation of the auto generated code verifies its alignment with expected behaviors and identifies enhancements in agent interactions. Structurally, we assessed the complexity of code derived from a model constrained solely by OCL meta models, against that influenced by both OCL and FIPA ontology meta models. The results indicate that the ontology constrained meta model produces inherently more complex code, yet its cyclomatic complexity remains within manageable levels, suggesting that additional meta model constraints can be incorporated without exceeding the high risk threshold for complexity.

代码生成模型驱动大模型应用敏捷开发

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。