spot_img
HomeResearch & DevelopmentEnhancing Code Generation with Explicit Data Dependencies from UML...

Enhancing Code Generation with Explicit Data Dependencies from UML Diagrams

TLDR: UML2Dep is a new framework that improves large language models’ ability to generate industrial code by explicitly inferring data dependencies from enhanced UML sequence diagrams. It uses mathematical formalization and context pruning to provide precise input to LLMs, leading to significantly higher code compilation and unit test pass rates in complex real-world scenarios.

Large language models (LLMs) have shown incredible potential in writing code from natural language descriptions. However, when it comes to generating complex, production-ready software, these models often hit a wall. Natural language can be ambiguous and struggles to capture intricate details like system behaviors, conditional logic, and the hidden connections between different pieces of data in a system. This makes it hard for LLMs to correctly understand and handle how data flows from one part of a system to another.

To tackle this challenge, a new framework called UML2Dep has been introduced. This framework aims to bridge the gap between ambiguous natural language and the precise requirements of industrial code generation by using formal specifications. It introduces a novel, step-by-step approach to code generation.

Enhanced UML Sequence Diagrams for Clarity

The first key innovation in UML2Dep is an enhanced version of the Unified Modeling Language (UML) sequence diagram. Traditional sequence diagrams are great for showing how different parts of a system interact, but they often fall short in explicitly representing how data moves between these interactions. The enhanced diagrams in UML2Dep are specifically designed for service-oriented architectures, which are common in modern software. They go beyond standard visual elements by incorporating “decision tables” and “API specifications.”

Decision tables explicitly define business rules, validation logic, and workflow decisions, detailing conditions and actions. API specifications provide comprehensive information about each service interface, including input parameters, outputs, data types, and constraints. This rich, structured information helps eliminate linguistic ambiguity and provides a solid foundation for understanding complex business rules and logic.

Data Dependency Inference: A Critical New Task

Recognizing that data flow is the “lifeblood” of software execution, UML2Dep introduces a dedicated task called Data Dependency Inference (DDI). Before any code is actually written, DDI systematically builds an explicit “data dependency graph.” This graph clearly shows which piece of data is produced by one part of the system and consumed by another. To ensure this inference is reliable, DDI is formalized as a mathematical reasoning task, leveraging the strong mathematical capabilities of LLMs. Additionally, static parsing and “dependency pruning” techniques are used to reduce the complexity of the information the LLM needs to process, improving accuracy and efficiency.

Improving LLM Performance with Mathematical Formalization and Context Pruning

The framework uses a novel “mathematical formalization prompting” strategy. Instead of vague natural language instructions, the LLM is given precise mathematical definitions of inputs (like sequence diagrams and API specs) and expected outputs (the data dependency graph). This structured approach helps the LLM reason more effectively about complex data flow relationships. Industrial sequence diagrams can be very large and contain a lot of information, much of which might not be relevant to a specific data dependency. To address this, UML2Dep employs a “reachability-based context pruning” technique. This method identifies only the relevant preceding nodes that could potentially supply data to a target node, removing unnecessary information and reducing the LLM’s “cognitive load.” This helps the LLM focus on constructing accurate data dependencies and reduces the chance of errors or “hallucinations.”

Also Read:

Real-World Impact and Results

The effectiveness of UML2Dep has been demonstrated on real-world industrial datasets from WeChat Pay. The framework achieved strong performance in the DDI task, with an average recall of 89.97%, precision of 95.06%, and an F1 score of 92.33%. More importantly, integrating UML2Dep into the code generation pipeline significantly improved the quality of the generated code. The compilation pass rate increased by 8.83%, and the unit test pass rate improved by 11.66%. These results show that by explicitly providing data dependency information, UML2Dep helps LLMs generate more structurally sound and functionally correct code, especially for complex enterprise-level systems.

The framework has been successfully integrated into an industrial code generation pipeline, proving its practical value. It also serves as an AI-assisted tool for designers, allowing them to visualize inferred data dependencies and detect design errors early. This includes identifying missing data sources or type compatibility issues, enabling real-time validation and correction during the design phase.

For more in-depth information, you can read the full research paper: Data Dependency Inference for Industrial Code Generation Based on UML Sequence Diagrams.

Nikhil Patel
Nikhil Patelhttps://blogs.edgentiq.com
Nikhil Patel is a tech analyst and AI news reporter who brings a practitioner's perspective to every article. With prior experience working at an AI startup, he decodes the business mechanics behind product innovations, funding trends, and partnerships in the GenAI space. Nikhil's insights are sharp, forward-looking, and trusted by insiders and newcomers alike. You can reach him out at: [email protected]

- Advertisement -

spot_img

Gen AI News and Updates

spot_img

- Advertisement -