Source-linked AI summary

MathPile: A Billion-Token-Scale Pretraining Corpus for Math

Zengzhi Wang, Xuefeng Li, Rui Xia, Pengfei Liu

arXiv:2312.17120v2cs.CLcs.AIcs.LG

TL;DR

The paper addresses the lack of an open, broad math-focused pre-training corpus. It constructs MATHPILE through diverse-source collection and careful processing, and reports improved mathematical reasoning benchmark performance in continual pre-training. The authors aim for the corpus to support mathematical reasoning in language models.

  • Problem

    Open pre-training corpora largely focus on general, multilingual, or programming domains, while existing math-focused resources are unavailable openly or limited in scope.

    Source: §1 · p. 1
  • Method

    The authors construct MATHPILE from diverse mathematical sources using source-specific preprocessing and filtering, global cleaning and deduplication, and benchmark contamination checks.

    Source: §1 · p. 2, §6 · p. 9
  • Results

    Continual pre-training with MATHPILE generally improved performance across mathematical reasoning benchmarks, with average improvement up to 5%.

    Source: §1 · p. 2
  • Takeaways & Limitations

    The authors aim for MATHPILE to enhance mathematical reasoning in language models.

    Source: §6 · p. 9

    The dataset is primarily English-focused, and its scale is insufficient for training extra-large models.

    Source: §6 · p. 9

Abstract

from arXiv · show

High-quality, large-scale corpora are the cornerstone of building foundation models. In this work, we introduce MathPile, a diverse and high-quality math-centric corpus comprising about 9.5 billion tokens. Throughout its creation, we adhered to the principle of "less is more", firmly believing in the supremacy of data quality over quantity, even in the pre-training phase. Our meticulous data collection and processing efforts included a complex suite of preprocessing, prefiltering, language identification, cleaning, filtering, and deduplication, ensuring the high quality of our corpus. Furthermore, we performed data contamination detection on downstream benchmark test sets to eliminate duplicates and conducted continual pre-training experiments, booting the performance on common mathematical reasoning benchmarks. We aim for our MathPile to boost language models' mathematical reasoning abilities and open-source its different versions and processing scripts to advance the field.

1 Introduction

Continual pre-training with MATHPILE generally improved language-model performance across mathematical reasoning benchmarks. The corpus addresses the lack of an open, broad math-focused pre-training resource through diverse sources, quality processing, and documentation.

  • Existing open corpora generally target other domains, while some math-specific training corpora are not open-sourced and OpenWebMath draws only from web pages.Source: §1 · pp. 1–2
  • MATHPILE combines textbooks, lecture notes, mathematics arXiv papers, and selected web and community sources, extending beyond web pages and formal proving.Source: §1 · p. 2
  • The corpus applies source-specific preprocessing and prefiltering before global language identification, filtering, cleaning, and deduplication, and documents quality annotations and contamination checks.Source: §1 · p. 2
  • Up to 5% average improvement was observed across mathematical reasoning benchmarks in continual pre-training experiments with MATHPILE.Source: §1 · p. 2

2 The Collection of Corpora

MATHPILE is assembled from varied mathematical sources using source-specific collection and cleaning procedures. Its collection includes conventional educational and research materials, reference and discussion sources, synthetic textbooks, and extracted web pages.

  • Textbook collection combines 38 K-12 and 369 college-level textbooks with 467 course handouts or lecture notes, producing 874 documents after parsing and cleaning.Source: §2 · p. 3
  • OpenPhi synthetic textbooks were filtered using $$ alongside common mathematical-expression markers, yielding 3,889 documents from 124,493.Source: §2 · p. 3
  • The corpus includes 347,945 cleaned arXiv LaTeX papers, about 8.5 billion tokens, selected from 50 sub-subjects across six fields.Source: §2 · p. 3
  • Other collected sources include 106,881 English mathematical Wikipedia entries, ProofWiki definitions and theorem-proof pairs, and quality-filtered StackExchange discussions.The reported collections include about 0.8 billion Wikipedia tokens, 7.6 million ProofWiki tokens, and 254 million StackExchange tokens.Source: §2 · p. 4
  • Rule-based extraction yielded 4,307 SlimPajama-C4 and 72,137 SlimPajama-CommonCrawl documents, totaling about 633 million tokens.Source: §2 · p. 5

3 Global Data Processing

Global processing applies language identification, domain-specific cleaning and filtering, deduplication, and benchmark contamination detection. These steps remove low-quality or repeated material while retaining content whose structure is meaningful, such as distinct ProofWiki entries.

3 Global Data Processing

  • The global workflow follows source-specific preprocessing with language identification, filtering, and deduplication across the corpus.Source: §3 · p. 5

3.1 Language Identification

  • Custom language-identification thresholds addressed false non-English classifications caused by mathematical symbols and removed about 8,400 documents, totaling 231 million tokens.Thresholds were 0.1 for Wikipedia and StackExchange, 0.3 for arXiv, and 0.5 for Common Crawl; none were used for manually verified ProofWiki and Textbooks.Source: §3.1 · p. 5

