Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Toward automating UML class diagram generation

using generative AI models


Omaran Bazna

Dept. of Electrical & Computer Engineering & Computer Science


University of Detroit Mercy
Detroit, MI, United States
baznaom@udmercy.edu

Model Name Model size Context window


Abstract—In this paper, my objective is to conduct a compre- Chat GPT turbo 3.5175 billion parameters 16K tokens
hensive exploration of the potential and constraints associated Claud AI Sonnet 500 billion parameters 200k+ tokens
with employing generative AI models, such as ChatGPT and TABLE I
Claude AI, for automating the generation of UML class dia- C OMPARE BETWEEN C HAT GPT AND C LAUDE AI MODELS
grams from English specifications. Despite their commendable
performance, these models present their own set of challenges and
limitations. While they yield satisfactory results, the feasibility of
their integration into practical environments remains a subject
(NLP) techniques and heuristic rule-based methods, such as
of debate. Nevertheless, their utility in generating initial drafts
might be a potential use case in real-world projects. My research analyzing nouns and verbs in English specifications, have been
showed that the accuracy and the correctness of the UML employed to extract class diagram descriptions [1] [2] [3].
diagram generated by the Generative AI model rely heavily on While these techniques have shown promising results, they
the context window of the model ,also it is rely on the model size still have not met the requirements to be used in real world
(number of parameters) , furthermore it has been shown that
projects [1] [2] [3].
generative AI models ability to generate UML models could be
dramatically improve by tuning the model into the UML domain This paper explores the potential of using generative AI
knowledge with few training samples. With proper selection of models, like ChatGPT, to generate class diagram code directly
the model and tuning, the generative AI technologies could be from English specifications. By feeding the textual specifica-
used in real word projects to generate UML drafts. tions into these models, the aim is to automate the process of
Index Terms—UML Diagram, Class Diagram, Generative AI,
Context window UML class diagram generation, potentially streamlining the
software development lifecycle and facilitating more effective
I. I NTRODUCTION communication between domain experts and technical teams.
Software development is a complex and multifaceted pro-
cess, fraught with challenges at every stage. One of the main II. L ITERATURE R EVIEW
challenges developers face is the lack of comprehensive under- Several research papers have discussed the topic of au-
standing of the domain in which the software operates. Often, tomating UML class diagram generation using AI models.
years of experience are required to grasp the domain area, so Some researchers have studied the use of Natural Language
the developers will need to rely on domain experts to provide Processing (NLP) techniques for this purpose. However, these
guidance and insights. However, domain experts frequently studies show that NLP techniques do not have good accuracy
lack the technical vocabulary to effectively communicate their for real-world applications and require a lot of user interven-
intricate ideas to the development team. tion. Recent research papers have investigated the usage of
To bridge this communication gap, Unified Modeling Lan- Generative AI models, which have demonstrated promising
guage (UML) diagrams serve as an intermediary layer between results.
the software’s textual descriptions in the domain expert’s lan-
guage (English specifications) and the coding layer created by
technical experts. UML diagrams facilitate the communication III. M ETHODOLOGY
and iterative refinement of ideas before implementing them in A. Data collection
source code.
Despite their utility, the process of generating UML dia- 1) Input data : For the input dataset, I utilized examples
grams is time-consuming and cost-intensive, prompting the from the UML diagrams org website, which provides clear
exploration of automation techniques. Various approaches have descriptions of popular projects in natural English language,
been proposed, including user-friendly UI tools that simplify along with their expected UML diagrams [6].
diagram generation but require extensive training and user The input text will be fed directly into the Generative AI
intervention [1]. Additionally, natural language processing model without any pre-processing steps.
Project Score
2) Output format : When prompted to generate a UML Library domain model 4
diagram, most generative AI models do not directly output Online shopping domain model 40
an image response. Instead, they typically generate a text- Bank account class diagram example 0
based response. To achieve the desired output format, the Hospital domain UML class diagram example -9
TABLE II
objective is to obtain a coding syntax that represents the C HAT GPT MODEL RESULTS FOR BUILDING UML CLASS DIAGRAM
UML diagram, specifically adhering to the syntax used by
the PlantUML website[5]. This approach allows for seamless Project Score
integration, as the generated output code can be directly Library domain model 10
inputted into the PlantUML website, enabling the rendering Online shopping domain model 100
of the corresponding UML diagram [7]. Bank account class diagram example Syntax error
Hospital domain UML class diagram example 100
3) Data set : The researcher utilized input samples from TABLE III
the UML-diagrams.org website for the following projects [6]: C LAUDE AI MODEL RESULTS FOR BUILDING UML CLASS DIAGRAM

