A first-iteration LoRA fine-tune of Qwen/Qwen3.5-4B for text-to-SVG generation (icons, flat illustrations, line art, gradients, emoji, SMIL/CSS animation, scenes). This repo holds the merged bf16 weights; the adapter alone is in aixonlab/svg-slm-4b-lora.
Honest summary. The project goal was to beat Claude Sonnet 5.5 at SVG generation. This checkpoint does not. It was trained for about 2 GPU-hours (207 optimizer steps, roughly 3,300 examples, about 4% of the dataset) under a hard $4 compute cap. In a blind pairwise evaluation it lost every comparison. Treat it as a baseline and starting point, not a replacement for a frontier model.
eval_outputs_v2.json and the judge output in judge_v2.json of the LoRA repo.</svg>.| Result | Value |
|---|---|
| Outputs that were a complete, renderable SVG | 26 / 60 (32 hit the 6,000-token cap without closing </svg>, mostly repetition loops or over-long path data; 2 rendered blank) |
| Blind judge wins, model vs Sonnet 5.5 (valid outputs only, n=26) | 0 / 26 |
| Mean judge score on those 26 | model 1.6 / 10, Sonnet 5.5 8.4 / 10 |
| Win rate over all 60 prompts (invalid counted as a loss) | 0 % |
Per category (valid outputs only) Sonnet won every comparison: icon 7/7, shaded 6/6, animated 5/5, line art 3/3, emoji 2/2, scene 2/2, flat illustration 1/1.
Caveats: the eval set is small and was created inside the same project; animations were judged on a static frame; a single judge model was used. An earlier decode (temperature 0.6, 3,500-token cap) gave only 20/60 valid outputs.
aixonlab/svg-sft-v1, 78,620 license-filtered examples (Iconify permissive sets, SVG Repo permissive rows, Clker, OpenClipart, InternSVG SAgoge and SVG-Sophia). Only about 3.3k were seen. The dataset card lists sources, licenses and attribution (some rows are CC-BY).flash-linear-attention installed, causal-conv1d not), which held throughput to roughly 38-43 s/step.import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "aixonlab/svg-slm-4b"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.bfloat16, device_map="auto")
msgs = [{"role": "user", "content": "flat icon of a red coffee mug with steam"}]
text = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True, enable_thinking=False)
ids = tok(text, return_tensors="pt", add_special_tokens=False).to(model.device)
out = model.generate(**ids, max_new_tokens=6000, do_sample=True, temperature=0.4, top_p=0.9,
repetition_penalty=1.06, stop_strings=["</svg>"], tokenizer=tok)
print(tok.decode(out[0][ids["input_ids"].shape[1]:], skip_special_tokens=True))
Extract the first <svg ...>...</svg> from the output and validate it before use. Animated SVGs need a browser to render, since resvg and CairoSVG ignore animation.
More compute (a full epoch or more over the 78k examples, with fast linear-attention kernels), better captions than metadata-derived prompts, preference or RL training with a render-based reward, and a fix for early termination and repetition. This checkpoint demonstrates the pipeline end to end, not the end result.
Apache-2.0 for the weights (inherited from the base model). Training data carries per-row licenses (MIT, Apache-2.0, CC0, public domain, CC-BY-4.0, ISC, BSD, Unlicense). This is not legal advice; review the dataset card before commercial use.
Qwen/Qwen3.5-4B