Table2LaTeX-RL: High-Fidelity LaTeX Code Generation from Table Images via Reinforced Multimodal Language Models

Jun Ling, Yao Qi, Tao Huang, Shibo Zhou, Yanqin Huang, Yang Jiang, Ziqi Song, Ying Zhou, Yang Yang, Heng Tao Shen, Peng Wang

Abstract

Converting table images into editable, high-fidelity LaTeX code remains a significant challenge for multimodal large language models (MLLMs). Traditional training methods often struggle with the syntactic ambiguity of LaTeX and the structural complexity of scientific tables. This paper introduces Table2LaTeX-RL, a framework that leverages a massive new dataset and a novel reinforcement learning strategy—Visual-Structure Group Relative Policy Optimization (VSGRPO). By incorporating a "visual-in-the-loop" reward mechanism, the model optimizes for the final rendered appearance and structural integrity rather than mere textual matching. Experimental results demonstrate that the resulting model, Qwen2.5-VL-3B-VSGRPO, achieves state-of-the-art performance, surpassing commercial tools like Mathpix and general-purpose models like GPT-4o in visual fidelity and structural accuracy.

Introduction

In scientific publishing and data extraction, the ability to reconstruct tables from images into professional-grade LaTeX code is essential. However, tables are inherently complex, often featuring nested headers, merged cells, and intricate mathematical notation. While current AI models excel at standard OCR tasks, they frequently fail to capture the precise typographic nuances required for LaTeX.

Existing approaches typically suffer from two primary limitations. First, many models prioritize HTML output, which lacks the precision of LaTeX. Second, most are trained using "teacher forcing," where the model is penalized for any deviation from a ground-truth text string. Because LaTeX is syntactically flexible—meaning multiple different code snippets can produce identical visual results—traditional training often penalizes valid variations, leading to suboptimal generalization and catastrophic "hallucinations" when the model encounters complex structures.

The Table2LaTeX-RL Framework

To address these challenges, the researchers developed a two-stage training pipeline designed to prioritize the final rendered output over raw text similarity.

1. Supervised Fine-Tuning (SFT)

The process begins with a baseline Multimodal Large Language Model (MLLM) fine-tuned on a massive, newly curated dataset of over 1.2 million table-image pairs. This stage provides the model with a foundational understanding of LaTeX syntax and the relationship between visual table elements and their corresponding code.

2. Visual-Structure Group Relative Policy Optimization (VSGRPO)

The core innovation of this work is the VSGRPO algorithm, which introduces a dual-reward mechanism to refine the model's performance:

  • Structure Reward: Utilizing the TEDS-Structure metric, this reward ensures the logical tree of the table—including rows, columns, and cell nesting—is correctly interpreted.
  • Visual Reward: This "visual-in-the-loop" component renders the model's generated LaTeX into an image in real-time. This image is then compared to the original source image using Complex Wavelet Structural Similarity (CW-SSIM).

By treating the LaTeX compiler as a non-differentiable environment, the model learns to prioritize code that works and looks correct, effectively bypassing the pitfalls of textual ambiguity.

Data and Complexity Categorization

Recognizing that data quality is a primary bottleneck, the authors constructed a comprehensive pipeline to scrape and process 1,209,986 table-LaTeX pairs from arXiv. To ensure robust evaluation, the data was categorized into three difficulty levels:

  • Simple: Standard grid layouts.
  • Medium: Tables with basic cell merging.
  • Complex: Tables featuring extensive use of \multirow, \multicolumn, and nested mathematical environments.

An evaluation benchmark of 1,211 diverse tables was also established to test the model's ability to generalize across various scientific domains.

Key Results and Insights

The Qwen2.5-VL-3B-VSGRPO model demonstrated significant improvements over both generalist and specialized models:

  • Superior Visual Fidelity: On complex tables, the model achieved a CW-SSIM of 0.6145, outperforming GPT-4o (0.4747) and Nougat (0.4699).
  • Structural Precision: The model became the first to surpass the 0.9 threshold on the TEDS-Structure metric for complex tables, reaching a score of 0.9218.
  • High Compilability: Despite the complexity of the generated code, the model maintained a compile success rate exceeding 99%, surpassing the industry standard set by Mathpix (98.89%).
  • Human Preference: Blind evaluations confirmed that human readers preferred the output of VSGRPO-trained models across all difficulty tiers, citing better alignment with the original visual intent.

Conclusion and Future Directions

Table2LaTeX-RL demonstrates that "visual-in-the-loop" reinforcement learning is a powerful tool for multimodal tasks where the final output is rendered. By rewarding visual and structural outcomes rather than text-based token matching, the framework overcomes the inherent ambiguities of LaTeX.

While the current approach is computationally intensive due to the need for real-time rendering during training, it sets a new benchmark for high-fidelity document reconstruction. Future work will focus on optimizing the rendering pipeline, potentially through the use of lightweight renderers or proxy models, to enable even larger-scale reinforced training.

Summary updated

BibTeX
@inproceedings{ling2025table,
  author = {Jun Ling and Yao Qi and Tao Huang and Shibo Zhou and Yanqin Huang and Yang Jiang and Ziqi Song and Ying Zhou and Yang Yang and Heng Tao Shen and Peng Wang},
  title = {{Table2LaTeX-RL: High-Fidelity LaTeX Code Generation from Table Images via Reinforced Multimodal Language Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=0bvc7Zslu3},
}
Figure