1) Library domain model


2) Online shopping domain model
3) Bank account class diagram example IV. R ESULTS AND D ISCUSSION
4) Hospital domain A. Analysis 1
For each project URL, comprehensive descriptions in natural A course has multiple student, each student has a name,
English were readily available and served as input for the grade the course has name and teacher name
generative AI models. These textual descriptions were inputted B. Analysis 2
into ChatGPT [8] and Claude AI [9].
A Book store is developing an E-commerce to sell books
The responses generated by the models were collected and online, the customer can create an account online, add books
stored in an Excel sheet [10]. to cart, check out the cart items, and return books the book
Subsequently, the output from each model was inputted into should be shipped to the customer address
the PlantUML UML generator, and the resulting diagrams
were manually scored by the author using the predefined C. Analysis 3
scoring criteria mentioned in section D. A drawing app software is developed to be hosted online,
The scores were then added to the corresponding rows in the the user should be able to select a shape from the list of shapes
Excel sheet, ensuring this process was repeated for all three (circle, box, line, rectangle) the user should be able to select
generative AI models. the filling color and the stroke color the user should be able
4) Evaluation : The output UML diagrams were manually to draw shapes on multiple layers.
scored by the author based on the following criteria: D. Analysis 4
For each correctly identified class: Online tutoring platform that teaches algorithms and data
1) If all attributes were accurately represented (+5 points) structures, the website consisted of sections each section
2) If the attributes were partially correct (+2 points) teaches a family of data structures (for example graphs or
3) For each correctly identified relationship: lists) for every section there are multiple pages for the detailed
4) If the relationship multiplicity was precisely specified data structures. please specify the data structures names in the
(+5 points) UML diagram.
5) If the relationship multiplicity was incorrect (+2 points)
Penalties were applied for the following cases:
1) For every major class omitted (-2 points)
2) For every major relationship missing (-2 points)
3) For every incorrect class included (-5 points)
4) For every incorrect relationship represented (-5 points)
It’s important to note that the final score could be either
positive or negative, reflecting the overall accuracy and com-
pleteness of the generated UML diagram.
5) Data Collected : Each record in the dataset consists of:
1) Model name
2) Project name
3) Project link
4) Output UML diagram code
5) Score for correctness Fig. 1. Chat GPT answer for prompt1
Model classes attributes relations score
Chat GPT turbo 3.5 CourseStudent (-2) complete attributes (+5) wrong relations (-2) 1
Claude AI Sonnet complete classes (+5) complete attributes (+5) complete relations (+5) 15
TABLE IV
A NALYSIS 1 DISCUSSION

Model classes attributes relations score


Chat GPT turbo 3.5 complete classes (+5) complete attributes (+5) wrong relations (-2) 8
Claude AI Sonnet complete classes (+5) complete attributes (+5) complete relations (+5) 15
TABLE V
A NALYSIS 2 DISCUSSION

Model classes attributes relations score


Chat GPT turbo 3.5 complete classes (+5) complete attributes (+5) bad relations (-5) 5
Claude AI Sonnet complete classes (+5) complete attributes (+5) good relations (+5) 15
TABLE VI
A NALYSIS 3 DISCUSSION

Model classes attributes relations score


Chat GPT turbo 3.5 some missing classes (+2) partial attributes (+2) bad relations (-5) -1
Claude AI Sonnet complete classes (+5) complete attributes (+5) good relations (+5) 15
TABLE VII
A NALYSIS 4 DISCUSSION

Fig. 2. Claude AI answer for prompt1

