CAGE: Bridging the Accuracy-Aesthetics Gap in Educational Diagrams via Code-Anchored Generative Enhancement
Organizations: IIIT Delhi, India
Abstract
Educational diagrams -- labeled illustrations of biological processes, chemical structures, physical systems, and mathematical concepts -- are essential cognitive tools in K-12 instruction. Yet no existing method can generate them both accurately and engagingly. Open-source diffusion models produce visually rich images but catastrophically garble text labels. Code-based generation via LLMs guarantees label correctness but yields visually flat outputs. Closed-source APIs partially bridge this gap but remain unreliable and prohibitively expensive at educational scale. We quantify this accuracy-aesthetics dilemma across all three paradigms on 400 K-12 diagram prompts, measuring both label fidelity and visual quality through complementary automated and human evaluation protocols. To resolve it, we propose CAGE (Code-Anchored Generative Enhancement): an LLM synthesizes executable code producing a structurally correct diagram, then a diffusion model conditioned on the programmatic output via ControlNet refines it into a visually polished graphic while preserving label fidelity. We also introduce EduDiagram-2K, a collection of 2,000 paired programmatic-stylized diagrams enabling this pipeline, and present proof-of-concept results and a research agenda for the multimedia community.
Figures & tables
| Scenario | DALL·E 3 | GPT-4o | Gemini |
|---|---|---|---|
| Per image ($) | 0.040 | 0.080 | 0.040 |
| Per deck ($) | 0.48 | 0.96 | 0.48 |
| Teacher/yr a ($) | 19.20 | 38.40 | 19.20 |
| School/yr b ($) | 960 | 1,920 | 960 |
| Eff. cost c ($) | 1.3–1.6 above | ||
| Paradigm | Model | LEM | CER | FID | HVA | $/img |
| Open-src. diffusion | SDXL 1.0 | 11.3 | 71.4 | 112.6 | 3.8 | 0 |
| Flux.1-dev | 18.7 | 59.2 | 95.3 | 4.1 | 0 | |
| SD3 Med. | 14.9 | 64.8 | 103.7 | 3.9 | 0 | |
| Code-based (LLM code) | GPT-4o | 97.2 | 0.8 | 184.5 | 2.1 | 0 a |
| Claude 3.5 | 95.6 | 1.4 | 191.3 | 2.0 | 0 a | |
| Closed-src. APIs | DALL·E 3 | 64.3 | 19.7 | 98.4 | 4.0 | 0.04 |
| Property | Value |
|---|---|
| Total pairs | 2,000 |
| Subjects | Biology, Chemistry, Physics, Mathematics |
| Grade bands | K–5, 6–8, 9–12 |
| Diagram types | Flowcharts, labeled illustrations, concept maps, structural diagrams |
| Avg. labels/diagram | 8.4 |
| Rendering languages | Python, L a T e X /TikZ, SVG |
T2I Generation
Text-to-image generation creates images from natural-language prompts using generative models, with research focused on fidelity, control, efficiency, and safety.
See all 299 papers