🤗 Dataset | 💻 Source Code | 🇨🇳 中文 README
UltraData-Math is a large-scale, high-quality mathematical pre-training dataset totaling 290B+ tokens across three progressive tiers—L1 (170.5B tokens web corpus), L2 (33.7B tokens quality-selected), and L3 (88B tokens multi-format refined)—designed to systematically enhance mathematical reasoning in LLMs. It has been applied to the mathematical pre-training of the MiniCPM Series models.
- 2026.02.09: Released UltraData-Math (290B+ tokens), a large-scale high-quality mathematical pre-training dataset with three progressive tiers (L1/L2-preview/L3).
High-quality pre-training data is crucial for enhancing the mathematical reasoning capabilities of large language models (LLMs). However, existing mathematical pre-training data construction schemes have the following shortcomings:
- HTML Parsing: General parsers (such as trafilatura, readability) are mainly designed for news/article parsing, lacking specialized processing for mathematical formulas and other content, often leading to formula structure destruction or loss; meanwhile, mathematical discussions on forum-like pages are difficult to extract completely.
- Data Quality: Existing datasets generally lack a systematic quality grading mechanism, with high-value mathematical content mixed with low-quality noise.
- Data Diversity: Mainstream datasets mostly originate from textbooks or competition question banks, lacking mathematical discussions and application scenarios in real web pages; synthetic data formats are single, difficult to cover diverse needs such as multi-turn dialogues and multi-style expressions.
To address these issues, we propose UltraData-Math—a large-scale high-quality pre-training dataset for mathematical reasoning tasks. This dataset is developed based on the UltraData L0-L4 Tiered Data Management Framework, containing four progressive levels:
- L0 Raw Data: Develops a mathematical parser based on magic-html, combined with w3m layout preservation rendering and multi-level fallback strategies, standardizing MathML, KaTeX, and AsciiMath into LaTeX format.
- L1 Filtered Data: Cleans noise through heuristic rules and performs document-level deduplication.
- L2 Selected Data: Uses proprietary large models to annotate seed data and distills it into a lightweight embedding classifier to achieve efficient quality grading of the full corpus.
- L3 Refined Data: Produces structured content with clear reasoning through rewriting, synthetic generation, and refinement in various formats such as Q&A, multi-turn dialogues, multi-style rewriting, and knowledge-grounded textbooks.
Experiments show that on the MiniCPM-1.2B architecture, UltraData-Math achieves a score of 37.02pp on the MATH500 benchmark, an improvement of +3.62pp compared to Nemotron-CC 4plus; it achieves 61.79pp on GSM8K, an improvement of +3.34pp, while maintaining code generation and general knowledge capabilities.
UltraData-Math has been applied to the mathematical pre-training of the MiniCPM Series models. This repository open-sources the core tools and configurations of the data processing pipeline.
- UltraData-Math-L1: Large-scale high-quality mathematical pre-training dataset, containing 170.5B tokens of web mathematical corpus.
- UltraData-Math-L2: High-quality mathematical pre-training dataset selected by the quality model, containing 33.7B tokens of high-quality web mathematical corpus.
- UltraData-Math-L3: High-quality refined mathematical dataset, containing 88B tokens of multi-format refined data (Q&A, multi-turn dialogues, knowledge textbooks, etc.).
To break through the limitations of existing mathematical datasets in quality and diversity, we established a refined grading standard centered on "mathematical content integrity" and "information density". UltraData-Math adopts the L0-L4 Tiered Data Management Framework proposed by the UltraData paper. Through standardized level definitions, it achieves orderly management and efficient flow of mathematical data assets. Each level represents higher data purity and mathematical value, while also corresponding to a more refined degree of processing.
| Level | Name | Function | Tool |
|---|---|---|---|
| L0 | Raw Data | HTML Math Parsing | UltraData-Math-L0-Parser |
| L1 | Filtered Data | Format Repair + Content Filtering | UltraData-Math-L1-Cleaner |
| L2 | Selected Data | Quality Classification Model Screening | UltraData-Math-L2-Selector |
| L3 | Refined Data | Multi-format Data Refinement | UltraData-Math-L3-Generator |
Definition: Initial data extracted from web sources like Common Crawl via parsers. Addressing the limitations of general HTML parsers in capturing mathematical formulas, we developed UltraData-Math-L0-Parser based on magic-html.
An enhanced HTML parser based on magic-html, optimized specifically for mathematical content extraction.
📊 Comparison with Original magic-html
| Feature | magic-html | UltraData-Math-L0-Parser |
|---|---|---|
| Unified Extraction Mode (UnifiedParser) | ❌ | ✅ Automatically identifies and merges scattered posts |
| Multi-level Fallback Strategy | ❌ | ✅ primary → wild_text → readability |
| Image LaTeX Intelligent Extraction | ❌ | ✅ Recovers formulas from alt attributes |
| Math Container Protection | ❌ | ✅ Protects <math> tags from accidental deletion |
| Configurable Table/Image | ❌ | ✅ include_tables / include_images |
✨ Core Features
1. UnifiedParser - Unified Extraction Mode
Merges extraction logic for Article and Forum, automatically adapting to different page types:
from ultradata_math_parser import GeneralParser
parser = GeneralParser()
result = parser.extract(html, base_url=url, html_type="unified")
# Returns: {html, title, text_length, fallback_strategy, forum_assembled}2. Multi-level Fallback Strategy
Automatically triggers a multi-level fallback chain when the main extracted content is insufficient, ensuring content integrity.
3. Mathematical Formula Format Standardization
Supports converting various mathematical formats into unified LaTeX, and intelligently recovers formulas from image alt attributes:
| Input Format | Conversion Method |
|---|---|
MathML (<math>) |
XSLT Conversion |
KaTeX (.katex) |
Extract annotation |
| AsciiMath | py-asciimath Conversion |
| LaTeX Image | Intelligent recovery from URL/alt |
\begin{equation} |
Direct Extraction |
Characteristics: Mathematical formulas are completely preserved, LaTeX format is unified, serving as the foundational layer resource for subsequent cleaning and screening.
Definition: Data cleaned through heuristic rules, with standardized text format and basic readability.
Processing Methods:
- Mapper (Format Repair): Cleans invisible characters, continuous line breaks, navigation bars/buttons, and other noisy text.
- Filter (Content Filtering): Filters short texts and texts with abnormal lengths.
Characteristics: Data noise is significantly reduced, format consistency is improved; see UltraData-Math-L1-Cleaner/README.md for details.
Definition: Data screened by quality assessment models, possessing high information density and mathematical educational value, with clear themes and coherent reasoning logic.
Processing Methods:
- Annotate seed data using proprietary large models.
- Distill into a lightweight embedding classifier to achieve efficient scoring of the full corpus.
- Multi-dimensional quality tags (mathematical depth, reasoning completeness, educational value).
Characteristics: Retains samples with high contribution to improving the model's mathematical reasoning ability, further reducing noise and significantly increasing mathematical content density. It is the core resource for the pre-training phase.
Definition: High-quality mathematical data that has undergone deep rewriting, synthesis, and refinement, with structured content, clear reasoning steps, and explicit educational intent, achieving textbook-quality standards.
Processing Methods:
- Q&A Format Generation (Question-Answer Pair with explicit reasoning steps)
- Multi-turn Dialogue Synthesis (Math Tutoring Scenario)
- Multi-style Rewriting (Textbook Style, Competition Style, Popular Science Style)
- Knowledge Point Textbook Generation (Generates textbook-style learning materials based on knowledge points)
- Format Repair and Enhancement (Fix broken LaTeX formulas, inconsistent notation, enhance content coherence)
Characteristics: Strong text readability, complete reasoning steps, standardized structure, high sample quality. It is the core resource for MidTraining and SFT phases.
We evaluated data quality using the Decay Verification method: continuing pre-training of a MiniCPM-1.2B base model (pre-trained on 1.3T tokens with MiniCPM3-4B tokenizer) with ~100B tokens (30% target data + 70% general data). We used OpenCompass as our evaluation framework. Evaluation benchmarks include:
- General English: MMLU, ARC-E, ARC-C, BigBench Hard (BBH), CommonSenseQA, HellaSwag, OpenbookQA, PIQA, SIQA, Winogrande
- General Chinese: C-Eval, CMMLU
- Math Reasoning: MATH500, GSM8K, Math-Bench, R-Bench-Math
- Code Reasoning: MBPP, HumanEval
To fairly compare different parsing strategies, we conducted experiments on a data subset sampled from the 2023-2024 distribution. We re-parsed the raw HTML from this source using different parsers. This comparison demonstrates the effectiveness of our L0 Parser against other parsers.
To validate the effectiveness of our L0-L3 tiered framework, we conducted ablation studies comparing models trained on different tiers of UltraData-Math. Unlike the L0 parser comparison above (which used a 2023-2024 subset), these results are based on the full dataset. Results demonstrate that higher-tier data (L3) significantly boosts mathematical reasoning (MATH500, GSM8K) and general capabilities.
To compare against existing public mathematical pre-training datasets, we trained models independently on each dataset using the same model architecture and training budget (~100B tokens). The baselines include Nemotron-CC-Math, MegaMath-Web-Pro, and FineMath. All models are evaluated under identical conditions for a fair comparison:
- L0 Parsing Layer: magic-html, w3m, trafilatura
- L3 Refined Layer: Qwen2.5-72B-Instruct, Qwen3-32B, GLM-4.5
- Seed Data: Nemotron-CC-Math, MegaMath, FineMath
If you find UltraData-Math useful in your research, please consider citing:
@misc{ultradata-math,
title={UltraData-Math},
author={Chuyue Zhou and Hongya Lyu and Xinle Lin and Hengyu Zhao and Junshao Guo and Xueren Zhang and Shuaikang Xue and Qiang Ma and Jie Zhou and Yudong Wang and Zhiyuan Liu},
year={2026},
url={https://huggingface.co/datasets/openbmb/UltraData-Math},
publisher={Hugging Face}
}This project is licensed under the Apache 2.0 license.