E. Analysis 5
We want to design a library for Front-End development, the
library should have a lot of ready (out of box) components
like for example buttons, radio buttons, input field , navbar .,
we want to cover most common UI components Ideally the Fig. 3. Chat GPT answer for prompt2
library components should be designed with a good level of
Fig. 5. Chat GPT answer for prompt3

Fig. 6. Claude AI answer for prompt3

Fig. 4. Claude AI answer for prompt2

implementing Object oriented principles like inheritance .


F. Discussion
The data collection process revealed that the AI models
exhibited varying levels of potential and accuracy in generating
UML models.
The results from the Claude AI model were very promising
and closely aligned with the requirements for real-world
scenarios, making it a suitable candidate for generating draft Fig. 7. Chat GPT answer for prompt4
UML diagrams.
Model classes attributes relations score
Chat GPT turbo 3.5 some missing classes (+2) partial attributes (+2) fair relations (+2) 8
Claude AI Sonnet complete classes (+3) complete attributes (+5) good relations (+5) 13
TABLE VIII
A NALYSIS 5 DISCUSSION

Fig. 10. Claude AI answer for prompt5

However, one potential issue identified with generative


AI models is their tendency to adhere too strictly to the
literal description of the project, lacking the flexibility and
adaptability that human experts possess.
The author noticed that generative AI models generally
avoided providing enough details initially and required further
prompting to incorporate sufficient details into the UML
models.
Additionally, the AI models rely heavily on their training
data and may lack creativity or the ability to deviate signifi-
cantly from their learned patterns and knowledge.
These observations highlight some of the current limitations
of generative AI models in this specific task. While they show
promise as a starting point for drafting UML diagrams, their
Fig. 8. Claude AI answer for prompt4 outputs may require further refinement and input from human
experts to address the lack of flexibility, detail, and creativity.

R EFERENCES
[1] E. Abdelnabi, A. Maatuk, and M. Hagal, ”Generating UML Class
Diagram from Natural Language Requirements: A Survey of Ap-
proaches and Techniques,” in 2021 International Mobile, Intelligent,
and Ubiquitous Computing Conference (MIUCC), 2021, pp. 288-293,
doi: 10.1109/MI-STA52233.2021.9464433.
[2] E. A. Abdelnabi, A. M. Maatuk, T. M. Abdelaziz and S. M. Elakeili,
”Generating UML Class Diagram using NLP Techniques and Heuristic
Rules,” in 2020 20th International Conference on Sciences and Tech-
niques of Automatic Control and Computer Engineering (STA), Monas-
tir, Tunisia, 2020, pp. 277-282, doi: 10.1109/STA50679.2020.9329301.
[3] S. Yang and H. Sahraoui, ”Towards automatically extracting UML
class diagrams from natural language specifications,” in Proceed-
ings of the 25th International Conference on Model Driven Engi-
neering Languages and Systems: Companion Proceedings (MOD-
ELS ’22), Montreal, Quebec, Canada, 2022, pp. 396–403, doi:
10.1145/3550356.3561592.
[4] Cámara, J., Troya, J., Burgueño, L. et al. On the assessment
of generative AI in modeling tasks: an experience report with
ChatGPT and UML. Softw Syst Model 22, 781–793 (2023).
https://doi.org/10.1007/s10270-023-01105-5
[5] Bader, Elias et al. “Facilitating User-Centric Model-Based Systems
Engineering Using Generative AI.” International Conference on Model-
Driven Engineering and Software Development (2024).
[6] Examples of UML diagrams - use case, class, component, package,
activity, sequence diagrams, etc. www.uml-diagrams.org
Fig. 9. Chat GPT answer for prompt5 [7] Plntuml - online platform to generate UML diagrams https://www.
plantuml.com/
[8] ChatGPT generative AI model ChatGPT(openai.com)
[9] ClaudeAI generative AI model https://claude.ai/
[10] Excelsheet of UML diagrams scores https://udmercy0-my.
sharepoint.com/:x:/g/personal/baznaom udmercy edu/
Eeh9a4UugexHnkPi4FtpJF0BS3molofTvbKRcNxU7xAr2w?e=
x1PqhK

You might also like