TL;DR
This paper introduces Text2Chart31, a comprehensive dataset designed to teach Large Language Models (LLMs) how to generate complex data visualizations across 31 unique plot types. To maximize performance, the authors developed a reinforcement learning (RL) instruction-tuning technique that uses automated feedback and cycle consistency to align models without requiring expensive human annotation. The resulting fine-tuned open-source models (8B and 13B parameters) outperform state-of-the-art proprietary models like GPT-4 and Claude 3 Opus on chart generation tasks.
What Problem Does This Paper Address?
While LLMs excel at generating text and basic code, visualizing complex, real-world data via charts and plots remains a significant hurdle. The authors identify two primary bottlenecks:
- Dataset Gaps: Existing chart datasets primarily focus on Chart Question Answering (QA) rather than chart generation. Furthermore, they lack diversity, rarely covering advanced visualization types like 3D, volumetric, gridded, or irregularly gridded charts.
- Methodological Limitations: Standard Supervised Fine-Tuning (SFT) struggles to fully capture the intricate, multi-modal relationships between data tables, natural language descriptions, and execution-ready code.
To bridge these gaps, this work focuses on automated dataset curation and advanced instruction tuning specifically tailored for data visualization.
Methods
The authors tackle the problem using a two-pronged approach: a hierarchical data generation pipeline and an RL-based instruction tuning framework.
1. Hierarchical Data Generation Pipeline
To create a high-quality dataset without human bias, the authors designed a multi-step pipeline leveraging GPT-3.5-turbo and GPT-4:
- Topic & Description Generation: Topics are sampled from a diverse pool and expanded into detailed plot descriptions. GPT-4 self-evaluates these descriptions to filter out incompatible instructions.
- Code & Data Table Production: The descriptions prompt GPT-4 to generate executable Matplotlib code and corresponding raw data tables.
- Cycle-Consistency Filtering: To ensure quality, an AI-assisted check regenerates the description from the produced code. If the new description doesn't match the original, the data point is discarded.
2. RL via Automatic Feedback
Instead of relying on costly human feedback, the authors introduce two automated reward functions optimized via Proximal Policy Optimization (PPO):
- Preference Reward: A reward model is trained to prefer the ground-truth code over the suboptimal code generated during the initial SFT phase.
- Alignment Reward: This exploits cycle consistency. A secondary model regenerates a text description from the predicted code, and the reward is calculated based on the semantic similarity (via BERTScore) between the original and regenerated descriptions.
Datasets
The paper introduces Text2Chart31 (and an expanded version, Text2Chart31-v2), which contains up to 28.2K tuples combining descriptions, Matplotlib code, data tables, intermediate reasoning steps, and final plots. It covers 31 unique plot types across five major categories: pairwise, statistical distribution, gridded, irregularly gridded, and 3D/volumetric charts.
Compared to existing benchmarks like PlotQA or ChartQA, Text2Chart31 achieves a near-perfect Shannon Diversity Index (0.993 for v2), indicating an exceptionally well-balanced distribution of chart types.
Key Insights and Ideas
- Cycle Consistency as a Reward Signal: One of the most elegant ideas in the paper is using the "Description $\rightarrow$ Code $\rightarrow$ Description" loop as a closed-loop training signal. If a model generates code that can be successfully translated back into the original prompt, it serves as strong proof of code correctness.
- Smaller Models Can Punch Above Their Weight: By focusing on high-quality, balanced data and targeted RL feedback, smaller open-source models (like Llama 3 Instruct 8B and Code Llama 13B) can beat massive, closed-source models on specialized tasks.
- Hierarchical Generation Defeats LLM Bias: Standard LLMs naturally default to common charts (like bar and line graphs). Forcing the generation through a structured pipeline ensures that complex visualizations (like 3D wireframes or triplots) receive equal representation.
Key Results
The models were evaluated across three primary tasks: Description-to-Chart, Raw Data-to-Chart, and Code-to-Description.
- Description-to-Chart: The fine-tuned Code Llama 13B model (
[SFT+RLpref] CLI-13B) achieved a remarkably low total code execution error ratio of 9.21%, outperforming GPT-4 (19.26%) and Claude 3 Opus (14.90%). - RL Improvement: Applying RL fine-tuning to the Llama 3 Instruct 8B model reduced its total error ratio from 16.09% to 14.55%.
- Human Evaluation: Blind A/B testing by crowd workers confirmed that the authors' fine-tuned models consistently generated charts that better matched the reference plots compared to base models and GPT-3.5-turbo.
Limitations and Future Work
The authors note a few limitations to their current approach:
- Library Dependency: The dataset is strictly tied to Matplotlib version 3.8. Changes or deprecations in earlier or future versions of the library could introduce runtime errors.
- Language Constraint: The chart descriptions are currently provided exclusively in English.
- Task Scope: The framework is explicitly optimized for chart generation and does not address chart question answering (QA), which remains an open area for future integration.
Summary updated