File size: 2,473 Bytes
6191165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e54f26
 
6191165
6e54f26
6191165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e54f26
6191165
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
license: cc-by-4.0
base_model: XunmeiLiu/VFIG-4B
library_name: peft
pipeline_tag: image-text-to-text
tags:
- lora
- image-to-code
- svg
- reinforcement-learning
- ra-grpo
---

# RA-GRPO-SVG-Code-4B

LoRA adapter for [VFIG-4B](https://huggingface.co/XunmeiLiu/VFIG-4B) that turns an image into SVG code. It is
the SVG model of RA-GRPO (Table 6 of the paper), trained for 150 steps with render-attributed
credit: each rendered element is traced back to the code that drew it, matched to the reference element it should
reproduce, and scored. The tokens that drew it get this score, standardized over the 8 samples, mixed half and half
with the GRPO advantage.

[Paper](https://arxiv.org/abs/2612.00307) | [Code](https://github.com/render-attribution/render-attribution) | [Project page](https://render-attribution.github.io)

## Result

Trained with the code-aware reward and structure credit. It keeps 53% of the reference groups (GRPO with the same reward: 40%) and its programs need the fewest code changes for the edits of the paper. Full tables are in the paper.

## Usage

The adapter is applied unmerged on top of the base model, as in every evaluation of the paper (rank 32 on the
language model). With vLLM:

```python
from huggingface_hub import snapshot_download
from vllm import LLM, SamplingParams
from vllm.lora.request import LoRARequest

llm = LLM("XunmeiLiu/VFIG-4B", enable_lora=True, max_lora_rank=32, max_model_len=16384, enforce_eager=True)
lora = LoRARequest("ragrpo", 1, snapshot_download("render-attribution/RA-GRPO-SVG-Code-4B"))
prompt = 'Generate the SVG code for this image. The image is WxH pixels; use viewBox="0 0 W H".'
messages = [{"role": "user", "content": [
    {"type": "image_url", "image_url": {"url": "file:///path/to/image.png"}},
    {"type": "text", "text": prompt}]}]
params = SamplingParams(temperature=0, max_tokens=6144, repetition_penalty=1.0)
print(llm.chat(messages, params, lora_request=lora)[0].outputs[0].text)
```

`W` and `H` are the size of the input image. `eval/decode.py` in the code repository
reproduces the paper's decoding exactly, and `train/configs/svg_code.yaml ragrpo` reproduces the training run.

## Citation

```bibtex
@article{wang2026whodrew,
  title   = {Who Drew That Pixel? Fine-Grained Visual Attribution for Image-to-Code Generation and Editing},
  author  = {Hexuan Wang and Zixian Ma and Ranjay Krishna and Jaemin Cho},
  journal = {arXiv preprint arXiv:2612.00307},
  year    = {2026}
}
```