3.2 Data Cleaning and Filtering

  • Domain-specific cleaning and filtering assigned quality annotations to Wikipedia and Common Crawl documents and removed about 1,100 documents, or 17 million tokens.Source: §3.2 · p. 6

3.3 Data Deduplication

  • About 714 million tokens were eliminated by deduplication; ProofWiki near-duplicates were retained when they represented distinct lemmas, proofs, or definitions.Source: §3.3 · p. 6

3.4 Data Contamination Detection

  • The benchmark scan found 23 MATH and 2 MMLU-STEM questions, no contamination in other benchmarks, and removed all detected exact matches.Questions were checked through line-level exact matching; benchmark answers were included except for multiple-choice tests where only questions were used.Source: §3.4 · pp. 6–7

4 Data Analysis

MATHPILE yields a 29GB, 9.5-billion-token corpus from 2.2TB of raw data, with source-specific document-length patterns. Continual pre-training experiments find that processing quality and data source matter, with benefits varying across benchmarks.

4.1 Statistics

  • 9.5 billion tokens in 29GB of corpus were obtained from 2.2TB of raw data; arXiv is the largest component and Textbooks the smallest, though exceptionally high-quality.Table 3 presents component statistics including document and token counts.Source: §4.1 · p. 7, Table 3 · p. 7
  • Document-length distributions are relatively smooth across sources; arXiv and Textbooks documents tend to be longer, while ProofWiki and StackExchange documents tend to be shorter.ProofWiki has many similar-length, short documents because its definitions, lemmas, and proofs follow a fixed format.Source: §4.1 · p. 7, Figure 3 · p. 7

4.2 Continual Pre-training Experiments

  • Continual pre-training used Mistral-7B-v0.1 for three epochs with 4,096-token chunks and evaluated six math benchmarks using the same few-shot prompting and greedy decoding.The experiments used a global batch size of 1,024 and a maximum learning rate of 1e-5.Source: §4.2 · pp. 7–8
  • MathPile subsets generally improved diverse math benchmarks, but StackExchange did not improve GSM8K and arXiv slightly improved GSM8K and MMLU-MATH while degrading MATH, SAT-MATH, and MathQA.Textbooks, Wikipedia, StackExchange, and CC improved GSM8K and MATH, but not the other benchmarks.Source: §4.2 · p. 8
  • AMPS and DM-Mathematics pre-training degraded performance, while sampled OpenWebMath improved less than same- or smaller-scale Textbooks and Wikipedia subsets.The authors attribute the synthetic-set result to narrow, monotonous problem sets and suggest such datasets generally work better combined with broader corpora; they suggest OpenWebMath may need more tokens for substantial gains.Source: §4.2 · p. 8, Table 4 · p. 8
  • A 10-billion-token, one-epoch pre-training run requires approximately 1,760 NVIDIA A100 GPU-hours, constraining further experiments.The authors cite limited computational resources as the reason they did not extensively test the entire dataset or data combinations.Source: §4.2 · p. 8
  • Skipping the processing pipeline reduced Mistral’s mathematical reasoning abilities even at 2.18B training size, and correct LaTeX displays were vital for enhancing reasoning.The Wikipedia testbed compared raw and cleaned data and problematic versus correct LaTeX displays.Source: §4.2 · pp. 8–9, Table 5 · p. 8

5 Related Work

Prior pre-training corpora range from broad general-domain and web collections to specialized code or multilingual resources. Math reasoning corpora address different levels and tasks, while MATHPILE focuses on a diverse, high-quality mathematical corpus.

Pre-training Corpora for Language Models

  • Language-model corpora include broad collections such as Pile, web-focused datasets such as C4, and specialized multilingual or code datasets such as ROOTS and The Stack.Some large corpora and data used by recent models are closed-source, while RedPajama and SlimPajama release corpora.Source: §5 · p. 9

Pre-training Benchmarks and Corpora for Mathematical Reasoning

  • Mathematical resources span arithmetic-to-competition benchmarks and corpora targeting problem-solving or theorem proving, while MATHPILE aims to fill gaps with a high-quality, diverse mathematical corpus.The related work contrasts public resources such as AMPS, ProofPile, and OpenWebMath with Minerva and MathMix, which are not public.Source: §5 · p. 9

6 Conclusion and Limitations

MATHPILE is a diverse, high-quality math-centered corpus built with a multi-stage processing pipeline and benchmark-contamination detection. Its scale, empirical design decisions, and English focus constrain the dataset’s scope.

