OmniDiagram: Advancing Unified Diagram Code Generation via Visual Interrogation Reward
Organizations: Institute of Automation, Chinese Academy of Sciences · University of Chinese Academy of Sciences · Zhejiang University
Abstract
The paradigm of programmable diagram generation is evolving rapidly, playing a crucial role in structured visualization. However, most existing studies are confined to a narrow range of task formulations and language support, constraining their applicability to diverse diagram types. In this work, we propose OmniDiagram, a unified framework that incorporates diverse diagram code languages and task definitions. To address the challenge of aligning code logic with visual fidelity in Reinforcement Learning (RL), we introduce a novel visual feedback strategy named Visual Interrogation Verifies All (Viva). Unlike brittle syntax-based rules or pixel-level matching, Viva rewards the visual structure of rendered diagrams through a generative approach. Specifically, Viva actively generates targeted visual inquiries to scrutinize diagram visual fidelity and provides fine-grained feedback for optimization. This mechanism facilitates a self-evolving training process, effectively obviating the need for manually annotated ground truth code. Furthermore, we construct M3Diagram, the first large-scale diagram code generation dataset, containing over 196k high-quality instances. Experimental results confirm that the combination of SFT and our Viva-based RL allows OmniDiagram to establish a new state-of-the-art (SOTA) across diagram code generation benchmarks.
Figures & tables
| Model | Diagram-to-Code | Diagram Editing | Text-to-Code | ||||||||||||
| M3 2 Bench | CoSyn | M3 2 Bench | M3 2 Bench | VisPlot | |||||||||||
| Exec(%) | Exec(%) | Exec(%) | Exec(%) | Exec(%) | |||||||||||
| Closed-Source Models | |||||||||||||||
| GPT-5-mini | 77.6 | 62.8 | 27.0 | 76.5 | 59.8 | 21.9 | 66.6 | 52.5 | 63.5 | 87.3 | 65.1 | 81.6 | 57.5 | 34.2 | 50.5 |
| Gemini-3-Flash | 82.4 | 73.6 | 31.7 | 83.4 | 72.2 | 37.1 | 86.5 | 77.8 | 82.0 | 91.4 | 72.4 | 87.7 | 90.1 | 58.4 | 80.2 |
| Open-Source VLMs | |||||||||||||||
| Data | Model | Exec (%) | ||
| M3 2 Bench | Qwen2.5-Coder-3B | 66.4 | 40.0 | 46.3 |
| Viscoder2-3B | 77.9 ( 11.5) | 54.3 ( 14.3) | 70.5 ( 24.2) | |
| Qwen2.5-VL-3B | 32.6 | 17.9 | 22.8 | |
| OmniDia-3B (SFT) | 86.5 ( 53.9) | 64.0 ( 46.1) | 81.0 ( 58.2) | |
| OmniDia-3B (RL) | 90.3 ( 57.7) | 70.8 ( 52.9) | 85.0 ( 62.2) | |
| Qwen2.5-Coder-7B | 73.0 | 50.2 | 63.3 |
| Configuration Strategy | Diagram-to-Code | Diagram Editing | Text-to-Code | |||
| Exec (%) | Exec (%) | Exec (%) | ||||
| Exp 1: Impact of Reasoning Trajectories | ||||||
| SFT (w/o Reasoning Data) | 88.6 | 61.8 | 70.1 | 58.3 | 86.5 | 72.5 |
| SFT + RL (w/o Reasoning Data) | 93.0 | 61.9 | 75.5 | 61.9 | 90.3 | 77.9 |
| SFT (w/ Reasoning Data) | 81.3 | 51.5 | 71.2 | 58.7 | 68.0 | 57.8 |
| SFT + RL (w/ Reasoning Data) | 89.3 | 55.4 | 77.6 | 62.6 | 88.1 | 76.0 |
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
| L a T e X | Mermaid | PlantUML | |||
| Diagram Type | Ratio (%) | Diagram Type | Ratio (%) | Diagram Type | Ratio (%) |
| Graph (Nodes & Edges) | 28.6 | Flowchart | 12.9 | Activity Diagram | 45.9 |
| Flowchart | 13.8 | Class Diagram | 12.3 | Sequence Diagram | 23.1 |
| Block Diagram | 13.7 | Kanban Board | 10.6 | Use Case Diagram | 13.5 |
| Timeline | 10.0 | Timeline | 9.6 | State Diagram | 6.6 |
| Finite State Machine | 7.5 | Entity Relationship | 9.4 | Deployment Diagram | 3.5 |
| Language | Error Category | OmniDiagram (RL) | |
| 3B | 7B | ||
| LaTeX | Reference Error | 33 | 23 |
| Structural Error | 16 | 10 | |
| Syntax Error | 15 | 13 | |
| Math & Resource Error | 8 | 9 | |
| Dependency & Encoding | 7 | 6 | |
| Model Setting | Inf. | Rob. | Rendered (v) | Overall | ||
| Exec (%) | ||||||
| Qwen2.5-VL-3B | Direct | 51.2 | 43.7 | 62.3 | 22.0 | 32.0 |
| VisCoder2-3B | Direct | 76.3 | – | – | 43.0 | 59.0 |
| 3B_SFT (190k) | Direct | 82.4 | 55.1 | 77.9 | 45.8 | 64.3 |
| 3B_SFT (270k) | Direct | 84.7 | 55.3 | 73.9 | 47.0 | 63.0 |
| Think | 69.5 | 59.2 | 75.0 | 41.0 | 52.0 | |
Code Generation
Code generation studies methods for turning natural-language, visual, or formal specifications into executable programs and code edits.
See all 313 papers