Sketch2TikZ: Multi-Reward Reinforcement Learning for Converting Hand-Drawn Sketches to Executable TikZ
Organizations: TCS Research, New Delhi, India · TCS Research, Pune, India
Abstract
Automatic digitization of hand-drawn sketches into editable formats is crucial for modern document workflows and LaTeX integration. Converting sketches into executable TikZ code provides a structured representation of diagrams, but remains challenging due to noisy and ambiguous inputs, which hinder reliable interpretation and limit the effectiveness of token-level supervision for ensuring global diagram validity. To address these challenges, we propose Sketch2TikZ, a reinforcement learning framework that optimizes sketch-to-code generation via a sequential multi-reward strategy, combining Code-Structure (), OCR (), CleanDIFT (), and Self-Similarity () rewards to enforce textual, visual and structural correctness. We evaluate Sketch2TikZ on the SkeTikZ and FlowChart-3B benchmarks using metrics including compilation success rate (CSR), image similarity, code similarity, and character similarity. Our method achieves near-perfect compilation success and improves visual and textual alignment over strong open-source baselines, while remaining competitive with proprietary GPT-based vision-language models. Extensive ablations demonstrate that curriculum-based reward scheduling is critical for reducing reward interference, stabilizing training and mitigating proxy over-optimization. Overall, our results highlight the effectiveness of reference-aware, multi-objective reinforcement learning for structured diagram generation from noisy sketches.
Figures & tables
| Model | Params | SkeTikZ [ Saito et al.(2025)Saito, Yoshida, and Sakaguchi ] | FlowChart-3b [ C. David Betancourt Montellano(2022) ] | |||||
| CSR | ImageSim | CodeSim | CharSim | CSR | ImageSim | CharSim | ||
| Closed Models | ||||||||
| GPT-5 | - | 0.9947 | 0.8461 | 0.7592 | 0.7283 | 0.928 | 0.8412 | 0.6965 |
| GPT-4o | - | 0.9659 | 0.8539 | 0.7671 | 0.7131 | 0.885 | 0.8229 | 0.6736 |
| GPT-4o-mini | - | 0.9449 | 0.8152 | 0.7481 | 0.6998 | 0.871 | 0.8186 | 0.6749 |
| Open Models | ||||||||
| Training Strategy | CSR | ImageSim | CodeSim | CharSim | Convergence Steps ( ) |
| Single-Objective Training | |||||
| 0.9978 | 0.7746 | 0.7283 | 0.4771 | 1.25 | |
| 0.9722 | 0.8093 | 0.7642 | 0.5931 | 2.47 | |
| 0.9652 | 0.8226 | 0.7549 | 0.5815 | 1.54 | |
| 0.9671 | 0.8289 | 0.7661 | 0.5735 | 1.86 | |
| Multi-Objective Training | |||||
| Reward | Mean Reward Score (Start End) | Image Similarity (Start End) | Gold Score (Start End) | Over-optimization Gap ( ) |
|---|---|---|---|---|
| 0.86 0.96 | 0.8139 0.7746 | 2.84 2.56 | -0.0393 / -0.28 | |
| 0.47 0.51 | 0.8139 0.8093 | 2.84 2.77 | -0.0046 / -0.07 | |
| 0.59 0.66 | 0.8139 0.8226 | 2.84 2.85 | 0.0087 / 0.01 | |
| 0.63 0.71 | 0.8139 0.8289 | 2.84 2.81 | 0.015 / -0.03 | |
| + | 0.72 0.78 | 0.8139 0.8295 | 2.84 2.93 | 0.0156 / 0.09 |
| 0.73 0.81 | 0.8295 0.8448 | 2.93 3.15 | 0.0153 / 0.22 |
Code Generation
Code generation studies methods for turning natural-language, visual, or formal specifications into executable programs and code edits.
See all 357 papers