StackMathQA
StackMathQA pulls together 2 million mathematical questions and their answers from across the Stack Exchange network, drawing on communities such as Mathematics, MathOverflow, Cross Validated (statistics), and others. Coverage runs from basic arithmetic to research-level topics depending on the source site, and the answers include the worked reasoning and LaTeX notation that make maths Q&A genuinely useful rather than just a final result.
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, which is why we mark its RAG readiness as chunked. 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. A good pattern is to embed the question text for matching, then return the top-voted answer as the grounding context.
Access is easy. The dataset lives on Hugging Face as `Parquet` files with several size configurations (from a compact subset up to the full 2 million pairs), so you can stream it with the `datasets` library and start with a smaller split while you prototype. That saves you the work of scraping and cleaning Stack Exchange dumps yourself.
A few things to watch. Community answers vary in quality, and although each question is paired with its answers, some carry more than one, so decide whether you index only the accepted or highest-voted answer or keep them all. The maths itself often depends on LaTeX rendering, which your chunking and display layers need to preserve. On licensing, StackMathQA is CC BY-SA 4.0, matching the underlying Stack Exchange content: commercial use is permitted, but attribution is required and the share-alike term means any derivative database you publish must carry the same licence. If you need broader mathematical text rather than tidy Q&A, pair it with corpora like AMPS or OpenWebMath.
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.