Scientific Graphics Program Synthesis via Dual Self-Consistency Reinforcement Learning

Juekai Lin, Yun Zhu, Honglin Lin, Sijing Li, Tianwei Lin, Zheng Liu, Xiaoyang Wang, Wenqiao Zhang, Lijun WuarXiv 2026

TL;DR

Reverse-engineering scientific diagrams from static images into editable TikZ vector code is notoriously difficult due to strict compilation rules and precise spatial constraints. This paper introduces SciTikZer, a framework that combines a high-quality 230K dataset with a novel Dual Self-Consistency Reinforcement Learning (DSC-RL) paradigm. By enforcing a "round-trip" consistency check—ensuring the model can accurately reconstruct code from its own rendered images—SciTikZer-8B achieves state-of-the-art performance, outperforming proprietary models and open-source giants over 20 times its size.

What Problem Does This Paper Address?

Converting static scientific graphics (like flowcharts, circuit diagrams, or geometric plots) into editable code is highly desirable for researchers and educators. The TikZ language in LaTeX is the gold standard for this, but it is notoriously unforgiving. Unlike standard plotting libraries that tolerate layout approximations, TikZ requires exact coordinates and explicit primitives. As shown in Figure 1, a single missing package or minor syntax hallucination causes the entire compilation to fail.

Figure 1: Challenges in graphics program synthesis. Current open-source MLLMs struggle with the strict constraints of TikZ, exhibiting critical issues such as syntax hallucinations, dependency omissions and geometric misalignments.

Current Multimodal Large Language Models (MLLMs) struggle with this task due to two primary bottlenecks:

  1. Data Quality Gap: Existing image-to-TikZ datasets are plagued by non-compilable code fragments and poor visual alignment.
  2. Evaluation Gap: There is a lack of comprehensive benchmarks capable of evaluating both visual similarity and underlying structural logic.

Methods

The authors address these challenges through a three-stage pipeline:

  1. Execution-Centric Data Engine: Instead of passively filtering noisy web data, this engine uses an MLLM to refactor broken code fragments into standalone, compilable documents. It also features a "Repair Agent" that iteratively fixes compilation errors using real-time compiler diagnostics.
  2. Curriculum Data Selection: To maximize reinforcement learning efficiency, the framework filters out tasks that are either too easy or completely intractable, focusing training strictly on the model's "zone of proximal development."
  3. Dual Self-Consistency Reinforcement Learning (DSC-RL): Implemented via Group Relative Policy Optimization (GRPO), this novel RL paradigm operates in two progressive stages:
  4. Stage 1 (Visual Fidelity Alignment): Anchors the model using an execution-gated reward (harshly penalizing compilation failures) combined with semantic (SigLIP) and structural (LPIPS) visual rewards.
  5. Stage 2 (Self-Consistency Refinement): Introduces a symbolic round-trip mechanism (see Figure 4). The model generates TikZ code from an image, renders it, and then attempts to back-translate its own rendered image back into the original code. The model is rewarded if the original and reconstructed code match structurally (measured via Token Edit Distance and CrystalBLEU).
Figure 4: Overview of the SciTikZ Framework. The pipeline initializes with SFT and Curriculum Data Selection. Core DSC-RL integrates Visual Alignment for pixel precision and Self-Consistency Refinement via symbolic back-translation.

Datasets

  • SciTikZ-230K: A newly curated, large-scale dataset containing 230,000 high-quality, strictly compilable image-code pairs spanning 11 scientific domains and over 90 fine-grained subcategories (see Figure 2).
  • SciTikZ-Bench: A new evaluation benchmark consisting of 611 manually verified, decontaminated samples across a stratified difficulty gradient (Easy, Medium, Hard).
  • DaTikZ-v3: An established external dataset used to evaluate out-of-distribution generalization.
  • ChartMimic: A Python-based chart dataset used to test the framework's cross-language generalization capabilities.
Figure 2: Overview of the SciTikZ-230K Dataset. The chart above presents the hierarchical distribution of our full dataset, spanning 11 scientific domains and over 90 fine- grained sub-categories.

Key Insights and Ideas

  • The Power of the Round-Trip: Standard visual reinforcement learning often suffers from "visual hacking," where a model generates messy, uneditable code that happens to render into a visually similar image. Forcing the model to read its own rendered image back into code incentivizes it to produce clean, canonical, and logically sound code structures.
  • Don't Discard, Repair: The data engine's ability to salvage and fix ~60% of faulty raw instances using compiler logs proves that automated error remediation is far more effective for building diverse datasets than passive filtering.
  • Decoupling Visual and Structural Learning: Trying to optimize for code structure and visual similarity simultaneously causes training instability. The authors show that anchoring visual alignment first (Stage 1) before introducing structural consistency constraints (Stage 2) is vital for stable RL convergence.

Key Results

  • State-of-the-Art Performance: SciTikZer-8B achieved a near-perfect 97.2% compilation success rate on SciTikZ-Bench, significantly outperforming proprietary models like Gemini-2.5-Pro (88.9%) and massive open models like Qwen3-VL-235B (92.1%).
  • Robust Generalization: On the external DaTikZ-v3 benchmark, SciTikZer-8B maintained its dominance, achieving the highest compilation rate (94.46%) and the lowest distribution gap (KID: 1.14).
  • Cross-Language Generalization: When applied to Python chart generation on ChartMimic, the DSC framework successfully boosted execution rates and visual fidelity, proving its versatility beyond LaTeX.
  • Human Preference: In a blind study involving 300 examples, human annotators preferred SciTikZer-8B's outputs 59% of the time over top competing baselines, citing superior coordinate alignment and structural correctness.

Limitations and Future Work

Not explicitly discussed in the paper. However, the reliance on an active rendering and compilation loop during the reinforcement learning phase implies a high computational overhead during training.

Summary updated

BibTeX
@misc{lin2026scientific,
  author = {Juekai Lin and Yun Zhu and Honglin Lin and Sijing Li and Tianwei Lin and Zheng Liu and Xiaoyang Wang and Wenqiao Zhang and Lijun Wu},
  title = {{Scientific Graphics Program Synthesis via Dual Self-Consistency Reinforcement Learning}},
  year = {2026},
  eprint = {2604.06079},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.06079},
}
Figure