Abstract
Text-to-image (T2I) generation has seen significant growth over the past few years. Despite this, there has been little work on generating diagrams with T2I models. A diagram is a symbolic/schematic representation that explains information using structurally rich and spatially complex visualizations. Existing state-of-the-art T2I models often fail at diagram generation because they lack fine-grained object layout control when many objects are densely connected via complex relations, and also often fail to render comprehensible text labels. To address this gap, we present DiagrammerGPT, a novel two-stage text-to-diagram generation framework leveraging the layout guidance capabilities of LLMs to generate more accurate diagrams.
Introduction
While modern Text-to-Image (T2I) models excel at photorealistic art, they struggle with logical visuals like diagrams. Standard models often produce "visual soup" when tasked with scientific schematics: arrows point nowhere, objects overlap, and text labels are illegible. The core challenge lies in fine-grained layout control. Diagrams require precise spatial relationships and crisp, readable text—structural understandings that standard diffusion models lack.
The DiagrammerGPT Framework
DiagrammerGPT addresses these challenges through a two-stage pipeline that decouples logical planning from aesthetic rendering.
Stage 1: Diagram Planning
In the first stage, an LLM (such as GPT-4) acts as a Planner. Instead of generating pixels, it produces a "diagram plan"—a structured specification of entities, their 2D bounding box coordinates, and their relationships (e.g., "Object A has an arrow to Object B").
To ensure logical consistency, the framework employs an Auditor Loop. A second LLM instance acts as an "Auditor," reviewing the initial plan for errors—such as incorrect scales or missing connections—and providing feedback to the Planner for iterative refinement.
Stage 2: Diagram Generation
The refined plan is passed to DiagramGLIGEN, a specialized diffusion model. Using gated self-attention layers, it "grounds" the generation process, ensuring objects are placed according to the plan's coordinates. To solve the problem of illegible text, the system uses the Pillow library to render crisp labels directly onto the generated image based on the plan's metadata.
Because the output of Stage 1 is a structured plan, DiagrammerGPT is Open-Platform. Plans can be exported to vector graphic tools like Microsoft PowerPoint or Adobe Illustrator, enabling human-in-the-loop editing.
Datasets and Evaluation
The researchers introduced AI2D-Caption, a benchmark for text-to-diagram generation built on the AI2D dataset. Using LLaVA 1.5, they generated dense, detailed captions and region descriptions for ~5,000 scientific diagrams to facilitate training and evaluation.
Key Results
- VPEval Superiority: DiagrammerGPT achieved a score of 71.2% on the VPEval metric (measuring object presence and relationships), significantly outperforming a fine-tuned Stable Diffusion v1.4 (45.1%).
- Human Preference: In head-to-head evaluations, DiagrammerGPT was preferred 68% of the time for image-text alignment and 62% for object relationships.
- Open-Domain Success: The model successfully generated diagrams for complex, unseen topics like neural network architectures, demonstrating robust generalization.
Discussion and Future Work
DiagrammerGPT demonstrates that decoupling logic from aesthetics is key to complex visual generation. By forcing LLMs (strong at spatial reasoning) and diffusion models (strong at drawing) to communicate via a structured plan, the system achieves superior results.
However, limitations remain. The final image quality is tied to the underlying diffusion backbone (currently Stable Diffusion v1.4). Additionally, iterative planning with GPT-4 introduces higher latency and cost ($0.17 per plan). Future work will focus on expanding to multi-lingual support and improving icon style consistency across vector exports.
Summary updated