A Method for Structured Generation and Validation of UML Sequence Diagrams Based on Large Language Models

CN122569880APending Publication Date: 2026-08-14NANJING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-20
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

针对复杂的自然语言需求文本,传统人工绘制序列图效率低、容易出现逻辑错误和遗漏,而现有自动化方法难以同时保证结构化正确性和语义一致性

Benefits of technology

[0028]与现有技术方案相比,本发明具有以下特点:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122569880A_ABST
    Figure CN122569880A_ABST
Patent Text Reader

Abstract

This invention discloses a method for structured generation and verification of UML sequence diagrams based on a large language model. It obtains use case text and extracts information, then constrains the sequence diagram based on a JSON structural constraint model, selecting either chain-based inference or workflow-based step-by-step generation strategies according to the model type: when using chain-based inference, the large language model performs step-by-step inference to identify control structures such as loops and branches, directly generating sequence diagrams that conform to structural constraints; when using workflow-based generation, the task is broken down into multiple stages such as information extraction, participant identification, process modeling, and structural assembly, progressively generating and correcting the sequence diagram structure. Based on control flow graph construction and conditional jump scenario matching technology, the method automatically extracts participant sets, message sequences, and jump scenarios, and semantically aligns them with a baseline diagram, thereby achieving automated verification of the generated sequence diagram in terms of content and structure. This effectively reduces the problems that arise in sequence diagram generation using large language models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for the structured generation and verification of UML sequence diagrams based on a large language model, belonging to the fields of software engineering, natural language processing and intelligent modeling technology. Background Technology

[0002] Unified Modeling Language (UML), as the most widely used modeling language in software engineering, plays a fundamental role in requirements analysis, system design, and architecture description. Sequence diagrams, used to describe the interaction sequence between objects or actors in a system, are one of the core outputs of requirements specification and system design. Sequence diagrams help developers understand system behavior, guide design implementation, and play a crucial role in subsequent test design, code generation, and requirements sourcing. However, in actual software development, sequence diagrams often require manual reading of requirements documents and manual drawing, which is not only time-consuming and labor-intensive but also prone to problems such as missed steps, timing errors, or logical inconsistencies due to subjective misunderstandings.

[0003] With the development of natural language processing technology, especially the increasing capabilities of Large Language Models (LLMs) based on the Transformer architecture in text understanding, code generation, and structuring tasks, researchers have begun to explore the feasibility of using them to automatically generate UML models from requirements text. Large language models possess strong semantic understanding and generation capabilities, and theoretically can extract actors, identify scenario steps, understand control structures, and further generate data structures or graphical representations of UML sequence diagrams from use case descriptions or requirements documents, thus enabling a high degree of automation in the requirements modeling process.

[0004] However, existing large language models still face several technical challenges in sequence graph generation. First, natural language requirements text is highly ambiguous and complex, containing multiple participants, multi-layered nested scenarios, conditional branches, and abnormal flows. Large language models may fail to accurately parse hierarchical relationships and control logic, resulting in incomplete sequence graph structures or semantic gaps and errors. Second, sequence graphs have strict structured formats, including constraints on participants, message order, and combined segments (alt, opt, loop, etc.). However, the content generated by general large language models often does not strictly adhere to UML syntax or structural specifications, making subsequent tools unable to parse or verify it difficult.

[0005] Furthermore, in complex system requirements, sequence diagrams often involve multi-layered nested logic, such as conditional jumps, loop control, and branch merging. Traditional automated generation methods struggle to fully reconstruct these control flow characteristics. While large language models can infer some logic, their sequence diagram generation may suffer from inconsistencies, omissions of jump relationships, or ambiguity leading to misunderstandings of the control semantics. Existing technologies also have limited means of verifying the correctness of generated sequence diagrams, typically only checking format correctness and failing to determine semantic consistency between the temporal logic and the requirements.

