Abstract
While Large Language Models (LLMs) have achieved high proficiency in text-based mathematics, their multimodal counterparts (LMMs) continue to struggle with geometry and chart-based reasoning. This performance gap stems from the "lossy" nature of natural language captions, which fail to capture the precise coordinates and structural relationships inherent in mathematical diagrams. MathCoder-VL introduces a novel approach by using executable code (LaTeX/TikZ and Python) as a lossless intermediate representation. By training on 8.6 million image-to-code pairs and synthesizing 3 million instruction-following samples, MathCoder-VL achieves state-of-the-art performance, notably surpassing GPT-4o and Claude 3.5 Sonnet on complex geometry benchmarks.
The Limitation of Natural Language Descriptions
Standard multimodal training relies on natural language captions to describe visual scenes. However, for mathematical diagrams, text is inherently ambiguous. A description like "a circle inside a square" omits critical details such as tangency points, exact angles, and relative scales required for rigorous problem-solving. This lack of precision prevents vision encoders from learning the structural features necessary for high-level math.
Methodology: Code as a Lossless Bridge
To address the data bottleneck, MathCoder-VL utilizes executable code as the primary "caption" for mathematical images. Code provides a deterministic and complete description of a figure's geometry, making it a perfect, lossless representation.
The FigCodifier Pipeline
The authors developed an automated pipeline to generate <Image, Code> pairs. An initial model, FigCodifier, is iteratively trained to map images to their underlying code. If the generated code successfully compiles into a valid image, the pair is added to the training set. This process ensures high-quality, verifiable data.
Image-to-Code Mid-Training
Before fine-tuning for general math problem-solving, the model undergoes a "mid-training" phase. The language backbone is frozen, and the vision encoder is trained specifically to predict the exact code required to render a given math image. This forces the encoder to capture precise spatial and structural relationships that text-based training would overlook.
Visual Data Synthesis
One of the most significant contributions of MathCoder-VL is its ability to solve the visual data scarcity problem. By increasing the "temperature" during code generation, FigCodifier can "hallucinate" novel code structures. Because code is deterministic, these hallucinations result in perfectly valid and highly diverse new math diagrams. These synthetic images are then paired with questions and step-by-step solutions generated by an LLM (Qwen2.5), creating a massive, high-quality training corpus.
Experimental Results
MathCoder-VL was evaluated across several rigorous benchmarks, including MATH-Vision, MathVerse, and MathVista.
- Open-Source SOTA: MathCoder-VL-8B sets a new standard for open-source models of its size.
- Geometry Excellence: On the MathVista Geometry Problem Solving (GPS) subset, MathCoder-VL-8B achieved 73.6%, significantly outperforming GPT-4o (64.7%) and Claude 3.5 Sonnet (64.4%).
- Multi-Step Mastery: The model demonstrated superior performance on complex, multi-step problems in the We-Math benchmark, scoring 52.1% on three-step problems compared to GPT-4o's 43.6%.
Ablation studies confirmed that the image-to-code mid-training was the primary driver of these gains, particularly in "Vision-Only" tasks where the model cannot rely on textual hints to solve the problem.
Conclusion
MathCoder-VL demonstrates that code is a superior representation for training multimodal models in mathematical domains. By bridging the gap between visual perception and logical structure through executable code, the model achieves a level of precision previously unseen in open-source LMMs. Future work will focus on scaling these methods to larger model architectures and expanding the domain to other STEM fields like physics and chemistry.
Summary updated