TL;DR
Large language models can write SVG vector code from text, yet asking them to trace a specific sketch is like asking an artist to draw blindfolded—they quickly lose track of the canvas. ControlSVG solves this by teaching autoregressive models to "look" at their intermediate drawings as they go, while softening how they get penalized for tiny pixel-level coordinate mistakes. The result is crisp, clean, controllable vector graphics generated natively from sketches, edges, and text prompts.
What Problem Does This Paper Address?
Scalable Vector Graphics (SVGs) are essentially recipes of geometric math—lines, curves, and hex colors—that scale infinitely without turning into blurry pixels. Recently, researchers realized that because SVGs are just XML text, autoregressive (AR) models can generate them token by token.
However, text alone is terrible at specifying exact layouts. Designers usually want to guide generation with a sketch, scribble, or edge map. In pixel-based diffusion models, tools like ControlNet handle this effortlessly. Yet adapting spatial control to 1D token sequences runs into two brick walls:
- Blind Generation ("Semantic Drift"): If you simply paste a sketch at the beginning of a prompt, the model has to mentally simulate how its abstract math commands render onto a 2D canvas. Over hundreds of tokens, that mental map degrades, and paths drift off course.
- Harsh Token Penalties: Standard Cross-Entropy loss treats discretized coordinates like completely unrelated vocabulary words. Predicting coordinate
(100, 50)instead of(100, 51)gets punished just as severely as predicting(0, 0), making spatial learning jittery and brittle.
Methods
Built upon the Qwen2.5-VL vision-language backbone and OmniSVG's tokenizer (which maps a $200 \times 200$ grid and hex colors into discrete tokens), ControlSVG introduces two clever mechanisms:
- Dynamic Visual Feedback (DVF): Instead of generating code in one blind, uninterrupted stream, ControlSVG establishes a "See-and-Draw" loop. After generating a path (or group of paths), an on-the-fly rasterizer renders the current canvas into an image, encodes it via a frozen vision encoder, and injects those visual tokens right back into the sequence. Crucially, only the latest visual snapshot is kept in the active context; older snapshots are dropped.
- Neighborhood Cluster Cross-Entropy (NCCE): To give the model spatial common sense, the authors replace strict single-token supervision with a hybrid loss. Alongside standard Cross-Entropy, NCCE defines a valid spatial neighborhood around the ground-truth coordinate (and within an RGB distance of 32 for color tokens) and sums the predicted probabilities inside that window. Near-misses are treated as geographically valid rather than catastrophic failures.
Datasets
- MMSVGBench: Derived from OmniSVG's Image-to-SVG tasks, split into Icon and Illustration categories. The authors pair each sample with descriptive captions generated by BLIP-2 and Canny edge maps for spatial conditioning.
- TU-Berlin: A dataset of real, human-drawn sketches used to test out-of-domain robustness.
Key Insights and Ideas
- Dropping old snapshots saves memory and geometry: In the DVF loop, discarding historical canvas renders doesn't just prevent a memory explosion—it preserves RoPE (Rotary Positional Embedding) continuity. Leaving old image tokens wedged between SVG path tokens creates artificial positional gaps that confuse the Transformer's sense of path-to-path continuity.
- Clustered tolerances beat Gaussian smoothing: Before settling on NCCE, the authors tried smoothing ground-truth coordinates with a 2D Gaussian (Gaussian Soft-Targets). Surprisingly, minimizing KL divergence against a smooth distribution diluted the gradients—an "optimization softening" effect where the model struggled to make confident, sharp predictions. Grouping logits via NCCE kept gradients sharp while still forgiving 1-pixel nudges.
- Colors have neighborhoods, too: Applying NCCE exclusively to $(x, y)$ coordinates left the model vulnerable to "color collapse"—reverting to pure black, white, or jarring hues when unsure. Treating similar RGB hex tokens as spatial neighbors fixed color harmony.
Key Results
ControlSVG was benchmarked against Condition-to-Image + Vectorization pipelines (e.g., Flux-Kontext + LIVSS), Text-to-SVG models, and frontier multimodal LLMs (GPT-5-Thinking, Gemini3-Pro, Qwen3-VL-Max):
- Spatial Precision: On MMSVG-Icon, ControlSVG achieved the lowest Distance Transform error (9.445 vs. 12.502 for Flux-Kontext+LIVSS and 12.946 for Gemini3-Pro) and the highest structural similarity (0.859 SSIM).
- Visual Quality: On complex Illustrations, it achieved the best Fréchet Inception Distance (93.7 FID, beating Gemini3-Pro's 105.9 and fine-tuned OmniSVG's 109.7) while avoiding the jagged path artifacts typical of raster-to-vector conversion.
- Human Preference: In a blind pairwise study with 13 CV/CG professionals, ControlSVG won outright against Flux-Kontext+LIVSS (48.6% win vs. 27.3% loss), GPT-5-Thinking (62.1% vs. 21.7%), and Gemini3-Pro (51.4% vs. 32.9%).
Limitations and Future Work
- Inference Overhead: Rasterizing intermediate SVG paths and encoding them mid-generation lengthens the context window and adds computational overhead (though keeping only the most recent snapshot constrains the cost).
- Preliminary Generalization: Most rigorous benchmarking focuses on Canny-edge control. While the authors show promising exploratory results on human scribbles, sparse scribble-to-SVG, and full image-to-SVG tasks, they note these broader modalities remain preliminary and warrant deeper investigation.
Summary updated