一句话:提出 UML2Dep 框架,用增强 UML 序列图显式建模并结合数据依赖推断,提升 LLM 从复杂需求生成代码的可靠性。
针对自然语言需求歧义大、难以刻画复杂系统行为与架构约束,以及服务化架构中隐式数据依赖难以推断的问题,本文提出分步代码生成框架 UML2Dep。该框架扩展 UML 序列图,加入决策表和 API 规格,显式形式化服务交互的结构关系与业务逻辑流;并将数据依赖推断(DDI)作为独立任务,在代码合成前构建显式依赖图,通过数学化提示、静态解析与依赖剪枝降低上下文复杂度。在自建工业数据集上,DDI 取得 89.97% 召回率、95.06% 精确率和 92.33% F1;接入代码生成流程后,编译通过率提升 8.83%,单元测试通过率提升 11.66%。
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.Experimental results on our in-house industrial datasets demonstrate the effectiveness of the proposed framework. Specifically, our framework achieves strong performance, with 89.97% recall, 95.06% precision, and 92.33% F1 score on the DDI task. Furthermore, the integration of UML2Dep into the code generation pipeline also improves practical deployment, increasing compilation pass rate by 8.83% and unit test pass rate by 11.66%.
DOI 原文 ·
@inproceedings{paperbot9548,
title = {Data Dependency-Aware Code Generation from Enhanced UML Sequence Diagrams},
author = {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},
booktitle = {ASE},
year = {2025},
doi = {10.1109/ase63991.2025.00282}
}