Image-Text-to-Text
Transformers
Safetensors
English
qwen2_5_vl
chart-to-code
multimodal
vision-language
reinforcement-learning
self-correction
matplotlib
conversational
text-generation-inference
Instructions to use cwbc/MM-ReCoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cwbc/MM-ReCoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="cwbc/MM-ReCoder") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("cwbc/MM-ReCoder") model = AutoModelForMultimodalLM.from_pretrained("cwbc/MM-ReCoder") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use cwbc/MM-ReCoder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cwbc/MM-ReCoder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cwbc/MM-ReCoder", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/cwbc/MM-ReCoder
- SGLang
How to use cwbc/MM-ReCoder with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "cwbc/MM-ReCoder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cwbc/MM-ReCoder", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "cwbc/MM-ReCoder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cwbc/MM-ReCoder", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use cwbc/MM-ReCoder with Docker Model Runner:
docker model run hf.co/cwbc/MM-ReCoder
File size: 4,357 Bytes
b61437b 06c64d3 b61437b 06c64d3 | 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | ---
license: cc-by-nc-4.0
language:
- en
base_model:
- Qwen/Qwen2.5-VL-7B-Instruct
pipeline_tag: image-text-to-text
library_name: transformers
tags:
- chart-to-code
- multimodal
- vision-language
- reinforcement-learning
- self-correction
- matplotlib
---
# MM-ReCoder
<p align="center">
<a href="https://cvpr.thecvf.com/Conferences/2026"><b>CVPR 2026</b></a>
|
<a href="https://zitiantang.github.io/MM-ReCoder/">Project Page</a>
|
<a href="https://arxiv.org/abs/2604.01600">arXiv</a>
|
<a href="https://github.com/ZitianTang/MM-ReCoder">Code</a>
|
<a href="https://huggingface.co/cwbc/MM-ReCoder-SFT-Cold-Start">SFT Cold-Start</a>
</p>
**MM-ReCoder** is the 7B vision-language model from the CVPR 2026 paper
[*MM-ReCoder: Advancing Chart-to-Code Generation with Reinforcement Learning and Self-Correction*](https://arxiv.org/abs/2604.01600).
It converts a chart image into the matplotlib code that reproduces it. At
inference time the model renders its own code with a sandboxed matplotlib
tool, inspects the result, and self-corrects across multiple turns.
This is the **final** RL-trained checkpoint. It is fine-tuned from
[`Qwen/Qwen2.5-VL-7B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct)
via:
1. **SFT cold-start** — released separately as
[`cwbc/MM-ReCoder-SFT-Cold-Start`](https://huggingface.co/cwbc/MM-ReCoder-SFT-Cold-Start).
2. **Multi-turn RL (GRPO), stage 1** — shared-first-turn optimization.
3. **Multi-turn RL (GRPO), stage 2** — full-trajectory optimization,
resumed from stage 1.
## Usage
The recommended way to use MM-ReCoder is through the inference scripts in
the [official repository](https://github.com/ZitianTang/MM-ReCoder), which
wrap the model with the self-correction agent loop (render → critique →
revise):
```bash
git clone https://github.com/ZitianTang/MM-ReCoder.git
cd MM-ReCoder
# Follow the Installation section in the repo README.
# Downalod the MM-ReCoder checkpoint from Hugging Face
hf download cwbc/MM-ReCoder
# Two-turn self-correction on ChartMimic.
bash examples/mmrecoder/inference/chartmimic_2turns.sh
```
### Direct single-turn use (no self-correction)
You can also load the model in a single-pass setting via `transformers`:
```python
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
from PIL import Image
import torch
model_id = "cwbc/MM-ReCoder"
processor = AutoProcessor.from_pretrained(model_id)
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
model_id, torch_dtype=torch.bfloat16, device_map="auto"
)
image = Image.open("path/to/chart.png").convert("RGB")
messages = [{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "Generate the matplotlib code that reproduces this chart."},
],
}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=4096, do_sample=False)
print(processor.batch_decode(out[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0])
```
This emits code in one shot. The full self-correction behavior requires the
agent loop in the repository.
## Training
- **Base model:** Qwen2.5-VL-7B-Instruct.
- **RL algorithm:** GRPO with chart-specific rule-based rewards (format,
color, text, layout, type) plus an LLM-as-a-judge model reward.
- **RL data:** [Chart2Code-160k](https://huggingface.co/datasets/xxxllz/Chart2Code-160k)
prompts.
- **Evaluation:**
[ChartMimic](https://github.com/ChartMimic/ChartMimic) (direct-600),
[Plot2Code](https://github.com/TencentARC/Plot2Code), and
[ChartX](https://github.com/InternScience/ChartVLM).
See the [repository](https://github.com/ZitianTang/MM-ReCoder) for full
training scripts and configs.
## Citation
```bibtex
@inproceedings{tang2026mmrecoder,
title={MM-ReCoder: Advancing Chart-to-Code Generation with Reinforcement Learning and Self-Correction},
author={Zitian Tang and Xu Zhang and Jianbo Yuan and Yang Zou and Varad Gunjal and Songyao Jiang and Davide Modolo},
booktitle={CVPR},
year={2026}
}
```
## License
Released under the Apache 2.0 License, inheriting from the base
Qwen2.5-VL-7B-Instruct license. |