Distill Visual Chart Reasoning Ability from LLMs to MLLMs

Wei He, Zhiheng Xi, Wanxu Zhao, Xiaoran Fan, Yiwen Ding, Zifei Shan, Tao Gui, Qi Zhang, Xuanjing Huang · Submission to ICLR 2025 · Rejected

TL;DR

Researchers have developed Code-as-Intermediary Translation (CIT), a method that uses Python code as a bridge to distill complex visual reasoning from Large Language Models (like GPT-4o) into smaller, open-source Multimodal Large Language Models (MLLMs). By training on the resulting REACHQA dataset, models like LLaVA-Next saw performance boosts of over 30%, proving that teaching a model to "understand" the code behind a chart is the secret to mastering visual reasoning.

What Problem Does This Paper Address?

While MLLMs have become remarkably good at identifying objects in photos, they still struggle with "visual reasoning"—the ability to look at a complex chart, extract specific data points, and perform multi-step logic (e.g., "Which country had the second-highest growth rate between 2010 and 2020?").

The bottleneck isn't just model architecture; it’s data. Existing chart datasets are often too simple, rely on basic templates, or are manually annotated, making them expensive and hard to scale. Furthermore, when LLMs are asked to generate Q&A pairs from raw data tables, they often ignore "visual-semantic" features like color-coding or overlapping subplots. This leads to training data that doesn't actually help a model "see" better.

Methods: Code-as-Intermediary Translation (CIT)

The authors introduce Code-as-Intermediary Translation (CIT). Instead of using data tables or raw images as the source of truth, they use Python plotting code (Matplotlib) as the bridge.

The Code-as-Intermediary Translation (CIT) pipeline used to generate the REACHQA dataset.
  1. Seed & Expand: The process starts with 33 "seed" codes from the Matplotlib gallery.
  2. Self-Instruct & Evol-Instruct: Using LLMs, these seeds are expanded into thousands of diverse chart types. The codes are then "evolved" to be more complex by adding overlays, subplots, and dense data groups.
  3. Bi-directional Translation: Because the LLM "understands" the code it just wrote, it can generate highly accurate, reasoning-intensive Q&A pairs. The code acts as a perfect textual representation of the visual structure.
  4. Self-Repair & Validation: If the generated code doesn't run, the system uses a "Self-Repair" loop to fix it. Finally, a "majority voting" ensemble of smaller MLLMs filters out low-quality images or misaligned questions.

The REACHQA Dataset

The primary contribution of this pipeline is REACHQA, a dataset containing:

  • 3,249 reasoning-intensive charts.
  • 19,963 Q&A pairs (split between recognition-oriented and reasoning-oriented tasks).

The authors evaluated their models against a battery of existing benchmarks, including chart-specific tests (ChartQA, ChartBench, ChartX, and CharXiv) and general reasoning tests (MathVista and MATH-Vision).

Key Insights and Ideas

  • Code is the Best Bridge: The "aha moment" is that code is a superior intermediary compared to data tables. Code explicitly defines visual elements (like "the red dashed line") that a table lacks, allowing the LLM to generate questions that are truly grounded in the visual output.
  • The Recognition-Reasoning Loop: The study found that recognition and reasoning are interdependent. If a model can't recognize the data accurately, its reasoning fails; however, training on reasoning-heavy data actually improves the model's recognition accuracy.
  • Cross-Domain Generalization: Surprisingly, fine-tuning on REACHQA didn't just make models better at charts. It improved their performance on general math reasoning benchmarks (like MathVista), suggesting that the logic patterns learned from charts are transferable to other mathematical contexts.

Key Results

The impact of REACHQA on open-source models was substantial:

Error reduction across different models when fine-tuned with the REACHQA dataset.
  • Massive Performance Gains: LLaVA-Next-Llama3-8B saw an average performance gain of 34.8% across all benchmarks, while InternVL2-8B improved by 20.8%.
  • Error Reduction: On the ChartQA test set, the REACHQA-trained models significantly reduced both "Recognition Errors" and "Reasoning Errors" compared to vanilla baselines.
  • Cost-Efficiency: The entire dataset was synthesized for approximately $300, a fraction of the cost of manual annotation or high-end proprietary API calls for every training sample.

Limitations and Future Work

The authors acknowledge a few key hurdles:

  • The "Natural Image" Gap: While CIT works wonders for abstract, structured images like charts and diagrams, it is difficult to apply to natural images (photos) because there is no "code" that perfectly generates a photo of a street scene.
  • Teacher Model Dependency: The quality of the distilled knowledge is capped by the "teacher" model (in this case, GPT-4o). If the teacher misinterprets the code, the synthetic data will be flawed.
  • Future Directions: The researchers suggest that as text-to-image models become more controllable, the CIT framework could potentially be expanded to more diverse visual domains beyond just charts.

Summary updated

BibTeX
@misc{he2024distill,
  author = {Wei He and Zhiheng Xi and Wanxu Zhao and Xiaoran Fan and Yiwen Ding and Zifei Shan and Tao Gui and Qi Zhang and Xuanjing Huang},
  title = {{Distill Visual Chart Reasoning Ability from LLMs to MLLMs}},
  year = {2024},
  eprint = {2410.18798},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.18798},
}
Figure