Source-linked AI summary

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

Ximing Xing, Ziteng Xue, Zhenxi Li, Weicong Liang, Linqing Wang, Zhantao Yang, Tiankai Hang, Zijin Yin, Qinglin Lu, Chunyu Wang, Qian Yu

arXiv:2604.05072v2cs.LG

TL;DR

Autoregressive SVG generation is hindered by coordinate fragmentation and low-information sequences that weaken geometric modeling. HiVG introduces hierarchical atomic and executable segment tokens, HMN initialization, and progressive curriculum training. The framework is reported to improve fidelity, spatial consistency, validity, and efficiency across text-to-SVG and image-to-SVG tasks.

  • Problem

    Existing SVG tokenizations fragment coordinates and produce inefficient sequences, limiting geometric and structural modeling in autoregressive generation.

  • Method

    HiVG decomposes SVGs into atomic tokens, merges complete command–parameter groups into executable segment tokens, initializes embeddings with HMN, and progressively increases program complexity during training.

  • Results

    HiVG improves generation fidelity, spatial consistency, and sequence efficiency across text-to-SVG and image-to-SVG tasks while maintaining structural validity.

  • Takeaways & Limitations

    Aligning tokenization with executable geometric structure provides a foundation for more stable autoregressive SVG modeling without relying solely on increased model scale.

Abstract

