From Tokens to Numbers: Continuous Number Modeling for SVG Generation
Michael Ogezi, Martin Bell, Freda Shi, Ethan Smith
TL;DR
This work tackles the inefficiency of tokenizing continuous SVG coordinates by introducing Continuous Number Modeling (CNM), which treats numerical attributes as first-class continuous values embedded via Fourier features. The model learns two parallel tasks—structural token prediction and numerical attribute regression—via a joint objective and uses a Number Encoder/Decoder to bridge between discrete SVG syntax and continuous geometry. After supervised fine-tuning, CNM is refined with reinforcement learning using a composite perceptual reward, yielding improvements in SSIM, DINOv2 similarity, and LPIPS' while significantly reducing sequence length and training time. On SVG-Stack, CNM achieves higher perceptual fidelity with a 32% training speedup and introduces SVGFloat as an efficient binary-friendly storage format, demonstrating practical benefits for scalable, high-quality vector generation.
Abstract
For certain image generation tasks, vector graphics such as Scalable Vector Graphics (SVGs) offer clear benefits such as increased flexibility, size efficiency, and editing ease, but remain less explored than raster-based approaches. A core challenge is that the numerical, geometric parameters, which make up a large proportion of SVGs, are inefficiently encoded as long sequences of tokens. This slows training, reduces accuracy, and hurts generalization. To address these problems, we propose Continuous Number Modeling (CNM), an approach that directly models numbers as first-class, continuous values rather than discrete tokens. This formulation restores the mathematical elegance of the representation by aligning the model's inputs with the data's continuous nature, removing discretization artifacts introduced by token-based encoding. We then train a multimodal transformer on 2 million raster-to-SVG samples, followed by fine-tuning via reinforcement learning using perceptual feedback to further improve visual quality. Our approach improves training speed by over 30% while maintaining higher perceptual fidelity compared to alternative approaches. This work establishes CNM as a practical and efficient approach for high-quality vector generation, with potential for broader applications. We make our code available http://github.com/mikeogezi/CNM.
