Instructions to use render-attribution/RA-GRPO-HTML-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use render-attribution/RA-GRPO-HTML-4B with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("render-attribution/Qwen3-VL-4B-SFT-HTML") model = PeftModel.from_pretrained(base_model, "render-attribution/RA-GRPO-HTML-4B") - Notebooks
- Google Colab
- Kaggle
Initial release
Browse files- README.md +59 -0
- adapter_config.json +45 -0
- adapter_model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: render-attribution/Qwen3-VL-4B-SFT-HTML
|
| 4 |
+
library_name: peft
|
| 5 |
+
pipeline_tag: image-text-to-text
|
| 6 |
+
tags:
|
| 7 |
+
- lora
|
| 8 |
+
- image-to-code
|
| 9 |
+
- html
|
| 10 |
+
- reinforcement-learning
|
| 11 |
+
- ra-grpo
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# RA-GRPO-HTML-4B
|
| 15 |
+
|
| 16 |
+
LoRA adapter for [Qwen3-VL-4B-SFT](https://huggingface.co/render-attribution/Qwen3-VL-4B-SFT-HTML) that turns an image into HTML code. It is
|
| 17 |
+
the HTML model of RA-GRPO (Table 4 of the paper), trained for 300 steps with render-attributed
|
| 18 |
+
credit: each rendered element is traced back to the code that drew it, matched to the reference element it should
|
| 19 |
+
reproduce, scored, and its score is sent to the responsible tokens as the GRPO advantage.
|
| 20 |
+
|
| 21 |
+
[Paper](https://arxiv.org/abs/TBD.00000) | [Code](https://github.com/render-attribution/render-attribution) | [Project page](https://render-attribution.github.io)
|
| 22 |
+
|
| 23 |
+
## Result
|
| 24 |
+
|
| 25 |
+
On Design2Code, the Block / Text / Position / Color scores (x100) go from 69.0 / 74.2 / 64.8 / 65.7 with GRPO to 77.4 / 82.9 / 72.9 / 73.2 with RA-GRPO. Full tables are in the paper.
|
| 26 |
+
|
| 27 |
+
## Usage
|
| 28 |
+
|
| 29 |
+
The adapter is applied unmerged on top of the base model, as in every evaluation of the paper (rank 32 on the
|
| 30 |
+
language model). With vLLM:
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
from huggingface_hub import snapshot_download
|
| 34 |
+
from vllm import LLM, SamplingParams
|
| 35 |
+
from vllm.lora.request import LoRARequest
|
| 36 |
+
|
| 37 |
+
llm = LLM("render-attribution/Qwen3-VL-4B-SFT-HTML", enable_lora=True, max_lora_rank=32, max_model_len=16384, enforce_eager=True)
|
| 38 |
+
lora = LoRARequest("ragrpo", 1, snapshot_download("render-attribution/RA-GRPO-HTML-4B"))
|
| 39 |
+
prompt = 'Generate the complete HTML document (with inline CSS) that reproduces this webpage screenshot. The page is 1280 pixels wide.'
|
| 40 |
+
messages = [{"role": "user", "content": [
|
| 41 |
+
{"type": "image_url", "image_url": {"url": "file:///path/to/image.png"}},
|
| 42 |
+
{"type": "text", "text": prompt}]}]
|
| 43 |
+
params = SamplingParams(temperature=0, max_tokens=8192, repetition_penalty=1.0)
|
| 44 |
+
print(llm.chat(messages, params, lora_request=lora)[0].outputs[0].text)
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
`eval/decode.py` in the code repository
|
| 48 |
+
reproduces the paper's decoding exactly, and `train/configs/html.yaml ragrpo` reproduces the training run.
|
| 49 |
+
|
| 50 |
+
## Citation
|
| 51 |
+
|
| 52 |
+
```bibtex
|
| 53 |
+
@article{wang2026whodrew,
|
| 54 |
+
title = {Who Drew That Pixel? Fine-Grained Visual Attribution for Image-to-Code Generation and Editing},
|
| 55 |
+
author = {Hexuan Wang and Zixian Ma and Ranjay Krishna and Jaemin Cho},
|
| 56 |
+
journal = {arXiv preprint arXiv:TBD.00000},
|
| 57 |
+
year = {2026}
|
| 58 |
+
}
|
| 59 |
+
```
|
adapter_config.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alpha_pattern": {},
|
| 3 |
+
"auto_mapping": {
|
| 4 |
+
"base_model_class": "Qwen3VLForConditionalGeneration",
|
| 5 |
+
"parent_library": "transformers.models.qwen3_vl.modeling_qwen3_vl"
|
| 6 |
+
},
|
| 7 |
+
"base_model_name_or_path": "render-attribution/Qwen3-VL-4B-SFT-HTML",
|
| 8 |
+
"bias": "none",
|
| 9 |
+
"corda_config": null,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 64,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.0,
|
| 22 |
+
"megatron_config": null,
|
| 23 |
+
"megatron_core": "megatron.core",
|
| 24 |
+
"modules_to_save": null,
|
| 25 |
+
"peft_type": "LORA",
|
| 26 |
+
"qalora_group_size": 16,
|
| 27 |
+
"r": 32,
|
| 28 |
+
"rank_pattern": {},
|
| 29 |
+
"revision": null,
|
| 30 |
+
"target_modules": [
|
| 31 |
+
"o_proj",
|
| 32 |
+
"gate_proj",
|
| 33 |
+
"k_proj",
|
| 34 |
+
"v_proj",
|
| 35 |
+
"up_proj",
|
| 36 |
+
"q_proj",
|
| 37 |
+
"down_proj"
|
| 38 |
+
],
|
| 39 |
+
"target_parameters": null,
|
| 40 |
+
"task_type": null,
|
| 41 |
+
"trainable_token_indices": null,
|
| 42 |
+
"use_dora": false,
|
| 43 |
+
"use_qalora": false,
|
| 44 |
+
"use_rslora": false
|
| 45 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a114662e077b1c70ccfe9ea8e840ca01c8b8da541b2f826f613bbe97cdd8990e
|
| 3 |
+
size 264316456
|