Back to Blog
AI Trend DigestEN

Unlimited-SVG: Generating Complex Vector Graphics with a Compact, Efficient Model

4 min read

Abstract illustration for: Unlimited-SVG: Generating Complex Vector Graphics with a Compact, Efficient Model

Converting a complex image into scalable vector graphics (SVG) is computationally expensive. A single detailed image can require more than 10,000 tokens to represent as structured SVG code—a regime where most large language models become slow and impractical. Baidu's Unlimited-SVG addresses this bottleneck by combining aggressive input compression with a mixture-of-experts architecture that activates only 0.5B parameters per token, making long-horizon SVG generation feasible on locally deployable hardware.

Why it matters

Vector graphics are essential for design workflows, web applications, and print production because they scale without quality loss and remain editable. However, automating the conversion from raster images to clean, structured SVG has remained difficult. Existing approaches either rely on heavy frontier APIs or produce incomplete or poorly structured output.

Unlimited-SVG makes this practical for three reasons:

  • Long-context efficiency: Generating 10,000+ tokens of SVG code no longer requires massive models or expensive API calls. The model sustains real-time performance on compact, locally deployable hardware.
  • Editability: The output is structured SVG—not a rasterized approximation—so designers can modify paths, colors, and text after generation.
  • Detail preservation: The input encoder retains fine details like small text, thin strokes, and exact spatial coordinates despite aggressive compression.

This opens possibilities for AI-powered design automation in web development, CAD workflows, diagram generation, and print design.

How it works

Unlimited-SVG solves the long-context problem from both ends of the pipeline:

Input compression

The model uses DeepSeek-OCR's encoder to compress a 2048 × 2048 image into just 1024 vision tokens. This is aggressive compression—a 4-megapixel image reduced to 1024 tokens—yet the encoder preserves fine details like small text, thin strokes, and precise spatial coordinates. By shrinking the visual prefix before decoding begins, the model avoids the token explosion that makes long-context generation slow.

Sparse decoding

Rather than activating all parameters for every token, Unlimited-SVG uses a mixture-of-experts (MoE) architecture. Only ~0.5B parameters activate per token, keeping computation minimal even as the model generates thousands of tokens of SVG code. This sparse activation is the key to sustaining real-time performance on modest GPUs.

Temperature tuning

The model supports both greedy (deterministic) and sampled decoding. The README recommends:

  • Low temperature (0–0.3) for CAD, diagrams, charts, and other images requiring exact detail consistency.
  • Higher temperature (0.5–0.8) for natural scenes and photos to avoid repetitive loops and encourage varied strokes.

How to try it

The model is available on Hugging Face at baidu/Unlimited-SVG and supports 2048 × 2048 global inference. Two inference methods are documented:

Using Transformers

Install dependencies with uv (see the README for the exact pip command), then save the provided infer_hf.py script and run:

CUDA_VISIBLE_DEVICES=0 .venv-svg-hf/bin/python infer_hf.py /path/to/image.png

This outputs output.svg and output.txt. The script handles image preprocessing (padding to 2048 × 2048, compositing transparency onto white) and extracts the SVG from the model's raw output.

Using vLLM

For higher throughput, vLLM is supported. The README includes steps to configure the vLLM image processor and start a server, then query it via OpenAI-compatible API. See the full README for the complete vLLM setup.

Key preprocessing details

Both methods use ImageOps.pad to resize the long edge to 2048 pixels while preserving aspect ratio, then center the image on a gray 2048 × 2048 canvas. Transparent pixels are composited onto white first to prevent them from turning black.

The first run downloads model weights from Hugging Face and caches them locally; subsequent runs reuse the cached files.

Who it's for (and limits)

Best suited for:

  • Designers and developers automating SVG generation from mockups or screenshots.
  • CAD and diagram workflows where exact detail preservation matters.
  • Web and print applications requiring scalable graphics.
  • Teams wanting to run inference locally without API dependencies.

Considerations:

  • The model is built on DeepSeek-OCR, so its strengths and weaknesses in OCR and visual understanding carry through.
  • Output quality depends on image type and temperature tuning; CAD and diagrams benefit from low temperature, while natural scenes may need higher temperature to avoid repetitive strokes.
  • The README recommends checking it for specific version details, dependency versions, and advanced configuration options not covered here.
  • A BF16-capable NVIDIA GPU is required for inference as documented.

The day's GitHub and Hugging Face picks side by side.

ProjectSource★Language / Type
elementalsouls/Claude-BugHunterGitHub31,620Python
HKUDS/CLI-AnythingGitHub69,386Python
jingyaogong/minimindGitHub74,252Python
openvinotoolkit/openvinoGitHub13,458C++
cathrynlavery/diagram-designGitHub77,118HTML
thinkingmachines/Inkling-2-MiniHugging Face7,142image-text-to-text
prism-ml/Ternary-Bonsai-2.5-27B-GGUFHugging Face1,134text-generation
baidu/Unlimited-SVGHugging Face741image-text-to-text
SulphurAI/Sulphur-3Hugging Face1,639—
Amazon-FMR/ErgoHugging Face516text-generation