[0006] Meanwhile, with increasing demands for accuracy and reliability in automated modeling within the software engineering field, automatic verification after sequence diagram generation has become an essential step. For example, conditional statements in requirements can correspond to alt, opt, or break segments in a sequence diagram, and loop descriptions should be mapped to loop structures. However, the same interaction logic may have multiple different expressions in a sequence diagram. Traditional rule-matching methods struggle to cover the diverse expressions resulting from complex natural language descriptions and are also inadequate for semantic consistency checks on complex temporal relationships. Existing large language models possess certain reasoning capabilities, but without structured control flow information, their verification capabilities cannot guarantee stability and consistency.

[0007] In recent years, advancements in large language models, particularly in chained reasoning (CoT), workflow-based step-by-step generation, and multi-stage structured understanding, have enhanced their performance in complex logic parsing and multi-step generation tasks. This presents new technological opportunities for the automated generation of UML sequence diagrams. However, combining the generative capabilities of large language models with the structured constraints of UML, and further constructing control flow graphs for temporal logic verification, remains a key technical challenge in current research and engineering practice.

[0008] In summary, existing technologies have not yet provided a complete and effective solution for how to accurately, systematically, and structurally generate UML sequence diagrams from natural language requirement texts, and for automatically verifying the generated results at the control flow level. Summary of the Invention

[0009] Purpose of the Invention: Based on the analysis of existing technologies, there is an urgent need for an automated sequence diagram generation and verification method that combines structured modeling, chain reasoning, control flow analysis, and the capabilities of large language models to improve the efficiency of requirements modeling, reduce human error, and enhance software design quality. This invention provides a UML sequence diagram generation and verification method based on large language models. For complex natural language requirements texts, traditional manual sequence diagram drawing is inefficient and prone to logical errors and omissions, while existing automated methods struggle to simultaneously guarantee structural correctness and semantic consistency. This invention combines the semantic understanding capabilities of large language models with JSON Schema constraints and control flow graph verification to achieve efficient and accurate generation and verification of sequence diagrams. Furthermore, it achieves automated rendering output through visual language conversion, thereby improving software modeling efficiency and quality.

[0010] Technical solution: A method for structured generation and verification of UML sequence diagrams based on a large language model, comprising the following steps: Step 1, parse the requirement text: The input requirement text is parsed using natural language to extract information such as title, participants, main success scenario, and extended scenario, and the extracted results are structured into a sequence of scenario steps.

[0011] Step 2: Construct a predefined sequence diagram JSON schema according to the UML specification, including the structure of participants, messages, and combined fragments (alt, opt, loop, par, break), and use the predefined sequence diagram JSON schema as a constraint template for the large language model generation results to limit the structure of participants, messages, and combined fragments, ensuring that the content generated by the large language model has a legal and parsable structure.

[0012] Step 3, Sequence Graph Generation Based on Large Language Model: Utilize the large language model to generate a JSON representation of the sequence graph conforming to JSON Schema from the structured scenario steps. Generation methods include: constructing a sequence graph conforming to JSON Schema based on chained reasoning or a workflow-based generation approach. Chained reasoning (CoT) mode: All structure generation is completed in a single reasoning iteration; Workflow-based generation mode: The generation process is broken down into independent steps such as participant identification, message generation, and structure assembly, and the final sequence diagram is formed by combining intermediate structures.

[0013] Step 4, Visualization and language conversion of JSON sequence diagrams: Automatically convert JSON-formatted sequence diagrams generated by large language models into modeling languages ​​that can be parsed by visualization tools, including but not limited to PlantUML, Mermaid, etc.

[0014] The participants, messages, and combined fragments are converted into the corresponding statement structures of the tool through syntax mapping rules, and a sequence diagram file that can be rendered is generated.

[0015] Step 5, Control Flow Graph Construction and Jump Scenario Extraction: Construct a control flow graph based on JSON sequence graph, and automatically identify and extract a set of jump scenarios with the structure of preceding message → condition → subsequent message.

[0016] Step 6, Sequence Figure 1 Consistency verification: Based on the extracted participant set, message set, and control flow graph transition scenario set, the sequence graph is semantically and logically verified, including participant consistency check, message semantic alignment, and control flow structure consistency check, and finally the verification conclusion of the sequence graph is output.

