InfiMM-WebMath-40B: Advancing Multimodal Pre-Training for Enhanced Mathematical Reasoning

Xiaotian Han, Yiren Jian, Xuefeng Hu, Haogeng Liu, Yiqi Wang, Qihang Fan, Yuang Ai, Huaibo Huang, Ran He, Zhenheng Yang, Quanzeng You

TL;DR

InfiMM-WebMath-40B is the first large-scale, open-source multimodal pre-training dataset designed specifically for mathematical reasoning, comprising 24 million web documents, 85 million image URLs (28 million extracted images), and 40 billion text tokens. By continuing pre-training on this dataset, the authors' resulting model (InfiMM-Math-7B) establishes a new state-of-the-art among open-source multimodal models on challenging benchmarks like MathVerse and We-Math.

What Problem Does This Paper Address?

While Large Language Models (LLMs) have made dramatic progress on textual math reasoning via large-scale mathematical pre-training corpora (e.g., OpenWebMath, DeepSeekMath), visual mathematical reasoning remains a bottleneck. Mathematics relies heavily on visual information—geometry figures, function plots, and diagrams.

Existing Multimodal LLMs (MLLMs) typically inject math capabilities only during the instruction fine-tuning (IFT) phase using small, synthetic datasets. Introducing core mathematical knowledge during fine-tuning often leads to hallucinations and poor generalization due to limited dataset scale and diversity. The open-source research community lacked a massive, high-quality, multimodal pre-training corpus of interleaved math text and figures—a gap this paper directly fills.

Methods

The authors designed a rigorous data curation pipeline starting from CommonCrawl’s ~122 billion web pages:

  1. Formula-Preserving HTML Extraction: Standard tools like Trafilatura strip mathematical symbols and equations. The authors built a custom extraction tool based on Resiliparse to faithfully preserve both LaTeX equations and associated image URLs.
  2. Language & High-Recall Filtering: Used fastText to retain English and Chinese pages (reducing the pool to 57.2B pages), followed by a high-recall fastText binary classifier trained on OpenWebMath to identify mathematical web content (bringing the count to 9.5B pages).
  3. Deduplication & Rule-based Cleansing: Applied MinHash document deduplication, URL deduplication, and heuristic text filters (e.g., removing lorem ipsum, high punctuation ratios, and NSFW content), yielding 3.8B documents.
  4. High-Precision Quality Filtering: Used LLaMA-3-70B-Instruct to rate the educational and mathematical quality of ~1M samples on a 0–10 scale. Samples scoring $\ge 6$ served as positive labels to train a fastText classifier (using SpaCy preprocessing and <NUM> token standardization) to filter the remaining corpus down to 24 million high-quality documents.
  5. Multimodal Alignment & Training: Paired text with 14 million unique downloaded images. Using a SigLIP vision encoder, a 3-layer Perceiver Resampler (compressing each image to 64 tokens), and DeepSeek-Coder backbones (1.3B and 7B), the authors trained models through a three-stage recipe:
  6. Modality alignment: On general image-text pairs from DFN-2B (8M subset).
  7. Continued Pre-Training (CPT): On InfiMM-WebMath-40B.
  8. Instruction Fine-Tuning (IFT): On a mixture of multimodal math QA and unimodal text math instructions.
CommonCrawl (122B)
  └── Language Filter (57.2B)
        └── High-Recall Classifier (9.5B)
              └── MinHash / URL Deduplication (3.9B)
                    └── Rule-based Filters (3.8B)
                          └── High-Precision fastText Scoring
                                └── InfiMM-WebMath-40B (24M pages, 40B tokens, 28M images)

Datasets

  • Introduced Dataset: InfiMM-WebMath-40B (interleaved multimodal web documents, released publicly on Hugging Face).
  • Text Pre-training Baseline Datasets: OpenWebMath, DeepSeekMath Corpus.
  • Fine-Tuning Datasets: MAVIS, Geo170k, PGPS9K, ChartQA, DVQA, DocVQA, ScienceQA, along with pure-text datasets like NuminaMath, DART-Math, and MetaMathQA.
  • Evaluation Benchmarks: MathVerse, We-Math, GSM8K, and MMLU (STEM).

Key Insights and Ideas

  • Multimodal CPT Trumps Scaling IFT: Ablation experiments showed that adding continued pre-training on InfiMM-WebMath-40B provided a +4.6 to +5.3 point boost on MathVerse, whereas simply expanding the instruction fine-tuning dataset only provided a ~2 point gain. Foundational pre-training remains irreplaceable for domain knowledge.
  • The Pitfall of LLM Classifiers (Length Bias): While LLaMA-3-70B is an effective judge, using an LLM directly as a filtering classifier introduced a heavy length bias (average document length of 2,500 tokens vs. 1,700 for fastText). Models trained on LLM-filtered data scored significantly worse on concise math problems (17.5% on GSM8K vs. 20.2% for fastText-filtered data).
  • Text-Only Math Strength Carries Over: Even when stripping images, pre-training DeepSeek-Coder-1.3B on InfiMM-WebMath-40B text outperformed equivalent models trained on OpenWebMath and DeepSeekMath corpora on GSM8K (26.1% vs. 11.0% and 23.8%).

Key Results

  • MathVerse Benchmark: InfiMM-Math-7B achieved an overall score of 34.5%, outperforming all open-source models (including LLaVA-NeXT-110B at 24.5% and MAVIS-7B at 27.5%) and closed models like Gemini-Pro (23.5%), trailing only GPT-4V (39.4%).
  • We-Math Benchmark: InfiMM-Math-7B scored an average of 20.6%, surpassing InternLM-XC2 (12.7%) and Math-LLaVA (11.1%), while cutting Insufficient Knowledge (IK) errors down to 48.8%.

Limitations and Future Work

  • Vision-Only Reasoning Bottleneck: While the model excelled in text-dominant and vision-intense categories, performance dropped on "Vision-Only" questions (15.8% on MathVerse vs. 31.6% for GPT-4V). The authors attribute this to fixed image resolution ($384 \times 384$) and aggressive token compression (64 tokens per image via the Perceiver Resampler), which discards fine-grained visual details.
  • Language Scope: The current filtering pipeline discards everything outside English and Chinese. Expanding to multilingual mathematical corpora remains open for future iterations.

Summary updated

BibTeX
@inproceedings{han2024infimm,
  author = {Xiaotian Han and Yiren Jian and Xuefeng Hu and Haogeng Liu and Yiqi Wang and Qihang Fan and Yuang Ai and Huaibo Huang and Ran He and Zhenheng Yang and Quanzeng You},
  title = {{InfiMM-WebMath-40B: Advancing Multimodal Pre-Training for Enhanced Mathematical Reasoning}},
  booktitle = {MATH-AI @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=Twzrpa6V2o},
}
Figure