Aligning Text, Code, and Vision: A Multi-Objective Reinforcement Learning Framework for Text-to-Visualization

Mizanur Rahman, Mohammed Saidul Islam, Md. Tahmid Rahman Laskar, Shafiq Joty, Enamul Hoque

TL;DR

RL-Text2Vis is the first reinforcement learning framework designed to align natural language queries with executable code and high-quality visualizations. By leveraging Group Relative Policy Optimization (GRPO) and a multi-objective reward system that "sees" the rendered chart, the authors trained open-source models (Qwen2.5) that significantly outperform GPT-4o in chart clarity and semantic correctness.

What Problem Does This Paper Address?

Translating a natural language query (e.g., "Show me the trend of renewable energy share over the last decade") into a visualization is a complex Text-to-Visualization (Text2Vis) task. It requires three distinct capabilities:

  1. Reasoning: Understanding the tabular data and the user's intent.
  2. Coding: Generating executable Python/Matplotlib code.
  3. Design: Ensuring the resulting chart is readable, accurate, and visually aligned with the query.

Current Large Language Models (LLMs) often fail here. Even if the code runs, the chart might display the wrong data or be visually uninterpretable. Traditional Supervised Fine-Tuning (SFT) fails to fix this because it only optimizes for token-level similarity to a reference; it cannot account for the "post-execution" quality of the chart. If the model doesn't "see" the output of its code during training, it can't learn to make better design choices.

Methods

The authors introduce RL-Text2Vis, a training pipeline that treats visualization as a multimodal reasoning problem solvable via Reinforcement Learning.

1. The Algorithm: GRPO

Instead of standard PPO (Proximal Policy Optimization), which requires a resource-heavy "critic" model to estimate rewards, the authors use Group Relative Policy Optimization (GRPO). GRPO generates a group of outputs for each prompt and calculates rewards relative to the group's average. This makes it more efficient for long-sequence generation like code.

2. Multi-Objective Reward Design

The core innovation is a two-stage reward system that provides feedback after the code is executed:

  • Stage 1 (Format): A binary reward for producing valid JSON and runnable Python code.
  • Stage 2 (Composite): If the code runs, the model receives a weighted score based on:
  • Textual Correctness ($R_{text}$): Does the short textual answer match the ground truth? (Evaluated by an LLM).
  • Code Reward ($R_{code}$): Does the code execute without errors, and does it match the user's intent?
  • Visualization Quality ($R_{vis}$): This is the "vision" component. A Vision-Language Model (VLM), specifically Qwen2.5-VL, acts as a judge to rate the rendered chart on readability (labels, scaling, layout) and correctness (faithfulness to the data).

Datasets

The framework was evaluated across several benchmarks to test both in-domain performance and out-of-domain generalization:

  • Text2Vis (In-Domain): The primary benchmark containing natural language queries, tables, and reference charts.
  • VisEval (Out-of-Domain): A challenging benchmark with ambiguous mappings and complex layouts.
  • NVBench (Out-of-Domain): A large-scale dataset covering 105 different domains.
  • PandasPlotBench (Out-of-Domain): Specifically tests the ability to generate plotting code from Pandas DataFrames.

Key Insights and Ideas

  • Closing the "Execution Gap": The paper demonstrates that LLMs can't be "taught" to visualize through text alone. Incorporating a VLM in the training loop to "critique" the rendered image is essential for design-heavy tasks.
  • Open-Source Parity: By using RL, a 14B parameter open-source model (Qwen2.5) can surpass proprietary giants like GPT-4o in specific visualization metrics. RL-Text2Vis-14B achieved a 4.10/5.0 in chart readability compared to GPT-4o’s 3.32/5.0.
  • GRPO as a Multimodal Strategy: While GRPO gained fame through DeepSeek-R1 for mathematical reasoning, this paper proves it is equally effective for "structured multimodal reasoning"—aligning code logic with visual output.
  • Robustness through Diversity: The model doesn't just memorize; it generalizes. It showed significant gains on datasets it never saw during training (like NVBench), proving the RL process teaches underlying visualization principles.

Key Results

  • Execution Success: Boosted code execution rates from 78% to 97% for the 14B model.
  • Chart Quality: Achieved a 22% relative improvement in chart quality over GPT-4o.
  • Final Pass Rate: On the Text2Vis benchmark, the RL-Text2Vis-14B model reached a 29% final pass rate (a strict metric requiring correct text, executable code, and high-quality visuals), nearly matching GPT-4o's 30% and doubling the performance of its zero-shot starting point (14%).
  • Ablation Success: Removing the visual reward component led to a significant drop in chart correctness, confirming that the "vision" feedback is the "secret sauce."

Limitations and Future Work

  • Computational Intensity: Training the 14B model required 50 hours on 6x NVIDIA H100 GPUs, which may be prohibitive for smaller labs.
  • Static vs. Interactive: The current work focuses entirely on static images (Matplotlib). Future work could extend this to interactive libraries like Plotly or D3.js.
  • Specialized Domains: While it generalizes well to general domains, its performance in highly specialized fields (e.g., medical imaging data or complex financial forensics) remains untested.
  • VLM Bias: The system relies on a VLM (Qwen2.5-VL) as a judge. While the authors found high agreement with human raters, any inherent biases in the judge model could potentially leak into the trained policy.

Summary updated

BibTeX
@inproceedings{rahman2026aligning,
  author = {Mizanur Rahman and Mohammed Saidul Islam and Md. Tahmid Rahman Laskar and Shafiq Joty and Enamul Hoque},
  title = {{Aligning Text, Code, and Vision: A Multi-Objective Reinforcement Learning Framework for Text-to-Visualization}},
  booktitle = {EACL (Volume 1: Long Papers)},
  year = {2026},
  doi = {10.18653/v1/2026.eacl-long.317},
}

Loading related content...

Figure