Meituan's MSRL Beats GPT-4o at Turning Charts Into Runnable Code
A new training recipe pushes a 7B open model past GPT-4o on chart-to-code generation by pairing a 3M-pair arXiv corpus with two-stage reinforcement learning.
ProTakeaways
- MSRL, a 7B Qwen2.5-VL fine-tune, beats GPT-4o on ChartMimic and ReachQA chart-to-code benchmarks.
- Authors show SFT plateaus after 2M samples, with 2.8M yielding no further gain over 2M.
- Two-stage GRPO training uses rule-based textual rewards then a Qwen2.5-VL-72B visual judge.
- Training corpus of 3M chart-code pairs curated from real arXiv tables via Gemini-2.5-Flash.
- Code and checkpoints available at DocTron-hub/MSRL on GitHub and Hugging Face.
- Generalizes to unseen Seaborn and Plotly libraries, though fidelity drops outside matplotlib training.
Turning a chart image back into the code that produced it sounds like a party trick, but it is one of the hardest structured-output problems in multimodal ML. The model has to read tiny numeric labels, infer layouts, guess libraries, and emit executable Python that renders a pixel-close replica. A team from Meituan has now shown that the standard recipe for this task, pouring more supervised data into a vision-language model, hits a hard ceiling, and that a carefully designed reinforcement learning stage can smash through it.
Their method, called Multimodal Structured Reinforcement Learning (MSRL), takes a 7B Qwen2.5-VL model past GPT-4o on the ChartMimic and ReachQA benchmarks. The paper has been accepted to ICLR 2026, and the models and training code are open source.
The SFT ceiling nobody was measuring
Previous chart-to-code work either fine-tuned on synthetic data or bolted on RL without checking whether SFT had actually saturated. The authors set out to find that ceiling first. They built the largest training corpus for this task to date by scraping real tables from arXiv papers and prompting Gemini-2.5-Flash to generate matching matplotlib code, then filtering out anything non-executable. The resulting Chart2Code dataset contains 3 million chart-code pairs covering 24 distinct chart types.
They then fine-tuned Qwen2.5-VL-7B on six slices of that data: 200k, 400k, 800k, 1.6M, 2M, and 2.8M samples. The curve is instructive. Performance climbs sharply up to 400k, slows through 1.6M, and then flat-lines. Going from 2M to 2.8M samples produced essentially no gain. The reason, they argue, is baked into the SFT objective itself: it treats every token in the target sequence with equal weight, so the model wastes capacity memorizing boilerplate like plt.plot while under-weighting the rare tokens that actually encode data values, colors, and layout parameters.

A reward that reads code and looks at pictures
MSRL replaces SFT's uniform token loss with a structured reward that scores what actually matters in a chart. It has two branches:
- Textual reward. The generated code is normalized into a canonical form and then scored by rule on five axes. Data values use soft matching with a plus or minus 5% tolerance, chart types use exact string matching, layout uses hard value matching, and titles and labels are scored by edit distance. A separate binary reward checks whether the code actually executes.
- Visual reward. The generated code is rendered to a PNG, and Qwen2.5-VL-72B acts as a judge, scoring the image against the ground truth on six dimensions: chart type, layout, text content, data, style, and clarity. Code that fails to render gets zero.
Running the 72B judge on every rollout is expensive, so the training is split into two curriculum stages. Stage one uses only the cheap textual reward on 22k samples. Stage two adds the visual reward on 11k samples with a hybrid weighting. Optimization uses GRPO, the group-relative policy gradient popularized by DeepSeek-R1, which fits well because the rule-based rewards produce clean group-wise rankings.
How the numbers move
On ChartMimic, MSRL scores 96.5 execution rate, 78.6 low-level, and 83.8 high-level, compared to GPT-4o at 93.2, 79.0, and 83.5. On ReachQA the gap is wider: 98.2 / 86.1 / 89.9 for MSRL versus 92.8 / 81.8 / 84.0 for GPT-4o. The SFT-only baseline (MSRL-SFT) already beats every prior open-source model, and RL then adds another 6.2 points on ChartMimic high-level and 9.9 on ReachQA high-level.
The ablations are where the design choices earn their keep:
- RL on top of a raw baseline model (no SFT) actually underperforms SFT-only on low and high-level scores. The two stages are complementary, not substitutable.
- Visual rewards alone yield the best single-reward score but cost 1,344 GPU hours. The two-stage textual-then-hybrid schedule reaches nearly the same quality for 576 GPU hours, a roughly 2.3x speedup.
- Swapping GRPO for DPO with GPT-4.1-generated negatives drops the high-level score from 83.8 to 78.9. Preference pairs are apparently too coarse a signal for a task with this many measurable axes.
- Using a vision-only encoder like DINOv2 as the visual judge helps but underperforms the VLM judge, because embedding similarity does not capture fine-grained chart element mismatches.
Where it generalizes and where it does not
The training data is matplotlib only, but the authors tested transfer to Seaborn and Plotly by scraping images from the two libraries' official galleries. MSRL improved execution rates from 69.2 to 85.1 on Seaborn and from 62.7 to 90.0 on Plotly, though high-level fidelity scores stayed modest (30.5 and 35.9 respectively). So the model can reliably produce runnable code in unseen libraries, but stylistic faithfulness degrades outside the training distribution.
The qualitative failure modes are also worth flagging. Even the final MSRL model occasionally hallucinates titles or extra scatter points, and subplot layout recognition remains imperfect on charts with three or more panels. This is a working tool for reproducing scientific figures and automating chart digitization pipelines, not a drop-in replacement for a human plotter on complex dashboards.
What you can actually run
Both checkpoints are on Hugging Face under DocTron/MSRL and DocTron/MSRL-SFT, and the training scripts live in the DocTron-hub/MSRL repository. The model is a straight Qwen2.5-VL-7B fine-tune, so it loads with the standard transformers class:
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
"DocTron/MSRL", torch_dtype="auto", device_map="cuda"
)
processor = AutoProcessor.from_pretrained("DocTron/MSRL")
The broader lesson generalizes past charts. Any structured-output task where the target sequence is mostly boilerplate with a few high-value tokens (SVG generation, LaTeX transcription, UI code synthesis) is a candidate for the same recipe: saturate SFT first to establish a real baseline, then apply RL with rewards that specifically target the tokens that matter. The fact that a 7B open model can beat GPT-4o on a demanding multimodal task, using 24 H800 GPUs for the visual RL stage, suggests the ceiling on chart understanding was never about model size. It was about what the loss function was rewarding.