[0017] In the requirement text parsing, paragraph recognition, scene segmentation, and semantic extraction are performed on the natural language text. The step description is standardized into a step sequence consisting of a main success scenario and extended scenarios, specifically including: 11) Requirements Text Extraction: Extract the requirements text descriptions and use case scenario descriptions related to the sequence diagram from the requirements document; 12) Paragraph segmentation and scenario classification: By analyzing the functional requirements and use case scenario descriptions in the requirement text, the requirement text is segmented into multiple blocks using a combination of automated script processing and manual inspection. Each block corresponds to a separate functional requirement or use case scenario unit, which facilitates the generation of the corresponding sequence diagrams.

[0018] The construction of the predefined sequence diagram JSON Schema specifically includes: 21) Define the participant structure fields, including ID, type, and name; 22) Define message structure fields, including sender, receiver, message content, and timestamp; 23) Define the structure of combined segments such as alt / opt / loop / break, which may include, but are not limited to: type label, operands, conditional statements, or conditional statements of operands; 24) Define a special structure ref to represent a reference to other sequence diagrams, including a type label, a list of participant IDs, and the ID or title of the sequence diagram to which it points.

[0019] 25) Construct recursively parsable, nested hierarchical structure templates based on standard UML sequence diagram syntax rules for use by large language models.

[0020] Sequence graph generation based on large language models specifically includes: 31) Construction of reasoning chains in chain reasoning mode or subtask decomposition and intermediate result management in workflow mode; 32) Schema-based structural validation and automatic correction; 33) Check the integrity of the generated JSON structure and the consistency of its fields.

[0021] Visual language conversion specifically includes: 41) The statement that maps participants to participants or actors; 42) The mapped message is in the format A -> B: message[time]; 43) Map nested combination fragments to the corresponding correctly indented tool code blocks, and embed the transformed message statement at the nesting level of the message; 44) Sequence diagram rendering is completed automatically through visual scripts.

[0022] Control flow graph construction and transition scenario extraction specifically include: 51) Transform each message into a control flow node; 52) Identify the boundaries of combined segments to form control flow branches; 53) Identify the edges connecting each control flow node and extract the possible jump conditions on these edges; 54) Parse the jump scenario triple (previous message, jump condition, subsequent message) from the control flow graph. The format for extracting the jump scenario is: preceding message — [condition judgment] → subsequent message. The preceding message is the message node immediately before the combined fragment, the condition judgment is the guard of the combined fragment, and the subsequent message is the first reachable message inside or after the combined fragment.

[0023] sequence Figure 1 Consistency verification specifically includes: 61) Use a large language model to perform semantic matching of participant names to check participant consistency; verify whether participants are duplicated, missing, or inconsistent by semantically matching participant names; 62) Based on the matching results in 61), establish a mapping between the sender and receiver in all generated messages and the participants in the same reference set, and extract (sender, receiver) key-value pairs for grouping the message list. Verify whether the message content is duplicated, true, or inconsistent by performing semantic matching on the message text within the same group. 63) Based on the matching results in 62), establish a mapping between the preceding and subsequent messages in all parsed jump scenarios and the messages in the same baseline set, and extract the (preceding message, subsequent message) key-value pairs to group the jump scenario list. Verify the correctness of the logical structure of the sequence diagram by performing semantic matching on the conditional judgment statements of the jump scenarios in the same group.

[0024] A UML sequence diagram structure generation and validation system based on a large language model includes: The use case parsing module is used to parse the requirement text and extract the title, participants, and scenario structure information; The structural constraint module is used to build and load the sequence diagram JSON schema and constrain the structure of the generated sequence diagram; The sequence diagram generation module is used to generate sequence diagrams that conform to JSON Schema based on chained reasoning or workflow generation methods; The visualization conversion module is used to automatically convert the generated JSON sequence diagram into the PlantUML / Mermaid visualization tool language to achieve automatic sequence diagram rendering; The control flow construction module is used to convert sequence graph messages and combined fragments into control flow graphs and extract transition scenarios; The consistency verification module is used to perform participant consistency checks, message semantic alignment, and control flow jump scenario alignment, and output the verification results.

