| --- |
| license: mit |
| task_categories: |
| - question-answering |
| language: |
| - en |
| tags: |
| - agent |
| --- |
| # Mathematics Stack Exchange Q&A Dataset |
|
|
| A curated dataset of question-and-answer pairs harvested from Mathematics Stack Exchange (math.stackexchange.com). Each entry contains the question, the top answer (if available), metadata (scores, tags, URL), and a combined Q/A text useful for training and evaluation of question-answering and tutoring models. |
|
|
| ## Dataset summary |
|
|
| - Source: Mathematics Stack Exchange (via the official Stack Exchange API) |
| - Content: High-quality Q&A pairs (question title + body, top answer body) |
| - Formats: CSV and JSON |
| - Typical fields: |
| - `question_id` (int) |
| - `question_title` (string) |
| - `question_body` (string, cleaned of HTML) |
| - `question_score` (int) |
| - `question_tags` (string, comma-separated) |
| - `question_url` (string) |
| - `answer_body` (string, cleaned of HTML; empty if no answer) |
| - `answer_score` (int) |
| - `answer_accepted` (bool) |
| - `combined_text` (string, "Q: <title>\n\n<body>\n\nA: <answer or placeholder>") |
| - `scraped_at` (ISO 8601 timestamp) |
|
|
| Example CSV header: |
| ``` |
| question_id,question_title,question_body,question_score,question_tags,question_url,answer_body,answer_score,answer_accepted,combined_text,scraped_at |
| ``` |
|
|
| ## License and attribution |
|
|
| Content in this dataset is user-contributed content from Stack Exchange and is licensed under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. |
|
|
| When using or redistributing the dataset, include attribution. A suggested attribution statement: |
|
|
| "Data from Mathematics Stack Exchange (math.stackexchange.com). Licensed under CC BY-SA 4.0." |
|
|
| Also include a link to the original question pages (the `question_url` field) when practical. |
|
|
|
|
| ## How the dataset was generated |
|
|
| The dataset was produced by a script that uses the official Stack Exchange API: |
|
|
| - Requests top-voted mathematics questions (configurable count) |
| - For each question, fetches the top answer (if any) |
| - Cleans HTML from bodies (HTML entities unescaped and tags removed), collapses whitespace |
| - Produces both CSV and JSON exports |
| - Respects rate limits and inserts polite delays |
|
|
| Notes: |
| - The generator script is not included in this repository. If you want to include it, add the script file (for example `scripts/generate_math_se_dataset.py`) and reference it here. |
| - For reproducibility, include the script, the exact arguments used, and the timestamp of generation. |
|
|
|
|
| ## Regenerating the dataset |
|
|
| Prerequisites: |
| - Python 3.8+ (or compatible) |
| - `requests` (for API calls) |
| - Optional: a Stack Exchange API key (recommended for higher rate limits) |
|
|
| Important considerations: |
| - Respect Stack Exchange API rate limits; use an API key if you will fetch many pages. |
| - The script should include backoff/retry and delays between requests; do not parallelize requests without careful rate-limit handling. |
| - If exporting large datasets, consider paging and storing intermediate results. |
|
|
|
|
| ## Data quality & known limitations |
|
|
| - Bodies are cleaned of HTML but some formatting (math markup, code blocks, LaTeX) may be simplified or lost; consider preserving LaTeX if you need formula fidelity. |
| - Only the top answer (by score) is captured — accepted vs. highest-scored may differ; both are recorded if available. |
| - Potential biases: |
| - Questions with higher votes and English-language questions are overrepresented if using a top-voted query. |
| - Highly specialized or duplicate content may appear. |
| - Empty `answer_body` means no answer was available at scraping time. |
| - Some fields may contain non-ASCII characters; files are exported with UTF-8 encoding. |
|
|
|
|
| ## Suggested preprocessing for ML |
|
|
| - Deduplicate entries by `question_id`. |
| - Normalize or preserve LaTeX as needed (consider using a LaTeX-aware tokenizer when training models that must understand formulas). |
| - Truncate or chunk very long texts (both question and answer) when fitting into model context windows. |
| - Optionally filter by tags for domain-specific datasets (e.g., `algebra`, `calculus`, `probability`). |
|
|
|
|
| ## Use cases |
|
|
| - Training and evaluating question-answering systems and math tutoring chatbots |
| - Fine-tuning language models on math Q&A patterns |
| - Research on problem-solving strategies and reasoning in mathematics |
| - Building retrieval-augmented systems with real Q&A examples |
|
|
|
|
| ## Privacy, ethics, and policy |
|
|
| - The dataset contains user-contributed content under CC BY-SA; comply with the license and provide attribution. |
| - Do not claim the content as your own; include proper attribution and linkbacks where practical. |
| - Avoid publishing personally identifiable information beyond what is already publicly available on Stack Exchange. |
|
|
|
|
| ## Citation |
|
|
| If you use this dataset in publications, we suggest citing it as: |
|
|
| Furkan Nar or https://github.com/TheOfficialFurkanNar/StackMathematics. (2026). Mathematics Stack Exchange Q&A Dataset. Retrieved from https://github.com/TheOfficialFurkanNar/StackMathematics (data originally from mathematics.stackexchange.com; licensed CC BY-SA 4.0) |
|
|
|
|
| ## Contact |
| Contact via: |
| furkannar168@hotmail.com |
| For questions about this dataset or generation script, open an issue in this repository or contact the maintainer. |
|
|
| ## Community & Support |
|
|
| Join the community to ask questions, discuss the dataset, and get help: |
|
|
| - Discord: https://discord.gg/dcjh8S5H |