Skip to main content

Hierarchical SVG Tokenization: Learning Compact Visual Programs for Scalable Vector Graphics Modeling

AuthorsXiming Xing et al.
Year2026
HF Upvotes18
arXiv2604.05072
PDFDownload
HF PageView on Hugging Face

Abstract

Recent large language models have shifted SVG generation from differentiable rendering optimization to autoregressive program synthesis. However, existing approaches still rely on generic byte-level tokenization inherited from natural language processing, which poorly reflects the geometric structure of vector graphics. Numerical coordinates are fragmented into discrete symbols, destroying spatial relationships and introducing severe token redundancy, often leading to coordinate hallucination and inefficient long-sequence generation. To address these challenges, we propose HiVG, a hierarchical SVG tokenization framework tailored for autoregressive vector graphics generation. HiVG decomposes raw SVG strings into structured atomic tokens and further compresses executable command--parameter groups into geometry-constrained segment tokens, substantially improving sequence efficiency while preserving syntactic validity. To further mitigate spatial mismatch, we introduce a Hierarchical Mean--Noise (HMN) initialization strategy that injects numerical ordering signals and semantic priors into new token embeddings. Combined with a curriculum training paradigm that progressively increases program complexity, HiVG enables more stable learning of executable SVG programs. Extensive experiments on both text-to-SVG and image-to-SVG tasks demonstrate improved generation fidelity, spatial consistency, and sequence efficiency compared with conventional tokenization schemes. Our code is publicly available at https://github.com/ximinng/HiVG


Engineering Breakdown

Plain English

This paper addresses a fundamental inefficiency in large language model-based SVG generation: standard byte-level tokenization from NLP destroys the geometric structure of vector graphics, causing coordinate hallucination and token bloat. The authors propose HiVG, a hierarchical tokenization framework that decomposes SVG strings into structured atomic tokens and compresses command-parameter pairs, dramatically reducing token redundancy while preserving spatial relationships. By tailoring tokenization to the domain-specific structure of vector graphics rather than treating them as generic text, HiVG enables more efficient and accurate autoregressive generation of scalable graphics, solving a critical bottleneck in LLM-based design automation.

Core Technical Contribution

HiVG's core innovation is domain-aware hierarchical tokenization for vector graphics instead of generic byte-level encoding. Rather than fragmenting coordinates like '300.45' into separate byte tokens that destroy spatial meaning, the framework recognizes and preserves command-parameter structures inherent to SVG—understanding that 'M 300 450' (move-to command) is an atomic semantic unit. This hierarchical decomposition reduces token sequences significantly while maintaining geometric interpretability, allowing downstream autoregressive models to reason about graphics structure instead of memorizing character-level patterns. The approach represents a shift from treating SVG as flat text to recognizing it as structured geometric program synthesis.

How It Works

The pipeline works in three stages: first, raw SVG strings are parsed into their command structure (moveTo, lineTo, curveTo, etc.), extracting commands and their numerical parameters as separate entities. Second, these commands and parameters are grouped hierarchically—related coordinates stay together, reducing fragmentation and enabling the model to learn spatial relationships as coherent units rather than scattered tokens. Third, the framework applies compression techniques to command-parameter pairs, eliminating redundancy that would otherwise force models to allocate precious tokens to repetitive coordinate sequences. During inference, an autoregressive LLM generates these structured tokens sequentially, and the final stage reconstructs valid SVG output by reassembling commands and parameters into executable graphics code. This approach reduces token count by orders of magnitude compared to byte-level encoding while maintaining one-to-one recoverability to valid SVG.

Production Impact

For teams building SVG generation systems (design automation, UI layout synthesis, icon generation), this directly reduces context window consumption, enabling longer sequences and batch processing on GPUs with limited memory—a massive practical win for production inference costs. If you integrate HiVG into a design tool, you'd swap the tokenizer layer without changing your base LLM; coordinate hallucinations (a common failure mode where models generate invalid or impossible coordinates) should drop substantially because the model now understands coordinates as geometric units, not random character sequences. Latency improves because fewer tokens means fewer forward passes; for a 1000-command SVG that previously required 5,000 tokens, you might need 800-1,200 tokens, reducing inference time by 60-70% depending on your hardware. The main trade-off is tokenizer complexity—you need SVG parsing infrastructure upstream, and the tokenizer itself is no longer a generic learned component but a hand-engineered domain-specific codec, increasing maintenance burden and making it harder to adapt to novel graphics formats.

Limitations and When Not to Use This

HiVG assumes well-formed SVG input and may struggle with malformed or edge-case graphics that violate the SVG specification—production systems need robust error handling for this. The framework is optimized specifically for SVG; applying it to other vector formats (PDF paths, PostScript, CAD formats) would require reengineering the tokenizer, so it's not a general solution for all vector graphics. The paper doesn't discuss how the approach scales to extremely complex, real-world SVGs with thousands of commands or nested groups and transforms—the hierarchical structure might collapse into linear sequences anyway for highly irregular graphics. Finally, there's an open question about whether structured tokenization actually helps the model learn better priors about geometry or merely reduces redundancy; the paper may not separate these effects clearly, meaning gains could evaporate if a simpler compression algorithm (lossless zipping) achieves similar token reduction.

Research Context

This work sits at the intersection of two research directions: autoregressive program synthesis for graphics (following systems like LayoutDM and recent SVG generation papers) and domain-specific tokenization (building on observations that generic BPE fails for structured domains like code and molecules). It directly addresses limitations of prior work that naively applied LLM architectures to SVG by throwing byte-level tokenizers at the problem, similar to how code generation benefited from syntax-aware tokenization. The paper opens a research direction toward domain-aware tokenization strategies for structured generation tasks more broadly—if it works for SVG, similar hierarchical tokenization might unlock better results in CAD, music, 3D geometry, or procedural content generation.


:::tip Subscribe Get weekly breakdowns of papers like this in AI Letters - the newsletter for engineers building production AI systems. :::


Back to Research Lab → · Subscribe to AI Letters →

© 2026 EngineersOfAI. All rights reserved.