[0025] The implementation process of the system and method is the same, and will not be described again.

[0026] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the UML sequence diagram structure generation and verification method based on a large language model as described above.

[0027] A computer-readable storage medium having a computer program / instructions stored thereon, which, when executed by a processor, implements the steps of the UML sequence diagram structure generation and verification method based on a large language model as described above.

[0028] Compared with existing technical solutions, the present invention has the following characteristics: 1) More standardized structured generation: By using JSON Schema constraints, problems such as incomplete structure and nesting errors in the generation of large language models are greatly reduced, ensuring that no syntax errors occur when converting them into visual languages.

[0029] 2) Strong ability to model complex control logic: Through CFG and jump scene extraction, it can accurately restore the conditions, loops and nested processes in natural language.

[0030] 3) Visualization Automation: Supports automatic conversion of JSON to tool languages ​​such as PlantUML / Mermaid, enabling automatic rendering of sequence diagrams and significantly reducing the cost of manual drawing.

[0031] 4) Strong semantic consistency: Semantic alignment is achieved using a large language model to ensure logical consistency between sequence diagrams and requirement descriptions.

[0032] 5) Complete end-to-end process: This invention covers the entire chain from requirements analysis, structure generation, visualization generation to verification, ensuring high reliability and high accuracy.

[0033] 6) High applicability: It is suitable for various types of requirement documents, scenarios with varying structural complexity, and various visualization tools. The schema structure or reasoning process can be customized or changed according to requirements, and it has good versatility and scalability. Attached Figure Description

[0034] Figure 1 This is a flowchart of a method according to an embodiment of the present invention; Figure 2 This is the schema structure definition for the UML sequence diagram structure generation and verification method based on a large language model in this embodiment of the invention; Figure 3 This is the chain-based reasoning prompt word structure of the UML sequence graph structured generation and verification method based on a large language model in this embodiment of the invention; Figure 4 This is a simplified example of the final visualized sequence diagram product of the UML sequence diagram structured generation and verification method based on a large language model in this embodiment of the invention. Detailed Implementation

[0035] The present invention will be further illustrated below with reference to specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. After reading the present invention, any modifications of the present invention in various equivalent forms by those skilled in the art will fall within the scope defined by the appended claims.

[0036] This invention discloses a method for structured generation and verification of UML sequence diagrams based on a large language model. The core idea is to constrain the structured output of the large language model through a predefined schema, ensuring the grammatical correctness of the output results and their conversion into a visual language. Furthermore, by constructing thought chains or workflows to constrain the output behavior and content of the large language model, the semantic correctness and consistency of the generated results are further improved. The following will describe this disclosure in detail with reference to the accompanying drawings and embodiments. This invention mainly includes the following steps: 1) use case text parsing; 2) structured constraints based on Jsonschema; 3) sequence diagram generation driven by a large language model; 4) visual language conversion of the sequence diagram; 5) control flow graph construction and jump scenario extraction; 6) automatic verification and consistency checking. The implementation process of each part is described in detail below.

[0037] For step 1, the first step is to extract text from all provided requirement documents to obtain use case descriptions and extract key information such as titles, actors, main success scenarios, and extended processes. Based on the file format of each document, an appropriate text extraction tool is selected to extract the full plain text. For example, Markdown is used to convert all provided Word-based requirement documents into plain text requirement documents expressed in Markdown markup language. Then, based on the functional requirements or use case scenario descriptions, a segmentation strategy is developed to cut the summarized requirement text into use case descriptions corresponding to individual sequence diagrams, as shown in Table 1.

[0038] Table 1. Simplified examples of use case scenario descriptions for each individual sequence diagram extracted after parsing.

