← Latest papers
💻 computer science

Query2Diagram: Answering Developer Queries with UML Diagrams

This paper introduces Query2Diagram, a fine-tuned LLM approach that generates semantically focused UML diagrams from natural language developer queries to address the limitations of traditional reverse engineering tools by producing structurally sound, context-aware visualizations of relevant code elements.

Original authors: Oleg Baryshnikov (HSE University), Anton M. Alekseev (St. Petersburg Department of Steklov Mathematical Institute, RAS, St. Petersburg State University), Sergey I. Nikolenko (St. Petersburg Department
Published 2026-04-28
📖 4 min read☕ Coffee break read

Original authors: Oleg Baryshnikov (HSE University), Anton M. Alekseev (St. Petersburg Department of Steklov Mathematical Institute, RAS, St. Petersburg State University), Sergey I. Nikolenko (St. Petersburg Department of Steklov Mathematical Institute, RAS, St. Petersburg State University)

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you've just moved into a massive, sprawling mansion (your software codebase). You want to understand how the plumbing works, or which rooms connect to the kitchen, but the blueprints are either missing, outdated, or so incredibly detailed they look like a tangled ball of yarn.

This is the problem software developers face every day. They need to understand complex code, but the existing "maps" (UML diagrams) are either non-existent or so cluttered with every single screw and wire that they are useless for finding a specific answer.

The Solution: A "Smart Personal Guide"
The authors of this paper, "Query2Diagram," propose a new way to solve this. Instead of generating a massive, overwhelming map of the whole mansion, they built a system that acts like a smart, on-demand tour guide.

Here is how it works, using simple analogies:

1. The Old Way vs. The New Way

  • The Old Way (Reverse Engineering Tools): Imagine asking a robot to draw a map of your house. The robot draws everything: every brick, every nail, every light switch, and every dust bunny. It's technically accurate, but if you ask, "Where is the coffee maker?", you have to sift through a million irrelevant details to find it. It's too much information.
  • The New Way (Query2Diagram): You ask the robot a specific question: "Show me how the coffee maker connects to the water line." The robot ignores the rest of the house and draws only the coffee maker and the pipes connecting to it. It gives you a focused, clear picture that directly answers your question.

2. How They Taught the Robot (The "Training" Phase)

To make this happen, the researchers used a Large Language Model (LLM), which is like a very smart student who has read a lot of books about code. However, this student was initially making mistakes:

  • Sometimes it drew things that didn't exist (hallucinations).
  • Sometimes it included too much junk (verbosity).
  • Sometimes the map was drawn with broken lines (structural defects).

The Fix:
The researchers didn't just let the student guess. They created a "textbook" of perfect examples.

  1. The Dataset: They took real code files and asked the student to draw diagrams for specific questions.
  2. The Correction: They hired human experts to look at the student's drawings. If the student drew a fake pipe or missed a connection, the experts fixed it.
  3. The Lesson: They fed these "corrected" drawings back to the student. It's like a teacher saying, "You got the coffee maker right, but you forgot the water valve. Here is the right way to draw it."

They used a specific model called Qwen2.5-Coder-14B and "fine-tuned" it (retrained it) on this small but high-quality set of corrected examples.

3. The Results: A Better Map

The paper tested this new "guide" against other smart AI models (like GPT-4o and Claude). Here is what they found:

  • Fewer Mistakes: The fine-tuned model made far fewer structural errors. Its maps were "sound," meaning the lines connected correctly and the shapes made sense.
  • Better Answers: It was much better at ignoring irrelevant details. If you asked about the coffee maker, it didn't draw the bedroom.
  • The Sweet Spot: The best version of their model achieved the highest "F1 score." In plain English, this means it found the perfect balance: it didn't miss important parts (high recall) and it didn't include fake or useless parts (high precision).

4. Why This Matters

The paper claims that you don't need a massive amount of data to teach an AI to do this well. Just a modest amount of high-quality, human-corrected data was enough to dramatically improve the results.

They also built a system that outputs the diagrams in a structured format (JSON), which can be instantly turned into visual charts (like PlantUML or Mermaid) that developers can actually read.

Summary

Think of this paper as the invention of a "Just-in-Time Map Maker."

  • Before: You had to buy a giant, expensive atlas of the whole world just to find your street.
  • Now: You can ask, "Where is my street?" and get a perfect, zoomed-in map instantly, drawn by an AI that has been trained to listen to exactly what you need.

The authors have made their code and data public, allowing others to build this "smart guide" for their own software projects.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →