arXiv:2604.23816cs.SEcs.AI2026-04

用大模型根据开发者提问生成精准的UML图,解决文档缺失问题。

Query2Diagram: Answering Developer Queries with UML Diagrams

论文配图:Query2Diagram: Answering Developer Queries with UML Diagrams
图 1 · 摘自论文原文
  • 基于自然语言查询生成聚焦的UML图,只保留相关元素。
  • 微调后模型在结构缺陷率上低于现有方法,F1分数最优。
  • 适合需要快速理解代码逻辑的开发人员或团队协作场景。

软件文档常过时或缺失,但开发者仍需聚焦的代码视图来理解复杂系统。现有反向工程工具虽能自动生成UML图,却信息冗余,不考虑开发意图。本文提出查询驱动的UML图生成方法,利用大模型根据自然语言问题生成语义聚焦的图表,仅包含相关元素并附上下文说明。我们在一个精心构建的数据集上对Qwen2.5-Coder-14B进行微调,该数据集包含代码文件、开发者查询和对应结构化JSON格式的图表示。通过自动检测结构缺陷与人工评估语义相关性双重验证,结果表明:仅需少量人工修正数据即可实现显著提升——最佳模型在F1得分上领先,缺陷率低于当前先进水平,生成的图表既结构正确又忠实于查询意图。本工作证明了大模型可用于可扩展的上下文感知、按需生成文档。代码与数据集已开源:https://github.com/i-need-a-pencil/query2diagram。

原文摘要 · Abstract (English)

Software documentation frequently becomes outdated or fails to exist entirely, yet developers need focused views of their codebase to understand complex systems. While automated reverse engineering tools can generate UML diagrams from code, they produce overwhelming detail without considering developer intent. We introduce query-driven UML diagram generation, where LLMs create diagrams that directly answer natural language questions about code. Unlike existing methods, our approach produces semantically focused diagrams containing only relevant elements with contextual descriptions. We fine-tune Qwen2.5-Coder-14B on a curated dataset of code files, developer queries, and corresponding diagram representations in a structured JSON format, evaluating with both automatic detection of structural defects and human assessment of semantic relevance. Results demonstrate that fine-tuning on a modest amount of manually corrected data yields dramatic improvements: our best model achieves the highest F1 scores while reducing defect rates below state-of-the-art LLMs, generating diagrams that are both structurally sound and semantically faithful to developer queries. Thus, we establish the feasibility of using LLMs for scalable contextual, on-demand documentation generation. We make our code and dataset publicly available at https://github.com/i-need-a-pencil/query2diagram.

代码理解大模型UML生成智能文档

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。