[0039] The table is a simplified version of use case 17 from the SuperFrog Scheduler project, and includes the following information: Use Case ID and Name: Use Case 17 Spirit Team Schedule Management Key participant: Spirit administrator Secondary participants: None Triggering condition: The Spirit administrator instructs the management of the Spirit team calendar.

[0040] Description: Spirit administrators create events on the Spirit team calendar to shield time periods such as exam preparation days, final exam weeks, or major holidays, thus preventing customers from requesting SuperFrog attendance at events during these periods. Spirit administrators can also edit and delete calendar events to maintain accurate scheduling information.

[0041] Key success scenarios: The Spirit administrator instructs the management of the Spirit team calendar.

[0042] The system displays the calendar and prompts the Spirit administrator to choose an action: create an event (steps 4–8), edit an event (steps 9–13), or delete an event (steps 14–17).

[0043] The Spirit administrator selects one of the actions.

[0044] Depending on the Spirit administrator's selection in step 3, the process proceeds to steps 4–8, 9–13, or 14–17.

[0045] Spirit administrators can choose to create one-time events (such as final exam week) or recurring events. For each event, the Spirit administrator must provide: the event title (e.g., final exam week), start date and time, end date and time, and (if applicable) the start and end dates for recurring events.

[0046] The system verifies the creation operation.

[0047] The system displays details of the new event and requests confirmation from the Spirit administrator regarding its creation.

[0048] The Spirit administrator confirms the creation (continues the normal process), or selects to modify details (returns to step 4).

[0049] The system saves the created events and notifies the Spirit administrator that the calendar has been updated.

[0050] (Steps 9–17 omitted) 18. The Spirit administrator instructs you to complete the operation (proceed to step 19) or continue managing the calendar (return to step 2).

[0051] 19. End of use case.

[0052] Extended: 5a. There are pending attendance requests within the selected time frame.

[0053] 5a1. The system alerts the Spirit administrator to reject pending requests.

[0054] 5a2. Test case terminated.

[0055] (The expansion in steps 9–17 is omitted) For step 2, a JSON schema is constructed to constrain the structured output of the sequence diagram. This schema is designed according to the syntax specifications of UML sequence diagrams, including necessary structures such as participants, messages, and various combination fragments (e.g., alt, opt, loop, par, break). By setting the type, required fields, recursive nesting rules, and constraints for each field, the large language model is required to output only when the structure is valid, thus avoiding common problems such as missing structures, incorrect fields, and nesting mismatches. Subsequently, the schema is combined with the inference hints of the large language model, leveraging the structured output capabilities of the large language model to ensure that the model strictly adheres to the defined structured format when generating sequence diagrams, guaranteeing the parsability and consistency of the output sequence diagrams.

[0056] In practical implementation, the core field design of the JSON Schema is as follows: Figure 2 As shown, the schema includes: a participant list field, containing ID, type, and name, used to define all objects or executors appearing in the system; a message list field, containing sender, receiver, message content, and optional timestamps; and combined fragment fields such as alt / opt / loop / break, used to describe control structures such as conditional branches and loop blocks, supporting multi-level nesting. The schema definition can be customized according to actual needs. The model automatically generates the required fields and standardizes field formats during the inference process based on this schema, and performs structured inference on the output content before generation to ensure consistency between the sequence diagram structure and UML specifications.

[0057] For step 3, after determining the structured constraints, the sequence graph generation process is carried out using a large language model. The model can employ chain-of-thought (CoT) or a workflow-based step-by-step generation approach.

[0058] In chained reasoning mode, the model completes use case semantic parsing, participant identification, message extraction, and fragment generation in a single round of reasoning to obtain the overall sequence diagram structure. In workflow mode, the generation process is broken down into multiple stages: first, the participants and objects appearing in the scenario are identified; then, messages are generated one by one based on the action descriptions, and the order of the messages is inferred; next, conditional statements, loop descriptions, and exception flows in the text are identified and mapped to UML fragments such as alt, opt, and loop; finally, the aforementioned generation results are combined to construct a JSON sequence diagram structure that conforms to the schema.

