Download cards.py from sandysanta/stem-cot-sft: direct link, hf CLI and curl.
- Browser
- Download file 8.62 kB
-
https://huggingface.co/datasets/sandysanta/stem-cot-sft/resolve/main/cards.py
- Command line
-
hf download hf://datasets/sandysanta/stem-cot-sft/cards.py
-
curl -L -o cards.py https://huggingface.co/datasets/sandysanta/stem-cot-sft/resolve/main/cards.py
8.62 kB
| """Dataset card generator for dsb.py.""" | |
| U = "sandysanta" | |
| DECON = ("**Benchmark decontamination:** documents sharing any 13-word overlap with the test questions/answers of GSM8K, MATH (all 7 subjects), MMLU (all) or " | |
| "ARC (Challenge+Easy) were removed (checked at stride {st}). Test items shorter than 13 words are not covered, and this is not a guarantee of zero leakage.") | |
| DEDUPE = "**Deduplication:** exact (normalized-text MD5) across all sources and configs. There is **no fuzzy/near-duplicate removal**, so near-identical documents can remain." | |
| PRIV = "Publication status: private until the owner reviews it. The `license: other` header means *mixed, see the per-source table*, not a new license on the content." | |
| def table(stats, cols=("kept", "chars")): | |
| rows = ["| Source key | Config | Rows kept | ~Tokens (chars/4) | Scanned | Decontaminated | Exact duplicates |", "|---|---|---|---|---|---|---|"] | |
| for k, v in stats.items(): | |
| rows.append(f"| `{k}` | `{v['cfg']}` | {v.get('kept', 0):,} | {v.get('chars', 0) // 4:,} | {v.get('scanned', 0):,} | {v.get('decontaminated', 0):,} | {v.get('duplicates', 0):,} |") | |
| return "\n".join(rows) | |
| def yaml(title, counts, lic, tags, task="text-generation"): | |
| cfgs = "\n".join(f"- config_name: {c}\n" + (" default: true\n" if i == 0 else "") + f" data_files:\n - {{split: train, path: \"data/{c}/train-*.parquet\"}}" for i, c in enumerate(counts)) | |
| return f"---\nlicense: {lic}\npretty_name: {title}\nlanguage: [en]\ntask_categories: [{task}]\ntags: [{', '.join(tags)}]\nconfigs:\n{cfgs}\n---\n" | |
| def card(which, repo, stats, counts): | |
| tot = sum(v.get("kept", 0) for v in stats.values()); tok = sum(v.get("chars", 0) for v in stats.values()) // 4 | |
| cfgs = "\n".join(f"| `{c}` | {n:,} |" for c, n in counts.items()) | |
| head = f"\n# {repo}\n\n**{tot:,} rows, about {tok / 1e9:.2f}B tokens (chars/4 estimate).** A filtered, deduplicated, decontaminated compilation of existing public datasets. This is a compilation: the content belongs to its original sources and keeps their licenses (see below). What is added here is the selection, filtering and cleaning.\n\n| Config | Rows |\n|---|---|\n{cfgs}\n\n" | |
| if which == "stem": | |
| return yaml("STEM Text Corpus", counts, "other", ["stem", "math", "science", "pretraining", "compilation"]) + head + f"""## Sources and licenses | |
| {table(stats)} | |
| | Source | Upstream | License as stated | | |
| |---|---|---| | |
| | `open-web-math` | [open-web-math/open-web-math](https://huggingface.co/datasets/open-web-math/open-web-math) | ODC-By 1.0 per the paper (card has no license field) | | |
| | `finemath-4plus` | [HuggingFaceTB/finemath](https://huggingface.co/datasets/HuggingFaceTB/finemath) | ODC-By 1.0 | | |
| | `cosmopedia-v2` | [HuggingFaceTB/smollm-corpus](https://huggingface.co/datasets/HuggingFaceTB/smollm-corpus) | ODC-By 1.0 (synthetic text generated with Mixtral) | | |
| | `fineweb-edu` | [HuggingFaceFW/fineweb-edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) `sample-10BT` | ODC-By 1.0 (web text; source pages keep their own rights) | | |
| | `stackexchange/*` | [common-pile/stackexchange](https://huggingface.co/datasets/common-pile/stackexchange) | **CC BY-SA** (share-alike): kept in its own config, `sharealike` | | |
| ## Columns | |
| `text`, `source`, `license`, `subject` (math / physics / chemistry / biology / cs / eng / earth), `url`, `n_chars`. | |
| ## How it was built | |
| - **STEM filter (heuristic):** for general sources (FineWeb-Edu, Cosmopedia, Stack Exchange sites) a vocabulary-density score picks STEM text; thresholds were tuned by inspecting score distributions. `subject` is the subject with the most vocabulary hits, **not a trained classifier or human label**, so expect errors (e.g. biology/medical overlap). OpenWebMath and FineMath were already math-focused and are kept whole after length filtering. | |
| - Stack Exchange: only STEM sites, capped at 25,000 posts per site. | |
| - {DECON.format(st=4)} | |
| - {DEDUPE} | |
| - Only a slice of each upstream dataset is included (see "Scanned" and the caps in `build_script.py`). | |
| ## Limitations | |
| Web text may contain personal information, errors and unsafe content; nothing here is fact-checked. FineWeb-Edu rows come from one 10B-token sample, not the full dataset. Share-alike (`sharealike` config) and ODC-By terms require attribution; check each source before commercial use. | |
| {PRIV} | |
| """ | |
| if which == "wiki": | |
| return yaml("Wikipedia STEM", counts, "cc-by-sa-3.0", ["wikipedia", "stem", "science", "math"]) + head + f"""## Source | |
| English Wikipedia, 20231101 dump via [wikimedia/wikipedia](https://huggingface.co/datasets/wikimedia/wikipedia). Text is under **CC BY-SA 3.0 and GFDL**; this derived dataset must stay under the same share-alike terms, and you must attribute Wikipedia and its contributors (`url` points to each article's page and history). | |
| {table(stats)} | |
| ## Columns | |
| `id`, `title`, `url`, `text`, `subject`, `stem_score`, `n_chars`, `license`. | |
| ## How it was built | |
| - Kept articles of at least 1,500 characters, excluding "List of ..." and disambiguation pages. | |
| - **STEM selection (heuristic):** a vocabulary-density score (`stem_score`, STEM terms per 1,000 words) with a threshold of 18, tuned on a sample. `subject` is the best-matching vocabulary group, not a human label. Some false positives (e.g. technology/product pages) and false negatives (STEM biography pages with little technical vocabulary) occur. | |
| - **No LaTeX:** the Hugging Face Wikipedia dump strips mathematical markup, so formulas are missing from the text. | |
| - {DECON.format(st=4)} | |
| - {DEDUPE} | |
| {PRIV} | |
| """ | |
| if which == "cot": | |
| return yaml("STEM Chain-of-Thought SFT", counts, "other", ["math", "science", "chain-of-thought", "sft", "instruction", "compilation"]) + head + f"""## Sources, generators and licenses | |
| {table(stats)} | |
| | Source | Upstream | License | Generated by | | |
| |---|---|---|---| | |
| | `numina-cot/*` | [AI-MO/NuminaMath-CoT](https://huggingface.co/datasets/AI-MO/NuminaMath-CoT) | Apache-2.0 | GPT-4o | | |
| | `metamathqa/*` | [meta-math/MetaMathQA](https://huggingface.co/datasets/meta-math/MetaMathQA) | MIT | GPT-3.5-turbo | | |
| | `orca-math-200k` | [microsoft/orca-math-word-problems-200k](https://huggingface.co/datasets/microsoft/orca-math-word-problems-200k) | MIT | GPT-4-Turbo | | |
| | `openmathinstruct-2/*` | [nvidia/OpenMathInstruct-2](https://huggingface.co/datasets/nvidia/OpenMathInstruct-2) (first 300k of `train_1M`) | CC-BY-4.0 | Llama-3.1-405B-Instruct | | |
| | `mathinstruct-cot` | [TIGER-Lab/MathInstruct](https://huggingface.co/datasets/TIGER-Lab/MathInstruct) | MIT | mixed | | |
| | `scienceqa-text` | [derek-thomas/ScienceQA](https://huggingface.co/datasets/derek-thomas/ScienceQA) (text-only rows) | CC-BY-SA-4.0 | human | | |
| **Model-generated data carries the generator's terms.** Much of this set was written by OpenAI models (OpenAI's terms restrict using outputs to develop competing models) and by Llama-3.1 (Llama license, attribution required). Check those terms before commercial use. Configs: `permissive` and `sharealike` (ScienceQA). | |
| ## Columns | |
| `messages` (list of `{{role, content}}`: one user turn, one assistant turn), `source`, `license`, `generated_by`, `subject`, `has_code`, `n_chars`. | |
| ## How it was built | |
| - Unified chat format. MathInstruct program-of-thought rows and any row containing code were dropped (the focus is natural-language reasoning). | |
| - **Answers are not verified.** Solutions are model-generated and can be wrong. | |
| - {DECON.format(st=1)} (applied to the problem text.) | |
| - {DEDUPE} | |
| {PRIV} | |
| """ | |
| return yaml("Planning and Advice Instructions", counts, "other", ["instruction", "planning", "reasoning", "sft", "compilation"], "text-generation") + head + f"""## Source and license | |
| {table(stats)} | |
| Filtered from [argilla/magpie-ultra-v1.0](https://huggingface.co/datasets/argilla/magpie-ultra-v1.0) (the card has no license field). The conversations were generated with **Llama-3.1-405B-Instruct**, so the **Llama 3.1 Community License** applies (attribution "Built with Llama"; models trained on this data and distributed may be subject to its naming requirement). Check the terms before commercial use. | |
| ## Columns | |
| `messages` (list of `{{role, content}}`), `tag` (Magpie `primary_tag`), `difficulty`, `quality`, `source`, `license`, `generated_by`, `n_chars`. | |
| ## How it was built | |
| - Kept conversations tagged Planning, Advice seeking, Brainstorming or Reasoning with quality *good* or *excellent*, not flagged unsafe, with caps per tag (100k / 60k / 50k / 50k). | |
| - Original model answers are kept as-is (they are not in a fixed Goal/Steps/Risks template). | |
| - {DECON.format(st=1)} | |
| - {DEDUPE} | |
| {PRIV} | |
| """ | |