LLM-enabled Instance Model Generation

Fengjunjie Pan, Nenad Petrovic, Vahid Zolfaghari, Long Wen, Alois Knoll · DOI

Abstract

In the domain of model-based engineering, models are essential components that enable system design and analysis. Traditionally, the creation of these models has been a manual process requiring not only deep modeling expertise but also substantial domain knowledge of target systems. With the rapid advancement of generative artificial intelligence, large language models (LLMs) show potential for automating model generation. This work explores the generation of instance models using LLMs, focusing specifically on producing XMI-based instance models from Ecore metamodels and natural language specifications. We observe that current LLMs struggle to directly generate valid XMI models. To address this, we propose a two-step approach: first, using LLMs to produce a simplified structured output containing all necessary instance model information, namely a conceptual instance model, and then compiling this intermediate representation into a valid XMI file. The conceptual instance model is format-independent, allowing it to be transformed into various modeling formats via different compilers. The feasibility of the proposed method has been demonstrated using several LLMs, including GPT-4o, o1-preview, Llama 3.1 (8B and 70B). Results show that the proposed method significantly improves the usability of LLMs for instance model generation tasks. Notably, the smaller open-source model, Llama 3.1 70B, demonstrated performance comparable to proprietary GPT models within the proposed framework.

Introduction

Model-Based Engineering (MBE) relies heavily on the relationship between metamodels—which define the rules, grammar, and structure of a system—and instance models, which represent specific, concrete implementations of those rules. For example, a metamodel might define what a "CPU" or "RAM" is, while an instance model describes a specific server with two CPUs and 64GB of RAM.

Creating these instance models is traditionally a labor-intensive task. It requires engineers to possess both deep domain knowledge and technical proficiency in modeling languages like Ecore and storage formats like XMI (XML Metadata Interchange). While Large Language Models (LLMs) have shown remarkable capabilities in code generation and natural language understanding, they face significant hurdles when generating industry-standard models directly. XMI files are deeply nested, verbose, and governed by strict syntactic constraints. When LLMs attempt "intuitive generation" (writing XMI directly), they frequently hallucinate tags, break hierarchical structures, or omit mandatory metadata, rendering the output incompatible with professional tools like the Eclipse Modeling Framework (EMF).

Methodology: A Two-Step Pipeline

To overcome the limitations of direct generation, this research proposes a "divide and conquer" strategy. By offloading the syntactic complexity to a dedicated compiler, the LLM can focus entirely on the semantic task of mapping requirements to model elements.

Overview of the proposed two-step generation process.

1. Preprocessing

To help the LLM understand the system's "grammar," the abstract Ecore metamodel is first converted into a text-friendly format. The researchers utilized PlantUML to provide a clear, textual representation of classes, attributes, and associations, which serves as the primary context for the LLM's reasoning.

2. LLM Generation (The Conceptual Model)

Instead of requesting a complex XMI file, the system prompts the LLM to generate a Conceptual Instance Model. This is a simplified, flat JSON structure. By using unique InstanceIDs to define relationships rather than XML nesting, the cognitive load on the model is drastically reduced. This format allows the LLM to focus on identifying the correct classes and assigning appropriate attribute values based on the natural language specification.

3. The Instance Compiler

The final stage involves a custom Python-based Instance Compiler built on the PyEcore library. This tool takes the LLM's JSON output and the original Ecore metamodel as inputs. It performs rigorous validation, ensures type correctness, and automatically handles the complex nesting and metadata requirements of the XMI format. This ensures that the final output is 100% syntactically valid and ready for use in engineering environments.

Experimental Evaluation

To evaluate the framework, the authors developed a new benchmark consisting of 26 Ecore metamodels covering diverse domains, such as virtualization-based resource allocation. Each metamodel was paired with human-reviewed natural language specifications and manually created "ground truth" reference models.

Distribution of elements across the 26 test models.

The study compared the performance of several state-of-the-art models, including GPT-4o, o1-preview, and Llama 3.1 (8B and 70B). The results highlighted a stark contrast between direct generation and the proposed pipeline:

  • Syntactic Validity: Direct XMI generation was largely unsuccessful; even GPT-4o only achieved a 4% validity rate, while Llama 8B failed entirely (0%). In contrast, the two-step method achieved 100% validity across all models, as the compiler effectively filtered or corrected formatting errors.
  • Semantic Accuracy: GPT-4o led the group with a semantic accuracy of 93%. However, the open-source Llama 3.1 70B performed impressively, reaching 81% accuracy. This suggests that with the right framework, open-source models can be viable for complex engineering tasks, offering a path for organizations with strict data privacy requirements.

Discussion and Future Work

While the two-step approach solves the syntax problem, semantic challenges remain. LLMs occasionally struggle with complex associations or "logical" hallucinations—assigning values that are syntactically correct but logically inconsistent with the specific system constraints.

Future research will focus on Iterative Refinement, where the compiler's error logs are fed back into the LLM to allow for self-correction. Additionally, the team plans to explore Retrieval-Augmented Generation (RAG) to handle massive metamodels that exceed the standard context window of current LLMs.

Conclusion

This work demonstrates that the primary barrier to LLM-driven model generation is not a lack of reasoning capability, but rather the complexity of the output format. By introducing a simplified intermediate conceptual model and a dedicated compiler, we can achieve 100% valid model generation and bridge the gap between proprietary and open-source AI performance in Model-Based Engineering.

Summary updated

BibTeX
@inproceedings{pan2025llm,
  author = {Fengjunjie Pan and Nenad Petrovic and Vahid Zolfaghari and Long Wen and Alois Knoll},
  title = {{LLM-enabled Instance Model Generation}},
  booktitle = {MODELS-C},
  year = {2025},
  doi = {10.1109/models-c68889.2025.00082},
}
Figure