Abstract
Automated data visualization requires translating visual chart structures into executable code, a task that demands both high-level structural understanding and low-level data precision. We present Chart-to-Code Mixture of Low-rank Adaptation (C2C-MoLA), a framework that integrates Mixture of Experts (MoE) with Low-Rank Adaptation (LoRA). By employing a complexity-aware router to distribute tasks among specialized experts, C2C-MoLA achieves a 17% accuracy improvement on complex charts while reducing GPU memory consumption by 18% compared to standard fine-tuning.
Introduction
Converting visual charts into Python code is a significant challenge for Multimodal Large Language Models (MLLMs). Existing models often struggle with generalization across diverse chart types, suffer from high computational costs during full fine-tuning, and lack the modularity needed to specialize in distinct visualization logics.
As shown in the comparison above, C2C-MoLA introduces dynamic routing awareness and structural metrics, filling a gap left by previous static or non-synergistic approaches.
Methodology
The C2C-MoLA architecture consists of two primary components designed for efficiency and specialization.
Complexity-Aware Mixture of Experts (MoE)
The model utilizes eight domain-specialized experts. A structure-aware router analyzes chart type and visual element density to determine the optimal expert allocation. To ensure balanced training and prevent "expert collapse," the framework incorporates an auxiliary load-balancing loss and Gaussian noise injection.
Low-Rank Adaptation (LoRA) Synergy
To maintain a lightweight profile, C2C-MoLA injects trainable low-rank matrices into the attention layers of the decoder. This avoids the overhead of full parameter updates while allowing the model to adapt to the specific nuances of chart-to-code translation.
The system employs a DeepSeek-Coder vision encoder for image processing and a Qwen2.5-Coder decoder for autoregressive code generation.
Experimental Setup
The framework was evaluated using the Chart2Code-160k dataset, comprising 160,000 image-code pairs across Bar, Line, Scatter, Pie, and Mixed categories. The dataset utilizes a stratified split, with the most complex variants reserved for the test set to evaluate generalization capabilities.
Results and Discussion
C2C-MoLA demonstrates superior performance across multiple metrics:
- Accuracy: The model achieved success rates of 92% for bar charts and 91% for scatter plots. Notably, it improved performance on complex, multi-axis charts by 17% over baseline methods.
- Efficiency: Peak GPU memory usage was reduced from 15.0GB to 12.3GB (an 18% reduction).
- Convergence: The model reached convergence 20% faster than standard baselines, requiring only 4 epochs compared to 5.
While the routing mechanism introduces a minor inference overhead (~0.05s), the gains in accuracy and memory efficiency provide a substantial net benefit for practical applications.
Conclusion
C2C-MoLA provides a scalable and efficient solution for automated chart-to-code generation. By combining the specialization of MoE with the efficiency of LoRA, the framework handles complex visualizations that traditional monolithic models struggle to process. Future work will focus on improving robustness to "in-the-wild" data and exploring expert-centric pretraining strategies.
Summary updated