[0059] To improve the generation quality, this invention makes the sequence diagram generation logic clearer and more accurate by constraining the output format of the model, guiding the model to explain its reasoning process, and using intermediate variables to store structured information, and enhances the modeling ability for complex demand scenarios.

[0060] This embodiment employs a chain-based reasoning generation method, and its prompt word structure is shown in the attached figure. Figure 3 As shown.

[0061] The prompt begins with an overall task description, explicitly defining the model's role as an expert in requirements engineering and UML modeling. The task definition requires the model to strictly adhere to a predefined JSON schema to generate sequence diagrams. Furthermore, explicit chain-of-thought instructions are provided to guide the reasoning process before generating the final result. The entire reasoning process is divided into five main steps.

[0062] In the "Extract Information" step, the model transforms the original use case text into a structured intermediate representation that includes a title, description, actors, main success scenarios, and extended scenarios. This step reduces noise in the use cases through structuring and ensures that key information relevant to the interaction is preserved.

[0063] In the "Determine Actors" step, the model refines the set of roles that actually participate in the interaction. Since the roles explicitly stated in the use case may not completely correspond to the actors in the final sequence diagram, the model is instructed to remove redundant roles and add missing roles to ensure that all entities participating in the interaction are represented in the final sequence diagram.

[0064] The "Identify Loops" step focuses on detecting iterative behavior described in the use cases. In our initial experiments, we observed that unidentified loops significantly impact the quality of the generated graph. Loops are typically identified by expressions such as "Return to step n" or "Continue from step n". The hint explicitly requires that all detected loops must be represented in the generated sequence graph. To this end, additional constraints are imposed in the hint to avoid ambiguous overlapping loops while allowing nested loops.

[0065] In the "Construct Diagram" step, we instruct the model to generate a sequence diagram in JSON format according to the schema specification. To help the model correctly generate messages and combined fragments, the hints provide domain knowledge, detailed instructions, and well-designed short examples.

[0066] The "Check and Revise" step requires the model to verify the logical consistency and completeness of the sequence diagram before generating the final result. This step helps reduce semantic inconsistencies between use cases and the generated diagram.

[0067] After each inference step, the model outputs the inference process for that step, and finally outputs the final JSON object. The hints include a JSON schema and a few examples to provide output format constraints and a reference for the generated artifacts.

[0068] Regarding step 4, this step aims to convert the JSON-formatted sequence diagram generated by the large language model into a sequence diagram description language that can be parsed by mainstream visualization tools. This conversion process is automatically implemented by the syntax mapping module, requiring no manual intervention.

[0069] In this embodiment, plantUML is selected as the target visualization tool. The system converts the definitions of participants, messages, and combined fragments in the JSON structure into the syntax supported by PlantUML. For example, participants are mapped to the `participant {participant_name} as {id}` statement in PlantUML, messages are mapped to the `A -> B: message[time]` format, and conditional structures are mapped to syntax blocks such as `alt / else / opt / loop`. The conversion process recursively generates target language code based on the inclusion relationships between sequence diagram elements, correctly handling the indentation of each line. After conversion, the system automatically renders and generates the sequence diagram via a script, and can export image formats such as PNG and SVG, achieving real-time visualization of the sequence diagram. (See Appendix...) Figure 1 The use case descriptions in the final generated sequence diagram product rendered by plantUml are shown in the attached image. Figure 4 As shown.

[0070] This step not only facilitates manual review of the generated results by developers, but also provides an intuitive basis for subsequent structural verification and document generation, improving the interpretability and usability of the overall system.

[0071] Regarding step 5, to verify whether the generated sequence graph conforms to logical relationships and business semantics, this invention constructs a Control Flow Graph (CFG) and extracts transition scenarios from it. The control flow graph is composed of messages and composite fragments from the sequence graph. Nodes in the control flow graph include message nodes and composite fragment nodes, where message nodes retain the sender, receiver, and message content of the corresponding message, while composite fragment nodes only retain their operator names. Edges in the control flow graph include unconditional edges and conditional edges, where conditional edges retain their transition conditions.

