NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

CodePercept: Code-Grounded Visual STEM Perception for MLLMs

Tongkun Guan, Zhibo Yang, Jianqiang Wan, Mingkun Yang, Zhentao Guo, Zijian Hu, Ruilin Luo, Ruizhe Chen, Songtao Jiang, Peng Wang, Wei Shen, Junyang Lin, Xiaokang Yang

TL;DR

When Multimodal Large Language Models (MLLMs) fail at complex STEM problems, the culprit is usually poor visual perception rather than weak reasoning. To fix this, CodePercept introduces a "code-as-perception" paradigm, training MLLMs to translate STEM diagrams into executable Python code. By grounding visual understanding in precise code semantics, CodePercept significantly boosts MLLM performance across major STEM benchmarks.

What Problem Does This Paper Address?

Artificial intelligence has made massive strides in text-based reasoning, but solving visual problems in Science, Technology, Engineering, and Mathematics (STEM) remains a major hurdle for MLLMs. When a model fails to solve a geometry puzzle or interpret a physics chart, it has been historically difficult to diagnose why: did it fail to reason through the steps, or did it simply misperceive the image?

The authors discover that perception is the primary bottleneck. Traditional natural language captions suffer from what they call descriptive aphasia—words are simply too ambiguous to precisely capture exact coordinates, complex 3D spatial relationships, or intricate geometric structures. Furthermore, existing benchmarks evaluate perception indirectly through final problem-solving accuracy, which only checks if a model caught problem-relevant details rather than assessing its holistic visual comprehension.

Methods

To overcome the limitations of natural language, CodePercept establishes executable Python code (specifically using the matplotlib library) as a structured, deterministic medium for visual perception. If a model can write code that perfectly reconstructs an image, it proves complete visual comprehension.

The CodePercept framework consists of two main training tasks:

  1. Code-Grounded Caption Generation: Instead of relying on hallucination-prone text descriptions, the model uses ground-truth executable code to verify and refine natural language captions, ensuring exact counts and spatial configurations.
  2. STEM Image-to-Code Translation: The model is trained to directly translate a visual diagram into clean, explanatory Python code that can render the exact same image.

The training pipeline operates in two stages:

  • Stage 1: Supervised Finetuning (SFT): Jointly trains the model on image-captioning and image-to-code translation tasks to align visual, linguistic, and symbolic code representations.
  • Stage 2: Reinforcement Learning (RL): Uses Group Relative Policy Optimization (GRPO) to optimize code generation. It rewards the model based on code format, successful execution, code-level semantic similarity, and visual similarity of the rendered output compared to the original image.
Figure 2. The overview pipeline of CodePercept that enhances MLLMs’ visual perception in STEM domains through code-grounded learning. (Part 01) Starting from public STEM data, we construct high-quality image-code pairs via three complementary pipelines: (1) Image Reproduce converts existing STEM images into executable Python codes, (2) Image Diversity extracts concepts from seed images and generates diverse instantiations while preserving semantic validity, and (3) Solid Geometry employs parametric templates to generate complex solid geometry images with corresponding codes, addressing MLLMs’ solid geometry limitations. (Part 02) The synthesized data enables two novel training tasks (Code-Grounded Caption Generation and STEM Image-to-Code Translation) that fundamentally shift how we approach visual perception. (Part 03) These processes culminate in ICC-1M, a dataset of over 1M curated image-caption-code triplets. We employ both Supervised Finetuning and Reinforcement Learning to train models that achieve robust visual perception capabilities.

Datasets

The authors introduced two major resources to the community:

  • ICC-1M: A large-scale dataset containing over 1 million high-quality Image-Caption-Code triplets. It was built using three parallel pipelines: direct image reproduction, conceptual diversification (abstracting a scientific principle and rendering it in new visual contexts), and specialized solid geometry synthesis using parametric templates to overcome standard LLM spatial deficiencies.
  • STEM2Code-Eval: A new, manually curated benchmark of 1,000 images spanning mathematics, physics, chemistry, and electrical engineering. Unlike standard benchmarks, it directly evaluates visual perception by challenging models to generate code that reproduces the input image.

Key Insights and Ideas

  • Perception is the True Lever: Through a systematic scaling analysis where perception (image-to-text) and reasoning (text-to-answer) were scaled independently, the authors proved that improving a model's perception capacity consistently yields higher performance gains than scaling its reasoning capacity.
Figure 1. The scaling analysis reveals perception as the bottleneck in STEM. We decouple visual STEM reasoning into perception (image-to-caption) and reasoning (caption-to-answer) stages, then independently scale each component while keeping the other con- stant. All components use Qwen3-VL-Thinking [35] models and evaluation in the representative MathVision Dataset [45]. Both ex- periments demonstrate that scaling perception consistently outper- forms scaling reasoning. This finding motivates our focus on sys- tematically enhancing MLLMs’ perception capabilities in STEM.
  • Code as a Grounding Modality: Code acts as an ideal bridge for multimodal learning. It eliminates the ambiguity of human language by providing precise, mathematical definitions of visual primitives (lines, points, colors, shapes) that can be deterministically executed and verified.

Key Results

The authors evaluated CodePercept across six prominent STEM benchmarks (including MathVision, MathVista, and DynaMath) using a captioner-solver setup.

  • Problem-Solving Boost: Integrating CodePercept-SFT models as image captioners consistently improved downstream problem-solving accuracy. For example, CodePercept-8B-S1 outperformed its base model (Qwen3-VL-8B-Instruct) by an average of 3.0%, even surpassing much larger models like Qwen2.5-VL-72B.
  • Superior Image Reconstruction: On the new STEM2Code-Eval benchmark, CodePercept models achieved massive gains in code execution rates and image similarity scores. CodePercept-32B-R1 achieved an execution success rate of 95.90% and an overall average score of 65.75, nearly doubling the performance of standard baseline models.
Table 2. Performance evaluation on our STEM2Code-Eval with 1k samples. We employ three metrics to assess their performances : (1) Image Scoring measures the visual similarity between the gen- erated and original images; (2) Code Scoring assesses the quality, structure, and correctness of the generated Python code itself; (3) Exec Rate reports the execution success rate.

Limitations and Future Work

Not discussed in the paper.

Summary updated

BibTeX
@inproceedings{guan2026codepercept,
  author = {Tongkun Guan and Zhibo Yang and Jianqiang Wan and Mingkun Yang and Zhentao Guo and Zijian Hu and Ruilin Luo and Ruizhe Chen and Songtao Jiang and Peng Wang and Wei Shen and Junyang Lin and Xiaokang Yang},
  title = {{CodePercept: Code-Grounded Visual STEM Perception for MLLMs}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2026},
  url = {https://openreview.net/forum?id=qENN5UTidc},
}
Figure