StackMathQA
StackMathQA pulls together 2 million mathematical questions and their answers from across the Stack Exchange network, covering everything from basic arithmetic to research-level topics depending on the source community.
Because each item is already a self-contained question paired with one or more answers, the data maps cleanly onto retrieval: each entry is effectively a ready-made passage. That makes it a strong fit for Q&A-style RAG, where you want to surface a relevant worked answer rather than a page of reference text.
The dataset is hosted on Hugging Face under CC BY-SA 4.0, matching the licence of the underlying Stack Exchange content, so derivative databases must carry the same terms.
Related sources
AMPS
A dataset of informal mathematics introduced alongside the MATH benchmark. It includes more than 100,000 Khan Academy problems with step-by-step solutions in LaTeX and over 5 million problems generated with Mathematica scripts, totalling around 23 GB.
AutoMathText
Around 200 GB of mathematical text compiled from websites, arXiv, and GitHub, drawing on OpenWebMath, RedPajama, and AlgebraicStack. Every piece of content carries a score from 0 to 1 for relevance, quality, and educational value, labelled automatically by the Qwen-72B model.
Awesome AI Math Datasets
A community-curated list of open-source mathematics datasets for training and evaluating maths-capable language models. A useful index for finding newer additions in this space.
MegaMath
An open mathematics pretraining dataset curated from diverse, maths-focused sources, with over 300 billion tokens. Among the largest open maths corpora available.