6 Conclusion and Limitations

  • MATHPILE combines diverse mathematical sources with preprocessing, prefiltering, language identification, cleaning, filtering, deduplication, and benchmark-test contamination detection.The authors aim for the corpus to enhance mathematical reasoning in language models, alone or with other datasets.Source: §6 · p. 9
  • Creation decisions were made empirically and may not be optimal; the dataset is too small for extra-large-model training and is primarily English.The authors identify expanding common-crawl subsets, building high-quality datasets for other languages, data mixing, and model-based corpus refinement as future directions.Source: §6 · p. 9

Checklist

The checklist records that limitations were discussed and reproduction materials, training details, and compute information were provided, but error bars and potential negative societal impacts were not reported.

Checklist

  • The checklist says the paper discussed limitations and potential negative societal impacts were not discussed.Source: Checklist · p. 18
  • The checklist reports that code, data, reproduction instructions, training details, and compute resources were provided, but error bars were not reported.Source: Checklist · p. 18
  • The checklist marks the estimated participant wage and total compensation as not applicable.Source: Checklist · p. 18

A MATHPILE Datasheet

MATHPILE was created to expand open access to math-focused pretraining data and support mathematical language modeling. It is intended for use alone or alongside general-domain corpora.

MOTIVATION

  • MATHPILE aims to enrich the open-source community with a math-centric pretraining dataset.Source: MOTIVATION · p. 20
  • The dataset is intended to enhance mathematical language modeling.Source: MOTIVATION · p. 20
  • MATHPILE can be used alone or together with general-domain corpora such as books and GitHub code.Source: MOTIVATION · p. 20

COMPOSITION

MATHPILE is a text-only collection of math-focused documents from varied sources, totaling about 903,000 documents and 9.5 billion tokens. The dataset was collected and processed through multiple stages, released through HuggingFace Hub, and has acknowledged quality and language-scope limitations.

COMPOSITION

  • Instances are text-only math-focused documents, including papers, textbooks, lecture notes, definitions, theorems, proofs, articles, Q&A, and webpages.Source: COMPOSITION · p. 20
  • About 903,000 documents and 9.5 billion tokens comprise MATHPILE.Source: COMPOSITION · p. 20

PREPROCESSING

  • Some documents, particularly web-sourced ones, may still fall short of the dataset’s quality standards.Source: COMPOSITION · p. 21

COLLECTION

  • Textbooks were manually collected with quality checks, while data also came primarily from arXiv and the Internet Archive; Common Crawl data came from SlimPajama.Source: COLLECTION · p. 21

PREPROCESSING

  • Processing included language identification, cleaning, filtering, deduplication, benchmark leakage detection, and removal of identified contaminated examples.Source: PREPROCESSING · p. 22
  • MATHPILE is tailored for English, limiting its applicability in multilingual contexts, and imperfect cleaning may exclude valuable documents.Source: PREPROCESSING · p. 22

DISTRIBUTION

MAINTENANCE

B Ethics Statement

The ethics statement describes the dataset’s licensing approach and acknowledges that explicit consent was not obtained from every author. The authors describe measures to manage copyright concerns and accept responsibility for potential rights or licensing violations.

B Ethics Statement

  • MATHPILE follows source licenses when they are more restrictive than CC BY-NC-SA 4.0; otherwise, the released dataset uses CC BY-NC-SA 4.0.Source: B Ethics Statement · p. 24
  • The authors did not obtain explicit consent from every author for some collected materials, including publicly available open-source textbooks, and acknowledge potential copyright issues.Source: B Ethics Statement · p. 24
  • To mitigate risks, the authors prioritize clearly open-licensed or public-domain sources, invoke fair-use principles for some copyrighted or non-commercial material, and accept removal requests.Source: B Ethics Statement · p. 24
  • The authors state that they bear full responsibility for potential violations of rights or licensing issues arising from the dataset.Source: B Ethics Statement · p. 24

C Examples of MATHPILE

The appendices illustrate MathPile documents from multiple source types and provide examples of collection, processing, quality annotation, deduplication, and contamination detection.

C Examples of MATHPILE

D Details for Corpus Collection and Processing

E Example for Quality Annotation

F Examples of Duplicates Encountered in the Deduplication Process

G Evaluation of Continal Pre-trained Models on General Langauge Benchmarks

The authors evaluate continual pre-training on MathPile subsets against general-language benchmarks. They report no significant degradation overall, with some benchmark improvements and slight declines on some metrics.

G Evaluation of Continal Pre-trained Models on General Langauge Benchmarks

  • The evaluation reports accuracy (acc norm) on PIQA, ARC-Easy, ARC-Challenge, SciQ, and HellaSwag.The experiments used EleutherAI’s lm-evaluation-harness.Source: G Evaluation of Continal Pre-trained… · p. 43
  • General-language abilities showed no significant degradation after continual pre-training on MathPile subsets, with some benchmark improvements and slight metric declines.The authors note that these experiments used math-specific data exclusively and did not necessarily expect general-benchmark improvements.Source: G Evaluation of Continal Pre-trained… · p. 43, Table 20 · p. 43
Loading 2312.17120v2…