from arXiv · show

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 \textit{atomic tokens} and further compresses executable command--parameter groups into geometry-constrained \textit{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

1 Introduction

HiVG addresses coordinate fragmentation and inefficient SVG sequences by replacing flat tokenization with hierarchical atomic and executable segment tokens, complemented by structured initialization and curriculum training.

  • Existing LLM-based SVG methods inherit tokenizations that split numerical coordinates into discrete symbols, weakening their geometric relationships and contributing to coordinate hallucination.
  • Raw SVG sequences are inefficient because simple shapes expand into tens or hundreds of low-information drawing-command and coordinate tokens.
  • HiVG decomposes SVG strings into atomic tokens and compresses command–parameter groups into geometry-constrained segment tokens.
  • 63.8% maximum sequence-length reduction relative to raw-string tokenization on Qwen is reported for HiVG segment tokens.
  • HMN initialization injects numeric ordering signals and semantic priors, while three-stage curriculum training progressively increases program depth for more stable optimization and generalization.

2 Related Work

Related work spans optimization-based, latent, and discrete-token SVG representations, while HiVG is presented as a task-specific compression and structural-tokenization approach.

  • Early SVG methods optimize stroke parameters through differentiable renderers, whereas other approaches learn compact continuous latent representations.
  • Recent SVG research represents graphics as sequences of discrete tokens, continuing the broader shift toward autoregressive program modeling.
  • BPE motivates task-specific compression by merging frequent character sequences into robust subword representations for language modeling.
  • HiVG extends this compression perspective to SVG through hierarchical, structure-aware token representations.

3 HiVG: Hierarchical SVG Modeling

HiVG models SVGs with executable atomic and segment tokens, learns segments through constrained merging, initializes new embeddings with HMN, and trains through progressively deeper programs.

  • Motivation: SVG’s program-like structure causes coordinate tokens to overwhelm context, making element boundaries, validity, and distant geometric relationships harder to model.
  • Atomic Tokens: Atomic SVG tokens separate structure, commands, coordinates, and attributes while preserving rendering executability.
  • Atomic Tokens: Coordinates are normalized to the canvas and uniformly quantized into discrete integer bins mapped to coordinate tokens.
  • Segment Tokens: Segments pair each command with all required coordinates, using command-specific arity to define executable geometric units.
  • Segment Tokens: Structure Segment Learning iteratively merges frequent adjacent segment pairs while restricting merges to valid segment boundaries and filtering invalid structures.
  • HMN Initialization: HMN combines mean-noise initialization with semantic descriptions and numeric coordinate encodings that capture local smoothness and global ordering.
  • Curriculum Training: Curriculum training expands program depth without discarding earlier regimes, separating embedding alignment, structural abstraction, and global composition.

4 Experiments

HiVG is evaluated on text-to-SVG and image-to-SVG generation using structured tokenization, segment learning, curriculum training, and human assessment. Results indicate improved structural consistency, geometric preservation, and performance on longer SVG programs, while learned segments remain compact and geometrically meaningful.

  • Experimental Setup: The experiments evaluate HiVG on both Text-to-SVG and Image-to-SVG tasks using structural validity, semantic alignment, visual fidelity, and diversity-related measures.The evaluation also includes perceptual metrics such as HPSv2, ImageReward, PickScore, and Aesthetic score.
  • Quantitative Results: HiVG achieves competitive or superior performance across multiple metrics on both Image-to-SVG and Text-to-SVG tasks.Image-to-SVG shows strong CLIP-S and aesthetic scores, while Text-to-SVG shows higher PickScore and competitive CLIP and HPS scores.
  • Qualitative Results: HiVG produces more structurally consistent Text-to-SVG programs and better preserves global structure and visual details in Image-to-SVG reconstruction than competing methods.The comparisons describe fewer incomplete shapes, incorrect layouts, text mismatches, geometric distortions, and color inconsistencies.
  • Human Evaluation: Human evaluation measures pairwise visual preference and SVG code usability because automatic raster-domain metrics do not fully capture human preference or practical code usability.The study samples 60 image-to-SVG cases and uses eight professional SVG practitioners as evaluators.
  • Ablation Study: Curriculum training improves performance on longer sequences L2/L3 without sacrificing accuracy on simpler cases L1.The authors associate progressive exposure to structural complexity with more stable optimization and better generalization to high-token-length SVG programs.
  • Structural Noise & Segment Analysis: Learned segments contain meaningful geometric primitives, while their atomic token length remains stable at a median of approximately 9 tokens across frequency tiers.High-frequency segments prominently represent arcs and smooth curves, and redundant path fragments are filtered during segment learning.

5 Conclusion

HiVG aligns SVG tokenization with executable geometric structure, reducing sequence length while preserving structural validity and supporting more stable autoregressive modeling. The conclusion argues that representation design is central to reliable SVG generation and may extend to other structured graphical formats.

  • HiVG redefines the representation unit from character-level fragments to executable geometric segments.This hierarchical tokenization aligns token structure with vector-graphics semantics.
  • The hierarchical design reduces sequence length while preserving structural validity, enabling more stable autoregressive modeling.
  • Structured initialization and scalable training complement hierarchical tokenization in the framework.
  • The results suggest that representation design plays a crucial role in reliable SVG generation, rather than geometric consistency relying solely on increased model scale.
  • Future work may extend the framework to other structured graphical formats and integrate it with differentiable rendering objectives.

A Dataset Construction, Filtering & Preprocessing

The training corpus merges three open-source SVG datasets into a deduplicated collection, then applies cleaning, coordinate transformation, and quantization before tokenization. These steps target rendering consistency, stable parsing, and compatibility with downstream decoding.

  • The merged corpus contains 2,445,092 unique SVG samples from SVG-Stack, SVGX-Dataset, and MMSVG-Icon.The source datasets contribute 2,283,875, 257,086, and 1,159,423 samples, respectively, before merging and deduplication.
  • The preprocessing pipeline removes unsupported elements, bakes transformations into coordinates, normalizes the viewBox, and quantizes coordinates.
  • Coordinates are normalized to a 784 × 784 canvas, rounded to integers, and converted from absolute to relative coordinates.
  • Transform baking follows <use> expansion, quantization follows global scaling, and boundary correction is deferred to the final stage.

A.1 SVG Code Usability Review

The usability review evaluates generated SVG structure in Adobe Illustrator through expert scoring and finds consistent advantages for HiVG-3B. It complements raster-domain and pairwise assessments with practical editability evidence.

  • Eight professional SVG practitioners import generated SVGs into Adobe Illustrator and score structural usability on a 1–5 Likert scale.
  • The review measures semantic layering, editability, redundancy control, and overall code usability across five representative methods.
  • HiVG-3B achieves the best scores on all four usability dimensions, with clearest gains in semantic layering and editability.
  • The Illustrator review evaluates structural usability beyond automatic raster metrics and assesses compatibility with human editing workflows.

B.1 More Text-to-SVG and Image-to-SVG Results

Additional examples cover diverse text-to-SVG and image-to-SVG cases, illustrating HiVG’s behavior across semantic granularity, composition, layout, and geometric complexity. The image-to-SVG examples pair raster inputs with generated SVG renderings.

  • Additional examples cover flat icons, stylized symbols, logos, and multipart graphic compositions.
  • For image-to-SVG examples, each case shows the raster input image alongside the generated SVG rendering.
  • The results illustrate HiVG under varying semantic granularity, object composition, and layout structure in open-ended textual descriptions.
  • The expanded examples provide a broader view of reconstruction behavior across different levels of geometric complexity.

B.2 Comparison with Existing Methods

Additional comparisons show HiVG generating complex SVGs, including typography and letters, while retaining efficiency with a lightweight 3B-parameter model.

  • HiVG shows strong text-to-SVG and image-to-SVG performance in additional comparisons.The supplied passage reports results in Figures S3 and S4.
  • HiVG demonstrates proficiency in generating SVGs containing typographical elements and letters.The authors connect this performance to precise geometric generation and complex topology preservation.
  • The reported typography quality is achieved with a lightweight 3B-parameter model.

C Extended Implementation Details

The implementation uses HMN initialization for structured SVG tokens, numeric feature projection, and unified conversational templates across text- and image-conditioned generation.

  • HMN initialization incorporates newly introduced structured SVG tokens into the pretrained language-model vocabulary.The method is presented as stabilizing their integration during training.
  • Numeric token features use 16 Gaussian radial basis functions, polynomial features, and a fixed random projection.The normalized scalar values are projected to the model embedding dimension.
  • The numeric projection design improves local continuity among coordinate tokens and stabilizes early structured-geometry optimization.
  • Unified instruction-style templates support both text-to-SVG and image-to-SVG token generation.Image-to-SVG prompts insert an image placeholder, while both tasks use the same conversational format.
  • Evaluation uses fixed prompt templates and unified rendering and post-processing rules to reduce prompt-induced variance.

D Additional Analysis of Structured Tokens

Raw SVGs contain visually negligible structural noise that inflates sequences and disrupts reusable geometric segmentation; HiVG addresses this through motif-aware cleaning and executable-unit tokenization.

  • Real-world SVGs contain redundant commands, near-degenerate fragments, and geometric fragmentation from authoring and conversion pipelines.These artifacts may disappear during rasterization while remaining costly for token-based modeling.
  • Although visually unnoticeable after rasterization, structural noise severely increases token-sequence length and disrupts consistent segment extraction.
  • The cleaning pipeline isolates recurring motifs such as zero-move command groups and redundant transitions that add no geometric value.
  • HiVG processes meaningful executable geometric units rather than applying naive text-level compression to unstable path fragments.
Loading 2604.05072v2…