Using Large Language Models to Extract UML Class Diagrams from Java Programs
Hanan Abdulwahab Siala, Kevin Lano · 2025
Many organizations rely on software systems to perform their core business operations. These systems often require modernization to accommodate new requirements and demands over time. Visual representations and diagrams help maintainers to understand these systems and to assist their maintenance and evolution. Reverse engineering is used to extract different representations of software systems, and the modeldriven engineering (MDE) approach can be used to assist the reverse engineering process, leading to model-driven reverse engineering (MDRE). Large Language Models (LLMs) are an advanced deep learning (DL) technology increasingly being applied in various domains. Despite this, the use of LLMs to extract diagrams from source code has rarely been used. In this paper, we introduce a novel MDRE framework, LLM4Models, that extracts UML class diagrams from Java source code files using LLMs. The paper also introduces a set of rules to extract UML class diagram representations. These rules have been implemented to create training data samples, which are then used to fine-tune the pre-trained LLM. Finally, the proposed framework is explained with an illustrative example and then evaluated.