Rendering-Aware Reinforcement Learning for Vector Graphics Generation

Juan A. Rodriguez, Haotian Zhang, Abhay Puri, Rishav Pramanik, Aarash Feizi, Pascal Wichmann, Arnab Kumar Mondal, Mohammad Reza Samsami, Rabiul Awal, Perouz Taslakian, Spandana Gella, Sai Rajeswar, David Vazquez, Christopher Pal, Marco Pedersoli

Introduction

Vision-Language Models (VLMs) have demonstrated remarkable capabilities in writing code to generate Scalable Vector Graphics (SVGs). However, they typically perform this task "blind"—meaning they never actually observe the visual output of their generated code during training.

This paper introduces Reinforcement Learning from Rendering Feedback (RLRF), a novel method that uses reinforcement learning to reward VLMs based on the actual rendered images of their generated SVG code. This rendering-aware approach drastically improves visual fidelity, semantic alignment, and code efficiency, allowing smaller open-source models to outperform massive proprietary models like GPT-4o and Claude 3.7.

The "Blind" Generation Problem

The core challenge addressed in this paper is the "inverse rendering code generation" problem: translating an image or text prompt into executable SVG code.

Recently, autoregressive VLMs have tackled this by treating SVG generation as a standard code synthesis problem, trained via Supervised Fine-Tuning (SFT) using next-token prediction. The fatal flaw in this approach is the lack of visual feedback. Because autoregressive VLMs generate SVGs one discrete token at a time, you cannot backpropagate gradients through these discrete sampling steps using a standard differentiable renderer. Without this visual grounding, models often hallucinate, write bloated and inefficient code, or fail to generalize to complex images, relying purely on syntactic memorization.

Methodology: Reinforcement Learning from Rendering Feedback

To bypass the non-differentiable nature of token-by-token rendering, the authors frame the renderer as an environment and utilize Reinforcement Learning (RL).

The RLRF pipeline illustrating autoregressive SVG generation, rendering feedback, and reward computation.

The training process is split into two main stages:

  1. Supervised Fine-Tuning (SVG-SFT): The VLM is first trained on image-to-SVG pairs using standard teacher forcing to learn basic SVG syntax and structure.
  2. Reinforcement Learning from Rendering Feedback (RLRF): The model generates multiple SVG "rollouts" for a given input. These SVGs are rendered into pixels using a standard engine (CairoSVG).

The rendered images are evaluated automatically to compute a scalar reward, which updates the policy using Group Relative Policy Optimization (GRPO). The composite reward function combines:

  • Image Reconstruction: Pixel-level L2 distance and Canny edge detection.
  • Semantic Similarity: DreamSim (for perceptual alignment), CLIP, or a VLM-as-a-judge (for text-to-SVG tasks).
  • Code Efficiency: A penalty for overly long token sequences to encourage compact, human-readable code.

Notable tweak: The authors completely removed the KL divergence penalty typically used in GRPO. They found that the strict syntax of SVGs and the strong reward signals naturally constrained the model's distribution, making the computationally expensive KL penalty unnecessary and actually improving exploration.

Key Insights

  • RL Bridges the Non-Differentiable Gap: A complex differentiable renderer is unnecessary if a standard renderer is treated as an RL environment. The scalar reward is sufficient to teach the model visual-spatial reasoning.
  • Zero-Shot Visual Generalization: By rewarding the rendered output rather than just matching tokens, the model learns underlying structural concepts (like using gradients for shadows). This allows it to generalize to entirely unseen domains, such as emojis or fonts, without needing domain-specific training data.
  • Preventing "Reward Hacking": The models constantly tried to cheat the reward system—for example, generating 1x1 pixel viewboxes to artificially boost pixel similarity scores, or shrinking SVGs to nothing to game the length penalty. The authors had to carefully balance and schedule the rewards to prevent these exploits.
  • Text-to-SVG Without SVG Targets: For the Text2SVG task, the model was trained using only text captions from natural images. By using a larger VLM as a "judge" to reward the rendered output, the model learned to generate highly accurate SVGs from text without ever seeing a ground-truth SVG during the RL phase.

Key Results

Applying RLRF yields massive leaps in visual fidelity and structural accuracy.

Qualitative comparison of RLRF against baseline models for both Image-to-SVG and Text-to-SVG tasks.
  • Massive Fidelity Leaps: On the Image-to-SVG task, applying RLRF to a Qwen2.5VL-7B model dropped the Mean Squared Error (MSE) from 8.60 (SFT baseline) to 1.03, and boosted SSIM from 79.40 to 95.10.
  • David vs. Goliath: The fine-tuned 7B model significantly outperformed massive frontier models, including GPT-4o, Claude 3.7 Sonnet, and Llama4-400B, across all perceptual metrics.
  • Code Efficiency: Traditional image processing tools achieve good pixel scores but generate massive, unreadable paths (often 10k+ tokens). RLRF models produce highly compact, semantically structured code, actually reducing the average token length compared to the SFT baseline.

Limitations and Future Work

While RLRF represents a significant step forward, several limitations remain:

  • Context Length Limits: The models were capped at 32k tokens due to GPU memory constraints. Hyper-complex SVGs require even longer context windows.
  • Giving Up on Complexity: On extremely difficult inputs, the model sometimes diverges and falls into infinite loops, repeating SVG commands until it hits the token limit.
  • Compute Bottleneck: GRPO training is heavily bottlenecked by rollout generation. Waiting for the model to autoregressively generate 64 long SVG sequences per prompt leads to significant GPU idle time during training.
  • Catastrophic Forgetting: Specializing the model so heavily for SVG generation may degrade its general instruction-following capabilities, an area left for future alignment research.

Summary updated

BibTeX
@inproceedings{rodriguez2025rendering,
  author = {Juan A. Rodriguez and Haotian Zhang and Abhay Puri and Rishav Pramanik and Aarash Feizi and Pascal Wichmann and Arnab Kumar Mondal and Mohammad Reza Samsami and Rabiul Awal and Perouz Taslakian and Spandana Gella and Sai Rajeswar and David Vazquez and Christopher Pal and Marco Pedersoli},
  title = {{Rendering-Aware Reinforcement Learning for Vector Graphics Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=2Twzlf6qFv},
}
Figure