MM-ReCoder: Advancing Chart-to-Code Generation with Reinforcement Learning and Self-Correction
Organizations: Brown University · Amazon AGI
Abstract
Multimodal Large Language Models (MLLMs) have recently demonstrated promising capabilities in multimodal coding tasks such as chart-to-code generation. However, existing methods primarily rely on supervised fine-tuning (SFT), which requires the model to learn code patterns through chart-code pairs but does not expose the model to a code execution environment. Moreover, while self-correction through execution feedback offers a potential route to improve coding quality, even state-of-the-art MLLMs have been shown to struggle with effective self-correction. In this work, we introduce MM-ReCoder, a chart-to-code generation model trained with reinforcement learning (RL) and equipped with self-correction ability. We propose a two-stage multi-turn self-correction RL strategy based on Group Relative Policy Optimization (GRPO). The first stage enhances the model's self-correction ability via rolling out a shared first turn, while the second stage improves the coding capability with full-trajectory optimization. MM-ReCoder learns to produce more accurate and executable code through the interaction with the environment and by iteratively correcting its own outputs. Our results on three chart-to-code benchmarks demonstrate the state-of-the-art performance of MM-ReCoder.
Figures & tables
| Model | # Turns | ChartMimic | Plot2Code | ChartX | ||||
| Exec.Rate | Low-Level | High-Level | Pass Rate | Text-Match | Rating | GPT-score | ||
| (GPT-4o) | (GPT-4V/4o) | (GPT-4/4o) | ||||||
| Full score | - | 100 | 100 | 100 | 100 | 100 | 10 | 5 |
| Proprietary | ||||||||
| GeminiProVision | 1 | 68.2 | 53.8 | 53.3 | 68.2 | 53.6 | 3.69 / - | - |
| Claude-3-opus | 1 | 83.3 | 60.5 | 60.1 | 84.1 | 57.5 | 3.80 / - | - |
| Strategy | First turn | Second turn | Avg. low-level improvement on rendered charts | Percentage of improved samples | Percentage of degraded samples | Percentage of repeated code | ||||
| Exec.Rate | Low-Level | Exec.Rate | Low-Level | |||||||
| 0 | 0 | 91.8 | 81.8 | 95.2 | 83.9 | 0.21 | 3.4 | 2.6 | 46.9 | |
| Full-trajectory | 0 | 0.1 | 64.5 | 66.7 | 96.0 | 84.3 | 10.11 | 87.5 | 2.3 | 0.3 |
| 0.5 | 0.1 | 96.5 | 85.0 | 97.5 | 85.5 | -0.03 | 2.2 | 2.2 | 55.6 | |
| Turn-wise | - | - | 94.5 | 82.7 | 96.8 | 83.4 | 0.05 | 2.7 | 1.6 | 63.0 |
| Shared-first-turn | - | - | 91.7 | 79.8 | 95.8 | 82.6 | 0.72 | 14.4 | 8.4 | 16.8 |
| Model | Low-level | High-level | ||||
| Average improve | Improved | Degraded | Average improve | Improved @0.1 | Degraded @0.1 | |
| Qwen2.5-VL-7B | -0.36 | 8.1 | 13.9 | -0.85 | 8.9 | 10.7 |
| Qwen2.5-VL-72B | 0.22 | 15.9 | 14.5 | 0.20 | 11.2 | 10.2 |
| Qwen3-VL-8B | -1.03 | 6.0 | 14.5 | -0.70 | 6.8 | 8.3 |
| Qwen3-VL-235B-A22B | -0.26 | 13.4 | 13.5 | 0.27 | 5.4 | 4.8 |
| GPT-4o | 0.85 | 22.4 | 12.0 | 1.76 | 11.2 | 4.9 |
| Turn | Exec. Rate | Low- level | High- level | Low-level | High-level | ||
| Avg. improve | Improved% | Avg. improve | Improved%@0.1 | ||||
| 1 | 92.5 | 83.5 | 81.2 | - | - | - | - |
| 2 | 96.5 | 84.8 | 84.7 | 0.30 | 7.3 | 0.89 | 7.1 |
| 3 | 96.5 | 85.3 | 84.8 | 0.12 | 3.8 | 0.22 | 3.7 |
| 4 | 97.5 | 86.5 | 84.9 | 0.10 | 2.6 | -0.1 | 2.6 |
| 5 | 98.3 | 86.4 | 85.5 | -0.12 | 2.4 | 0.26 | 3.7 |
| Strategy | First turn low-level | Second turn low-level | Avg. improvement on rendered charts | Percentage of repeated code |
| Qwen2.5-VL-7B | 56.2 | 57.2 | -0.36 | 10.9 |
| + Single-turn cold start | 79.1 | 78.9 | -0.10 | 81.5 |
| + Multi-turn cold start | 75.2 | 73.5 | -0.54 | 2.3 |
| + RL | 83.5 | 84.8 | 0.30 | 2.2 |
| Reward weights | ChartMimic | ||||
| Format | Rule-based | Model-based | Exec.Rate | Low-level | High-level |
| 0.1 | 0.9 | 0.0 | 95.0 | 84.8 | 78.6 |
| 0.1 | 0.8 | 0.1 | 95.0 | 84.3 | 83.7 |
| 0.1 | 0.6 | 0.3 | 94.3 | 84.1 | 83.7 |
| 0.1 | 0.4 | 0.5 | 95.5 | 84.2 | 85.3 |
| 0.1 | 0.2 | 0.7 | 93.3 | 83.9 | 83.8 |
Appendix figures & tables16 assets
Supplementary material from the paper’s appendix.
Appendix
| Strategy | First turn | Second turn | Avg. low-level improvement on rendered charts | Percentage of improved samples | Percentage of degraded samples | Percentage of repeated code | ||||
| Exec.Rate | Low-Level | Exec.Rate | Low-Level | |||||||
| Full-trajectory | 0 | 0 | 91.8 | 81.8 | 95.2 | 83.9 | 0.21 | 3.4 | 2.6 | 46.9 |
| 0 | 0.1 | 64.5 | 66.7 | 96.0 | 84.3 | 10.11 | 87.5 | 2.3 | 0.3 | |
| Full-trajectory | 0 | 0.3 | 79.0 | 73.7 | 94.5 | 83.2 | 4.57 | 77.1 | 8.3 | 0.0 |
| 0 | 0.5 | 71.8 | 72.5 | 96.2 | 77.7 | 3.13 | 77.7 | 10.2 | 0.0 | |
| 0.5 | 0.1 | 96.5 | 85.0 | 97.5 | 85.5 | -0.03 | 2.2 | 2.2 | 55.6 | |
| Strategy | First turn | Second turn | Avg. low-level improvement on rendered charts | Percentage of improved samples | Percentage of degraded samples | Percentage of repeated code | ||||
| Exec.Rate | Low-Level | Exec.Rate | Low-Level | |||||||
| Full-trajectory | 0 | 0 | 91.8 | 81.8 | 95.2 | 83.9 | 0.21 | 3.4 | 2.6 | 46.9 |
| 0.5 | 0.1 | 96.5 | 85.0 | 97.5 | 85.5 | -0.03 | 2.2 | 2.2 | 55.6 | |
| Full-trajectory for 2 epochs | 0 | 0 | 92.3 | 79.0 | 97.0 | 81.8 | 0.16 | 4.5 | 2.5 | 54.0 |
| 0.5 | 0.1 | 94.3 | 82.2 | 94.2 | 82.3 | 0.07 | 2.7 | 1.6 | 87.7 | |
| Shared-first-turn | - | - | 91.7 | 79.8 | 95.8 | 82.6 | 0.72 | 14.4 | 8.4 | 16.8 |
| Cold Start | Performance on ChartMimic after RL | |||
| First turn low-level | Second turn low-level | Average improvement on rendered charts | Percentage of repeated code | |
| None | 83.0 | 84.9 | 0.53 | 36.3 |
| Single-turn cold start | 82.3 | 84.8 | 0.02 | 13.1 |
| Single-turn cold start + multi-turn cold start | 83.7 | 86.0 | 0.55 | 21.6 |
| Reward Model | ChartMimic | ||
| Exec.Rate | Low-level | High-level | |
| None | 95.0 | 84.8 | 78.6 |
| Qwen2.5-VL-7B | 95.3 | 81.0 | 82.6 |
| Qwen2.5-VL-72B | 95.0 | 84.3 | 83.7 |
| Win | Tie | Loss | |
| Ours v.s. ChartCoder | |||
| Ours v.s. Qwen2.5-VL-72B | |||
| Ours v.s. Qwen3-VL-235B-A22B |
| Model | Diagnosis error | Coding error | Regression |
| MM-ReCoder | 8 (30.8%) | 13 (50.0%) | 5 (19.2%) |
| Qwen3-VL-8B | 22 (37.9%) | 28 (48.3%) | 8 (13.8%) |
| Qwen3-VL-235B-A22B | 15 (20.5%) | 33 (45.2%) | 25 (34.3%) |