[0072] The sequence graph JSON structure is traversed, and each message and combined fragment is transformed into a control flow node. First, unconditional jump connections between nodes are established based on the order of messages in the sequence. Then, combined fragments are identified, and structured edges such as conditional jumps, loop jumps, and exception jumps are constructed according to their types. The edge representation only considers the pointers that meet specific conditions, regardless of the combined fragment type. The final generated control flow graph can completely represent all path relationships within the sequence graph.

[0073] Based on this, jump scenarios are automatically extracted, with a structure defined as "preceding message — [condition] → subsequent message". These jump scenarios can reflect whether the conditional semantics in the requirements are consistent with the flow structure in the actual sequence diagram, and play a crucial role in the subsequent verification process.

[0074] Regarding step 6, this step utilizes the automatically extracted participant set, message sequence set, and jump scenario set to perform semantic alignment with the baseline graph, thereby enabling the semantic consistency and logical correctness verification of the generated sequence graph.

[0075] Specifically, firstly, a large language model is used to semantically compare the names of participants in the sequence graph, identifying potential synonyms, abbreviations, or naming inconsistencies, and matching participants accordingly. Then, participants in all generated messages are mapped according to the matching results, and groups are formed based on sender-receiver pairs with consistent results. Semantic alignment of messages is achieved by semantically matching the text within the same group. Finally, based on the jump scenario extraction results from step 5, messages are semantically matched in the same way as above (determining whether the sender and receiver names and message content text are semantically consistent), establishing mappings between successfully matched messages. All parsed jump scenarios are grouped according to successfully matched previous-to-next message pairs, and semantic matching of conditional statements within the same group is used to check for omissions, redundancies, or logical errors in the control flow path.

[0076] The validation results will be output in the form of a structured report, which includes the precision, recall, and F1 score calculation results for participants, messages, and jump scenarios, consistency scores, discrepancy tips, and possible fix suggestions, thereby providing developers with reference and supporting further optimization of the model output.

[0077] Obviously, those skilled in the art should understand that the steps of the UML sequence diagram structured generation and verification method based on a large language model or the modules of the UML sequence diagram structured generation and verification system based on a large language model in the above embodiments of the present invention can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the embodiments of the present invention are not limited to any particular hardware and software combination.

Claims

1. A method for structured generation and verification of UML sequence diagrams based on a large language model, characterized in that, Includes the following steps: Step 1, Requirements Text Parsing: Perform natural language parsing on the input requirements text to extract the title, participants, main success scenario, and extended scenario information, and structure the extracted results into a sequence of scenario steps; Step 2: Construct a predefined sequence diagram JSON Schema according to the UML specification, and use the predefined sequence diagram JSON Schema as a constraint template for the large language model generation results to limit the structure of participants, messages and combined fragments; Step 3, Sequence diagram generation based on a large language model: Use a large language model to generate a JSON representation of the sequence diagram conforming to the JSON Schema from the structured scenario steps; Step 4, Visualization language conversion of JSON sequence diagrams: Automatically convert the JSON format sequence diagrams generated by the large language model into a modeling language that can be parsed by the visualization tool; convert participants, messages, and combined fragments into the corresponding statement structures of the tool through syntax mapping rules, and generate a sequence diagram file that can be rendered. Step 5, Control Flow Graph Construction and Jump Scenario Extraction: Construct a control flow graph based on JSON sequence graph, and automatically identify and extract a set of jump scenarios with the structure of preceding message → condition → subsequent message; Step 6, Sequence Graph Consistency Verification: Based on the extracted participant set, message set, and control flow graph transition scenario set, perform semantic and logical verification on the sequence graph, including: participant consistency check, message semantic alignment, and control flow structure consistency check, and finally output the verification conclusion of the sequence graph.

2. The method for structured generation and verification of UML sequence diagrams based on a large language model according to claim 1, characterized in that, In step 3, a sequence diagram conforming to JSON Schema is constructed based on either chain-based reasoning or workflow-based generation. Chain-based reasoning mode: All structure generation is completed in a single reasoning iteration; Workflow-based generation mode: The generation process is broken down into independent steps such as participant identification, message generation, and structure assembly, and the final sequence diagram is formed by combining intermediate structures.

