arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2508.03379cs.AIcs.SE
收藏

基于增强UML顺序图的数据依赖感知代码生成

Data Dependency-Aware Code Generation from Enhanced UML Sequence Diagrams

WeChat Pay, Tencent Inc(腾讯公司);The Chinese University of Hong Kong(香港中文大学);Wuhan University(武汉大学)

Wenxin Mao, Zhitao Wang, Long Wang, Sirong Chen, Cuiyun Gao, Luyang Cao, Ziming Liu, Qiming Zhang, Jun Zhou, Zhi Jin

AI总结:

提出UML2Dep框架,通过增强UML顺序图显式形式化复杂需求,并引入数据依赖推断(DDI)任务构建依赖图,结合静态解析与剪枝降低复杂性,提升LLM代码生成的准确性与效率。

摘要:

大型语言模型(LLMs)擅长从自然语言(NL)描述生成代码。然而,纯文本描述本质上具有歧义性,往往无法捕捉复杂需求,如错综复杂的系统行为、条件逻辑和架构约束;面向服务架构中的隐式数据依赖难以推断和正确处理。为弥合这一差距,我们提出了一种名为UML2Dep的新型逐步代码生成框架,利用复杂需求的无歧义形式化规范。首先,我们引入了一种专为面向服务架构定制的增强型统一建模语言(UML)顺序图。该图通过集成决策表和API规范扩展了传统视觉语法,显式形式化服务交互中的结构关系和业务逻辑流,从而严格消除语言歧义。其次,认识到数据流的关键作用,我们引入了专门的数据依赖推断(DDI)任务。DDI在实际代码合成之前系统性地构建显式数据依赖图。为确保可靠性,我们通过新颖的提示策略将DDI形式化为受约束的数学推理任务,与LLMs卓越的数学能力相契合。额外的静态解析和依赖剪枝进一步降低了与复杂规范相关的上下文复杂性和认知负荷,从而提升了推理准确性和效率。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