arXiv:2608.28800cs.SEAug 2026

Manuscript Offprint

arXiv:2608.28800

UML Class Diagram Evaluation and Repair Strategies based on LLMs

Jie Liang, Peng Liang, Chong Wang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

UML class diagrams are a crucial tool for defining the structure of software systems, but designing accurate and comprehensive class diagrams is a challenging task. Traditionally, creating UML models relies on the expertise and experience of professionals. However, with the development of AI technologies, particularly large language models (LLMs), new opportunities for software modeling have emerged. Despite this, there has been limited research on the application of LLMs in software modeling, especially in UML class diagram modeling. This study adopts an exploratory research paradigm and conducts empirical experiments on several typical software system cases. Combining the SDMetrics measurement tool with expert manual review, this paper comprehensively evaluates the practical performance of mainstream LLMs in UML class diagram modeling from multiple dimensions, including size and completeness, relationship correctness, inheritance hierarchy, and design rule compliance. Focusing on typical defects in LLM-generated UML class diagrams, this study reveals that LLMs exhibit uncertainties analogous to human memory. Accordingly, three targeted repair strategies are proposed, including memory reinforcement, external knowledge injection, and detection-guided automated targeted repair. Experimental results obtained from the case studies indicate that (1) compared to expert-crafted class diagrams, LLM-generated UML class diagrams exhibit several issues, such as incomplete identification of key classes, confusion or omissions in relationships, insufficient or absent inheritance relationships, unused classes, and circular dependencies, and (2) after applying the repair methods, all the LLMs show varying degrees of improvement in addressing these issues. The average repair rate for key class identification reaches 85%, the coupling relationship repair rate is 46%, the inheritance relationship repair rate is 69%, while repair rates for unused classes and circular dependencies both reach 100%. This study highlights both the practical limitations and optimization potential of LLM-based UML modeling, offering empirical insights and actionable strategies for advancing intelligent software modeling research.

Keywords: UML Class Diagram, Software Modeling, Large Language Model, Memory Reinforcement, Class Diagram Repair

1. Introduction

Software modeling is a critical component of software engineering and directly affects the performance and reliability of the final software product [1]. UML class diagrams, as an important tool for defining software system architecture, visually represent classes, their attributes, methods, and relationships [1]. They serve as a crucial bridge for transforming domain knowledge into executable designs. However, constructing high-quality class diagrams poses two major challenges. On the one hand, requirements analysis requires abstracting ambiguous business descriptions into structured models that comply with UML semantics, demanding both domain insight and modeling expertise from practitioners [2]. On the other hand, traditional approaches that rely on expert manual design suffer from efficiency bottlenecks and struggle to accommodate the rapid iterations required by agile development [2].

Recent breakthroughs in large language models (LLMs) offer new opportunities to transform software modeling paradigms [3]. LLMs, such as ChatGPT and DeepSeek, demonstrate exceptional capabilities

*Corresponding author at: School of Computer Science, Wuhan University, China. Tel.: +86 27 68776137; fax: +86 27 68776027. Email addresses: liangjie@wsyu.edu.cn (Jie Liang), liangp@whu.edu.cn (Peng Liang), cwang@whu.edu.cn (Chong Wang)

Preprint submitted to Elsevier

September 1, 2026 in natural language understanding and generation, and are increasingly being applied to software engineering tasks such as code generation and requirements analysis [3, 4]. However, research on applying LLMs to the core modeling task of UML class diagram generation remains nascent. Most existing work is limited to preliminary performance validation of individual models and lacks systematic evaluation frameworks [5]. Moreover, effective quality enhancement strategies have yet to emerge for addressing common structural defects in generated class diagrams, such as redundant associations and mixed responsibilities [6].

To this end, this study pursues a primary objective: to evaluate and enhance the quality of UML class diagrams generated by large language models (LLMs). To achieve this objective, three cases were selected to represent diverse application domains and varying levels of complexity. For each case, expert-crafted class diagrams serve as the validated gold standard for assessment. Subsequently, three representative LLMs with distinct capabilities were selected for experimentation: OpenAI's general-purpose model GPT-4, OpenAI's reasoning model o1-preview, and DeepSeek's reasoning model DeepSeek-R1. Taking these expert-crafted class diagrams as the gold standard, this study develops a comprehensive assessment framework to enable multidimensional and precise evaluation of LLM-generated class diagrams. The framework encompasses design size, coupling degree, inheritance hierarchy, and compliance with design rules [7, 8]. A human-machine collaborative approach is adopted for systematic analysis. Finally, to address key quality issues in LLM-generated class diagrams, this study proposes several improvement strategies, including external knowledge injection, memory reinforcement, and automated defect detection with targeted repair, and empirically evaluates their effectiveness.

Experimental results demonstrate that LLM-generated UML class diagrams consistently suffer from recurring modeling defects compared with expert-crafted benchmarks, including inaccurate key class identification, erroneous or missing class relationships, incomplete inheritance structures, unused classes, and cyclic dependencies. Furthermore, the proposed repair strategies can effectively alleviate these defects across different LLMs and achieve substantial improvements in overall diagram quality.

The main contributions of our work are as follows:

  • We propose a comprehensive method for evaluating the quality of LLM-generated class diagrams. The method compares expert-crafted class diagrams with LLM-generated outputs across key dimensions, including design size, coupling, inheritance hierarchy, and compliance with design rules. By combining automated analysis using SDMetrics [9] with manual review, the method enables an in-depth assessment of the quality of generated class diagrams.

  • We propose a set of repair strategies and evaluation schemes to address quality defects in LLM-generated class diagrams. Specifically, we introduce external knowledge injection and targeted repair based on the results of automated defect detection. In addition, motivated by the similarity between uncertainty in large language models and the forgetting characteristics of human memory, we propose a memory-reinforced repair strategy.

Paper Organization: Section 2 surveys existing research concerning LLM-based UML modeling, quality assessment, and defect repair. It summarizes representative empirical studies and highlights two major research gaps: the absence of multidimensional evaluation frameworks for LLM-generated class diagrams and the lack of systematic strategies for addressing structural defects. Section 3 presents the research methodology. The research design is organized into four sequential stages: data collection, class-diagram generation, evaluation of LLM-generated class diagrams, and class-diagram repair. Data collection prepares case resources and expert-crafted reference class diagrams. We then generate UML class diagrams via different LLMs, evaluate their modeling quality, and implement targeted repairs for detected defects. Section 4 presents the two research questions and their corresponding results. Section 5 discusses the findings and their implications, while Section 6 addresses the limitations of this study. Finally, Section 7 presents the conclusions and directions for future work.

References (30)