Data Dependency Inference for Industrial Code Generation Based on UML Sequence Diagrams

Wenxin Mao, Zhitao Wang, Long Wang, Sirong Chen, Cuiyun Gao, Luyang Cao, Ziming Liu, Qiming Zhang, Jun Zhou, Zhi JinarXiv 2025 · DOI · arXiv

Abstract: Large Language Models (LLMs) frequently struggle with complex software requirements due to the ambiguity of natural language and the implicit nature of data dependencies in standard UML sequence diagrams. This paper presents UML2Dep, a framework designed to improve automated code generation by explicitly inferring missing data dependencies. By utilizing enhanced UML diagrams, mathematical formalization, and reachability-based context pruning, UML2Dep achieves a 92.33% F1 score in dependency inference. Experimental results on industrial microservice datasets demonstrate significant improvements in both compilation and unit test pass rates for generated code.

1. Introduction

Unified Modeling Language (UML) sequence diagrams are the industry standard for software design, yet they possess a significant limitation: they primarily capture control flow while leaving data dependencies implicit. When LLMs attempt to generate code from these diagrams, they face a "dual cognitive load," forced to simultaneously reconstruct logic and guess data relationships. This often results in "hallucinations," where the model invents data sources or misses critical parameters, leading to code that fails in production environments.

2. The UML2Dep Framework

The authors propose UML2Dep to bridge the gap between high-level design and executable code. The framework treats Data Dependency Inference (DDI) as a standalone preprocessing step, decoupling the "thinking" about data from the "writing" of the code.

Overview of the UML2Dep framework, from enhanced sequence diagrams to code generation.

The framework consists of four primary stages:

  • Enhanced UML Sequence Diagrams: Traditional UML syntax is extended by binding Decision Tables (to clarify business logic) and Refined API Specifications (detailing data types and constraints).
  • Data Dependency Inference (DDI) Task: The LLM is tasked with building a directed Data Dependency Graph before code generation begins.
  • Mathematical Formalization Prompting: Leveraging the reasoning capabilities of models like DeepSeek-R1, the DDI task is defined using formal mathematical sets and graph-theoretic constraints rather than ambiguous prose.
  • Reachability-Based Context Pruning: To handle massive industrial diagrams, the system parses the design into an Execution Dependency Graph (EDG) and prunes logically unreachable nodes.

3. Context Pruning and Reachability

Industrial-scale diagrams often contain excessive "noise" that can overwhelm an LLM's context window. UML2Dep addresses this by identifying reachable predecessors for any given target node.

Construction of the Execution Dependency Diagram (EDG) and identification of reachable nodes to prune irrelevant context.

By converting the sequence diagram into an EDG, the framework can identify which function or control nodes are logically relevant to a specific target. Pruning irrelevant information reduces token consumption and prevents "noise amplification," allowing the model to focus on the correct data sources.

4. Experimental Evaluation

The framework was evaluated using an industrial dataset from WeChat Pay, comprising 11 complex microservice design diagrams and 224 ground-truth dependency relations approved by professional engineers.

Key Results:

  • Inference Accuracy: The framework achieved 95.06% precision and 89.97% recall (92.33% F1 score) on the dependency inference task.
  • Code Quality Improvements: Integrating inferred dependencies into the generation pipeline led to an 8.83% increase in compilation pass rates and an 11.66% increase in unit test pass rates.
  • Model Performance: Reasoning-focused models like DeepSeek-R1 significantly outperformed standard models (like DeepSeek-V3) on complex diagrams with many branching paths.

5. Conclusion and Future Work

UML2Dep demonstrates that formalizing data dependencies and pruning irrelevant context significantly reduces LLM hallucinations in industrial settings. While the current requirement for "enhanced" diagrams involves manual effort, future work aims to automate the generation of these specifications from existing documentation and extend the DDI approach to other architectural diagrams, such as State Machine or Activity diagrams.

Summary updated

Abstract

Large language models (LLMs) excel at generating code from natural language (NL) descriptions. However, the plain textual descriptions are inherently ambiguous and often fail to capture complex requirements like intricate system behaviors, conditional logic, and architectural constraints; implicit data dependencies in service-oriented architectures are difficult to infer and handle correctly. To bridge this gap, we propose a novel step-by-step code generation framework named UML2Dep by leveraging unambiguous formal specifications of complex requirements. First, we introduce an enhanced Unified Modeling Language (UML) sequence diagram tailored for service-oriented architectures. This diagram extends traditional visual syntax by integrating decision tables and API specifications, explicitly formalizing structural relationships and business logic flows in service interactions to rigorously eliminate linguistic ambiguity. Second, recognizing the critical role of data flow, we introduce a dedicated data dependency inference (DDI) task. DDI systematically constructs an explicit data dependency graph prior to actual code synthesis. To ensure reliability, we formalize DDI as a constrained mathematical reasoning task through novel prompting strategies, aligning with LLMs' excellent mathematical strengths. Additional static parsing and dependency pruning further reduce context complexity and cognitive load associated with intricate specifications, thereby enhancing reasoning accuracy and efficiency.
BibTeX
@misc{gao2025data,
  author = {Cuiyun GAO and Wenxin Mao and Zhitao Wang and Long Wang and Sirong Chen and Cuiyun Gao and Luyang Cao and Ziming Liu and Qiming Zhang and Jun Zhou and Zhi Jin},
  title = {{Data Dependency Inference for Industrial Code Generation Based on UML Sequence Diagrams}},
  year = {2025},
  eprint = {2508.03379},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.03379},
}
Figure