3. The method for structured generation and verification of UML sequence diagrams based on a large language model according to claim 1, characterized in that, Natural language parsing of the input requirement text includes: paragraph recognition, scene segmentation and semantic extraction of the natural language text, and standardization of the step description into a structured sequence of steps.

4. The method for structured generation and verification of UML sequence diagrams based on a large language model according to claim 1, characterized in that, The construction of the predefined sequence diagram JSON Schema specifically includes: 21) Define the participant structure fields, including ID, type, and name; 22) Define message structure fields, including sender, receiver, message content, and timestamp; 23) Define the structure of the alt / opt / loop / break combined segment, including: type label, operands, and conditional statements or conditional statements of operands; 24) Define a special structure ref to represent a reference to other sequence diagrams, including a type label, a list of participant IDs, and the ID or title of the sequence diagram it points to; 25) Construct hierarchical structure templates that can be recursively parsed and nested according to the standard UML sequence diagram syntax rules for use by large language models.

5. The method for structured generation and verification of UML sequence diagrams based on a large language model according to claim 1, characterized in that, Visual language conversion specifically includes: 41) The statement that maps participants to participants or actors; 42) The mapped message is in the format A -> B: message[time]; 43) The mapping can be a nested combination of code segments that are correctly indented into corresponding tool code blocks, and the converted message statement is embedded in the correct position; 44) Sequence diagram rendering is completed automatically through visual scripts.

6. The method for structured generation and verification of UML sequence diagrams based on a large language model according to claim 1, characterized in that, Control flow graph construction and transition scenario extraction specifically include: 51) Transform each message into a control flow node; 52) Identify the boundaries of combined segments to form control flow branches; 53) Identify the edges connecting each control flow node and extract the possible jump conditions on the edges; 54) Parse the jump scenario triple (previous message, jump condition, subsequent message) from the control flow graph.

7. The method for structured generation and verification of UML sequence diagrams based on a large language model according to claim 1, characterized in that, Sequence graph consistency verification specifically includes: 61) Verify whether participants are duplicated, missing, or inconsistent by semantically matching participant names; 62) Based on the matching results in 61), establish a mapping between the sender and receiver in all generated messages and the participants in the same baseline set, and extract (sender, receiver) key-value pairs to group the message list. Verify whether the message content is duplicated, true or inconsistent by performing semantic matching on the message text within the same group. 63) Based on the matching results in 62), establish a mapping between the preceding and subsequent messages in all parsed jump scenarios and the messages in the same baseline set, and extract the (preceding message, subsequent message) key-value pairs to group the jump scenario list. Verify the correctness of the logical structure of the sequence diagram by performing semantic matching on the conditional judgment statements of the jump scenarios in the same group.

8. A UML sequence diagram structure generation and verification system based on a large language model, characterized in that, include: The use case parsing module is used to parse the requirement text and extract the title, participants, and scenario structure information; The structural constraint module is used to build and load the sequence diagram JSON schema and constrain the structure of the generated sequence diagram; The sequence diagram generation module is used to generate sequence diagrams that conform to JSON Schema based on chained reasoning or workflow generation methods; The visualization conversion module is used to automatically convert the generated JSON sequence diagram into the PlantUML / Mermaid visualization tool language to achieve automatic sequence diagram rendering; The control flow construction module is used to convert sequence graph messages and combined fragments into control flow graphs and extract transition scenarios; The consistency verification module is used to perform participant consistency checks, message semantic alignment, and control flow jump scenario alignment, and output the verification results.

9. A computer device, characterized in that: The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the method for generating and verifying UML sequence diagrams based on a large language model as described in any one of claims 1-8.

10. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that: When the computer program / instruction is executed by the processor, it implements the steps of the UML sequence diagram structure generation and verification method based on the large language model as described in any one of claims 1-8.