Initial release (private)
Browse files- README.md +56 -0
- build_script.py +307 -0
- build_stats.json +42 -0
- cards.py +111 -0
- data/core/train-00000.parquet +3 -0
- data/core/train-00001.parquet +3 -0
- data/core/train-00002.parquet +3 -0
- data/core/train-00003.parquet +3 -0
- data/core/train-00004.parquet +3 -0
- data/core/train-00005.parquet +3 -0
- data/core/train-00006.parquet +3 -0
- data/core/train-00007.parquet +3 -0
- data/core/train-00008.parquet +3 -0
- data/core/train-00009.parquet +3 -0
- data/core/train-00010.parquet +3 -0
- data/core/train-00011.parquet +3 -0
- data/core/train-00012.parquet +3 -0
- data/core/train-00013.parquet +3 -0
- data/core/train-00014.parquet +3 -0
- data/core/train-00015.parquet +3 -0
- data/core/train-00016.parquet +3 -0
- data/core/train-00017.parquet +3 -0
- data/core/train-00018.parquet +3 -0
- data/core/train-00019.parquet +3 -0
- data/core/train-00020.parquet +3 -0
- data/sharealike/train-00000.parquet +3 -0
- data/sharealike/train-00001.parquet +3 -0
- data/sharealike/train-00002.parquet +3 -0
- data/sharealike/train-00003.parquet +3 -0
- data/sharealike/train-00004.parquet +3 -0
README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
pretty_name: STEM Text Corpus
|
| 4 |
+
language: [en]
|
| 5 |
+
task_categories: [text-generation]
|
| 6 |
+
tags: [stem, math, science, pretraining, compilation]
|
| 7 |
+
configs:
|
| 8 |
+
- config_name: core
|
| 9 |
+
default: true
|
| 10 |
+
data_files:
|
| 11 |
+
- {split: train, path: "data/core/train-*.parquet"}
|
| 12 |
+
- config_name: sharealike
|
| 13 |
+
data_files:
|
| 14 |
+
- {split: train, path: "data/sharealike/train-*.parquet"}
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# stem-text-corpus
|
| 18 |
+
|
| 19 |
+
**1,169,612 rows, about 1.52B 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.
|
| 20 |
+
|
| 21 |
+
| Config | Rows |
|
| 22 |
+
|---|---|
|
| 23 |
+
| `core` | 869,612 |
|
| 24 |
+
| `sharealike` | 300,000 |
|
| 25 |
+
|
| 26 |
+
## Sources and licenses
|
| 27 |
+
| Source key | Config | Rows kept | ~Tokens (chars/4) | Scanned | Decontaminated | Exact duplicates |
|
| 28 |
+
|---|---|---|---|---|---|---|
|
| 29 |
+
| `owm` | `core` | 300,000 | 590,362,965 | 312,200 | 1,722 | 32 |
|
| 30 |
+
| `finemath` | `core` | 300,000 | 377,334,223 | 307,800 | 2,182 | 1,916 |
|
| 31 |
+
| `cosmo` | `core` | 69,612 | 75,579,072 | 1,500,000 | 74 | 499 |
|
| 32 |
+
| `fweb` | `core` | 200,000 | 217,600,010 | 2,485,200 | 42 | 2,014 |
|
| 33 |
+
| `se` | `sharealike` | 300,000 | 263,377,534 | 5,233,000 | 5,186 | 1,992 |
|
| 34 |
+
|
| 35 |
+
| Source | Upstream | License as stated |
|
| 36 |
+
|---|---|---|
|
| 37 |
+
| `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) |
|
| 38 |
+
| `finemath-4plus` | [HuggingFaceTB/finemath](https://huggingface.co/datasets/HuggingFaceTB/finemath) | ODC-By 1.0 |
|
| 39 |
+
| `cosmopedia-v2` | [HuggingFaceTB/smollm-corpus](https://huggingface.co/datasets/HuggingFaceTB/smollm-corpus) | ODC-By 1.0 (synthetic text generated with Mixtral) |
|
| 40 |
+
| `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) |
|
| 41 |
+
| `stackexchange/*` | [common-pile/stackexchange](https://huggingface.co/datasets/common-pile/stackexchange) | **CC BY-SA** (share-alike): kept in its own config, `sharealike` |
|
| 42 |
+
|
| 43 |
+
## Columns
|
| 44 |
+
`text`, `source`, `license`, `subject` (math / physics / chemistry / biology / cs / eng / earth), `url`, `n_chars`.
|
| 45 |
+
|
| 46 |
+
## How it was built
|
| 47 |
+
- **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.
|
| 48 |
+
- Stack Exchange: only STEM sites, capped at 25,000 posts per site.
|
| 49 |
+
- **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 4). Test items shorter than 13 words are not covered, and this is not a guarantee of zero leakage.
|
| 50 |
+
- **Deduplication:** exact (normalized-text MD5) across all sources and configs. There is **no fuzzy/near-duplicate removal**, so near-identical documents can remain.
|
| 51 |
+
- Only a slice of each upstream dataset is included (see "Scanned" and the caps in `build_script.py`).
|
| 52 |
+
|
| 53 |
+
## Limitations
|
| 54 |
+
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.
|
| 55 |
+
|
| 56 |
+
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.
|
build_script.py
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Text dataset compilations -> private HF repos under sandysanta.
|
| 2 |
+
python dsb.py {calib|stem|wiki|cot|plan} [limit] (limit>0: tiny dry run, writes locally, no upload)
|
| 3 |
+
Pipeline per source: stream -> adapt/filter -> 13-gram decontamination vs GSM8K/MATH/MMLU/ARC test -> exact dedupe -> parquet shards by license config."""
|
| 4 |
+
import os, sys, re, json, hashlib, itertools, collections, shutil
|
| 5 |
+
from multiprocessing import Pool
|
| 6 |
+
import pyarrow as pa, pyarrow.parquet as pq
|
| 7 |
+
from datasets import load_dataset
|
| 8 |
+
from huggingface_hub import HfApi
|
| 9 |
+
|
| 10 |
+
WHICH = sys.argv[1] if len(sys.argv) > 1 else "calib"
|
| 11 |
+
LIMIT = int(sys.argv[2]) if len(sys.argv) > 2 else 0
|
| 12 |
+
USER, WORKERS = "sandysanta", 4
|
| 13 |
+
WRE = re.compile(r"[a-z0-9]+")
|
| 14 |
+
words = lambda t: WRE.findall(t.lower())
|
| 15 |
+
|
| 16 |
+
# ---------------- STEM vocabulary scoring (heuristic, not a trained classifier) ----------------
|
| 17 |
+
VOCAB = {
|
| 18 |
+
"math": "theorem lemma proof corollary polynomial integral derivative matrix eigenvalue eigenvector calculus algebra geometry topology probability combinatorics prime modulo equation inequality logarithm trigonometric sine cosine tangent hypotenuse axiom conjecture manifold homomorphism isomorphic isomorphism convergence converges differentiable continuous bijection subgroup commutative abelian cardinality supremum infimum permutation determinant coefficient quadratic",
|
| 19 |
+
"physics": "quantum photon electron proton neutron momentum velocity acceleration thermodynamics entropy relativity gravitational electromagnetic wavelength frequency hamiltonian lagrangian boson fermion nuclear particle newton joule voltage magnetic oscillator spectrum kinetic torque friction inertia refraction diffraction superconductor plasma",
|
| 20 |
+
"chemistry": "molecule atom ion bond reaction catalyst organic compound solvent acid oxidation reduction polymer titration molar stoichiometry isomer covalent ionic equilibrium synthesis spectroscopy electronegativity alkane alkene benzene reagent precipitate",
|
| 21 |
+
"biology": "protein gene dna rna genome mutation evolution species organism enzyme metabolism membrane chromosome ecosystem photosynthesis mitochondria bacteria virus neuron hormone tissue taxonomy phylogenetic allele genotype phenotype ribosome cytoplasm",
|
| 22 |
+
"cs": "algorithm complexity compiler runtime recursion sorting hashing database cryptography encryption neural bitwise polynomial-time automaton turing heap pointer asymptotic complexity-class pseudocode",
|
| 23 |
+
"eng": "circuit transistor resistor capacitor inductor amplifier impedance semiconductor stress strain thermal turbulence controller sensor voltage resistance bandwidth modulation",
|
| 24 |
+
"earth": "geology tectonic seismic climate atmosphere glacier mineral sediment volcano orbit planet galaxy telescope astronomy cosmology exoplanet stellar supernova",
|
| 25 |
+
}
|
| 26 |
+
ALL = {}
|
| 27 |
+
for _s, _v in VOCAB.items():
|
| 28 |
+
for _w in _v.split():
|
| 29 |
+
ALL.setdefault(_w, _s)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def stem_score(text, nw=3000):
|
| 33 |
+
"""(STEM-term density per 1000 words, best subject)."""
|
| 34 |
+
w = words(text[:30000])[:nw]
|
| 35 |
+
if len(w) < 50: return 0.0, "none"
|
| 36 |
+
c = collections.Counter()
|
| 37 |
+
for x in w:
|
| 38 |
+
s = ALL.get(x) or (ALL.get(x[:-1]) if x.endswith("s") else None)
|
| 39 |
+
if s: c[s] += 1
|
| 40 |
+
n = sum(c.values())
|
| 41 |
+
return 1000.0 * n / len(w), (c.most_common(1)[0][0] if c else "none")
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
# ---------------- benchmark decontamination (13-gram overlap) ----------------
|
| 45 |
+
NG, H = 13, set()
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def build_H():
|
| 49 |
+
def add(t):
|
| 50 |
+
w = words(t)
|
| 51 |
+
for i in range(max(1, len(w) - NG + 1)): H.add(hash(" ".join(w[i:i + NG])))
|
| 52 |
+
for r in load_dataset("openai/gsm8k", "main", split="test"): add(r["question"]); add(r["answer"])
|
| 53 |
+
for c in ("algebra", "counting_and_probability", "geometry", "intermediate_algebra", "number_theory", "prealgebra", "precalculus"):
|
| 54 |
+
for r in load_dataset("EleutherAI/hendrycks_math", c, split="test"): add(r["problem"]); add(r["solution"])
|
| 55 |
+
for r in load_dataset("cais/mmlu", "all", split="test"): add(r["question"] + " " + " ".join(r["choices"]))
|
| 56 |
+
for c in ("ARC-Challenge", "ARC-Easy"):
|
| 57 |
+
for r in load_dataset("allenai/ai2_arc", c, split="test"): add(r["question"] + " " + " ".join(r["choices"]["text"]))
|
| 58 |
+
print("decontamination 13-gram set:", len(H), flush=True)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def contaminated(text, stride):
|
| 62 |
+
w = words(text[:200000])
|
| 63 |
+
return any(hash(" ".join(w[i:i + NG])) in H for i in range(0, len(w) - NG + 1, stride))
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
# ---------------- adapters: raw row -> unified dict (or None to drop) ----------------
|
| 67 |
+
L_ODC, L_OWM = "odc-by-1.0", "odc-by-1.0 (per the OpenWebMath paper; the dataset card has no license field)"
|
| 68 |
+
STEM_SITES = {f"{s}.stackexchange.com": s for s in ("math", "physics", "chemistry", "biology", "stats", "cs", "cstheory", "datascience", "electronics", "engineering",
|
| 69 |
+
"astronomy", "earthscience", "quantumcomputing", "scicomp", "matheducators", "bioinformatics", "materials", "robotics", "space", "crypto", "dsp", "mathematica")}
|
| 70 |
+
STEM_SITES["mathoverflow.net"] = "mathoverflow"
|
| 71 |
+
SITE_SUBJ = {"math": "math", "mathoverflow": "math", "matheducators": "math", "stats": "math", "crypto": "math", "physics": "physics", "chemistry": "chemistry", "biology": "biology",
|
| 72 |
+
"bioinformatics": "biology", "cs": "cs", "cstheory": "cs", "datascience": "cs", "quantumcomputing": "physics", "scicomp": "cs", "mathematica": "cs",
|
| 73 |
+
"electronics": "eng", "engineering": "eng", "robotics": "eng", "dsp": "eng", "materials": "eng", "astronomy": "earth", "earthscience": "earth", "space": "earth"}
|
| 74 |
+
T_COSMO, T_WEB, T_WIKI = 20.0, 20.0, 18.0 # STEM density thresholds (tuned with `calib`)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def row(text, source, lic, subject, url):
|
| 78 |
+
return dict(text=text, source=source, license=lic, subject=subject, url=url, n_chars=len(text), _chk=text)
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def a_owm(r):
|
| 82 |
+
t = r["text"]
|
| 83 |
+
if len(t) < 300: return None
|
| 84 |
+
s, sub = stem_score(t); return row(t, "open-web-math", L_OWM, sub if s > 0 else "math", r.get("url"))
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def a_finemath(r):
|
| 88 |
+
t = r["text"]
|
| 89 |
+
if len(t) < 300: return None
|
| 90 |
+
s, sub = stem_score(t); return row(t, "finemath-4plus", L_ODC, sub if s > 0 else "math", r.get("url"))
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def a_cosmo(r):
|
| 94 |
+
t = r["text"]; s, sub = stem_score(t)
|
| 95 |
+
return row(t, "cosmopedia-v2", L_ODC + " (synthetic, generated with Mixtral)", sub, None) if len(t) >= 300 and s >= T_COSMO else None
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def a_fweb(r):
|
| 99 |
+
t = r["text"]
|
| 100 |
+
if r.get("int_score", 0) < 3 or len(t) < 500: return None
|
| 101 |
+
s, sub = stem_score(t)
|
| 102 |
+
return row(t, "fineweb-edu", L_ODC, sub, r.get("url")) if s >= T_WEB else None
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def a_se(r):
|
| 106 |
+
m = r["metadata"]; site = m.get("site", "")
|
| 107 |
+
if site not in STEM_SITES or len(r["text"]) < 300: return None
|
| 108 |
+
short = STEM_SITES[site]
|
| 109 |
+
return row(r["text"], f"stackexchange/{site}", "CC BY-SA (version varies per post; see url)", SITE_SUBJ[short], m.get("url"))
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def a_wiki(r):
|
| 113 |
+
t, ti = r["text"], r["title"]
|
| 114 |
+
if len(t) < 1500 or ti.startswith("List of") or "(disambiguation)" in ti: return None
|
| 115 |
+
s, sub = stem_score(t)
|
| 116 |
+
if s < T_WIKI: return None
|
| 117 |
+
return dict(id=r["id"], title=ti, url=r["url"], text=t, subject=sub, stem_score=round(s, 2), n_chars=len(t), license="CC BY-SA 3.0 + GFDL", _chk=t)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def conv(q, a, source, lic, gen, subject, code=False):
|
| 121 |
+
return dict(messages=[{"role": "user", "content": q}, {"role": "assistant", "content": a}], source=source, license=lic, generated_by=gen,
|
| 122 |
+
subject=subject, has_code=code, n_chars=len(q) + len(a), _chk=q)
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def a_numina(r):
|
| 126 |
+
m = r["messages"]
|
| 127 |
+
return conv(m[0]["content"], m[1]["content"], f"numina-cot/{r['source']}", "apache-2.0", "GPT-4o", "math") if len(m) == 2 and len(m[1]["content"]) > 20 else None
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def a_metamath(r): return conv(r["query"], r["response"], f"metamathqa/{r['type']}", "mit", "GPT-3.5-turbo", "math")
|
| 131 |
+
def a_orca(r): return conv(r["question"], r["answer"], "orca-math-200k", "mit", "GPT-4-Turbo", "math")
|
| 132 |
+
def a_omi2(r): return conv(r["problem"], r["generated_solution"], f"openmathinstruct-2/{r['problem_source']}", "cc-by-4.0 (generated with Llama-3.1-405B; Llama license terms apply)", "Llama-3.1-405B-Instruct", "math")
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def a_mathinstruct(r):
|
| 136 |
+
o = r["output"]
|
| 137 |
+
if "PoT" in r["source"] or "```" in o or "def " in o: return None # drop program-of-thought / code
|
| 138 |
+
return conv(r["instruction"], o, "mathinstruct-cot", "mit", "mixed (see MathInstruct card)", "math")
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
def a_camel(dom):
|
| 142 |
+
def f(r): return conv(r["message_1"], r["message_2"], f"camel-ai/{dom}", "cc-by-nc-4.0", "GPT-4", dom)
|
| 143 |
+
return f
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
def a_sqa(r):
|
| 147 |
+
if r.get("image") is not None or not (r.get("solution") or "").strip(): return None
|
| 148 |
+
ch = "\n".join(f"{chr(65 + i)}. {c}" for i, c in enumerate(r["choices"]))
|
| 149 |
+
q = (r["hint"] + "\n" if r.get("hint") else "") + r["question"] + "\n" + ch
|
| 150 |
+
return conv(q, r["solution"].strip() + f"\nAnswer: {chr(65 + r['answer'])}", "scienceqa-text", "cc-by-sa-4.0", "human (ScienceQA)", r.get("subject", "science"))
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
WANT = {"Planning", "Advice seeking", "Brainstorming", "Reasoning"}
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def a_plan(r):
|
| 157 |
+
if r["primary_tag"] not in WANT or r["quality"] not in ("good", "excellent") or r.get("safe") is False: return None
|
| 158 |
+
c = r["conversation"]
|
| 159 |
+
if len(c) < 2: return None
|
| 160 |
+
msgs = [{"role": ("user" if m["role"] in ("user", "human") else "assistant"), "content": m["content"]} for m in c]
|
| 161 |
+
return dict(messages=msgs, tag=r["primary_tag"], difficulty=r["difficulty"], quality=r["quality"], source="magpie-ultra-v1.0",
|
| 162 |
+
license="Llama 3.1 Community License (generated with Llama-3.1-405B-Instruct; 'Built with Llama')", generated_by="Llama-3.1-405B-Instruct",
|
| 163 |
+
n_chars=sum(len(m["content"]) for m in msgs), _chk=msgs[0]["content"], _cap=r["primary_tag"])
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
ADAPT = {"owm": a_owm, "finemath": a_finemath, "cosmo": a_cosmo, "fweb": a_fweb, "se": a_se, "wiki": a_wiki, "numina": a_numina, "metamath": a_metamath, "orca": a_orca,
|
| 167 |
+
"omi2": a_omi2, "mathinstruct": a_mathinstruct, "camel-physics": a_camel("physics"), "camel-chemistry": a_camel("chemistry"),
|
| 168 |
+
"camel-biology": a_camel("biology"), "sqa": a_sqa, "plan": a_plan}
|
| 169 |
+
STRIDE = {k: (1 if k in ("numina", "metamath", "orca", "omi2", "mathinstruct", "camel-physics", "camel-chemistry", "camel-biology", "sqa", "plan") else 4) for k in ADAPT}
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
def work(arg):
|
| 173 |
+
name, rows = arg; out, ncon = [], 0
|
| 174 |
+
for r in rows:
|
| 175 |
+
try: x = ADAPT[name](r)
|
| 176 |
+
except Exception: x = None
|
| 177 |
+
if x is None: continue
|
| 178 |
+
chk = x.pop("_chk")
|
| 179 |
+
if contaminated(chk, STRIDE[name]): ncon += 1; continue
|
| 180 |
+
x["_dig"] = hashlib.md5(" ".join(words(chk)).encode()).digest()
|
| 181 |
+
out.append(x)
|
| 182 |
+
return out, len(rows), ncon
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
# ---------------- sources ----------------
|
| 186 |
+
def robust(fn):
|
| 187 |
+
"""Yield rows of a streaming dataset; on a network error reopen and resume after the rows already yielded."""
|
| 188 |
+
import time
|
| 189 |
+
n, tries = 0, 0
|
| 190 |
+
while True:
|
| 191 |
+
try:
|
| 192 |
+
ds = fn()
|
| 193 |
+
if n: ds = ds.skip(n)
|
| 194 |
+
for r in ds:
|
| 195 |
+
n += 1; tries = 0; yield r
|
| 196 |
+
return
|
| 197 |
+
except Exception as e:
|
| 198 |
+
tries += 1
|
| 199 |
+
print(f"stream error after {n} rows ({type(e).__name__}: {str(e)[:80]}); retry {tries}", flush=True)
|
| 200 |
+
if tries > 8: raise
|
| 201 |
+
time.sleep(10 * tries)
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
S = lambda *a, **k: (lambda: robust(lambda: load_dataset(*a, streaming=True, **k)))
|
| 205 |
+
SRC = {
|
| 206 |
+
"owm": S("open-web-math/open-web-math", split="train"), "finemath": S("HuggingFaceTB/finemath", "finemath-4plus", split="train"),
|
| 207 |
+
"cosmo": S("HuggingFaceTB/smollm-corpus", "cosmopedia-v2", split="train"), "fweb": S("HuggingFaceFW/fineweb-edu", "sample-10BT", split="train"),
|
| 208 |
+
"se": S("common-pile/stackexchange", split="train"), "wiki": S("wikimedia/wikipedia", "20231101.en", split="train"),
|
| 209 |
+
"numina": S("AI-MO/NuminaMath-CoT", split="train"), "metamath": S("meta-math/MetaMathQA", split="train"),
|
| 210 |
+
"orca": S("microsoft/orca-math-word-problems-200k", split="train"), "omi2": S("nvidia/OpenMathInstruct-2", split="train_1M"),
|
| 211 |
+
"mathinstruct": S("TIGER-Lab/MathInstruct", split="train"), "camel-physics": S("camel-ai/physics", split="train"),
|
| 212 |
+
"camel-chemistry": S("camel-ai/chemistry", split="train"), "camel-biology": S("camel-ai/biology", split="train"),
|
| 213 |
+
"sqa": S("derek-thomas/ScienceQA", split="train"), "plan": S("argilla/magpie-ultra-v1.0", split="train"),
|
| 214 |
+
}
|
| 215 |
+
# per dataset: name -> list of (source key, config, kept-row cap, scanned-row cap, per-key cap)
|
| 216 |
+
PLANS = {
|
| 217 |
+
"stem": ("stem-text-corpus", [("owm", "core", 300_000, 450_000, None), ("finemath", "core", 300_000, 450_000, None), ("cosmo", "core", 150_000, 1_500_000, None),
|
| 218 |
+
("fweb", "core", 200_000, 3_000_000, None), ("se", "sharealike", 300_000, 12_000_000, 25_000)]),
|
| 219 |
+
"wiki": ("wikipedia-stem", [("wiki", "default", 10**9, 7_000_000, None)]),
|
| 220 |
+
"cot": ("stem-cot-sft", [("numina", "permissive", 900_000, 900_000, None), ("metamath", "permissive", 400_000, 400_000, None), ("orca", "permissive", 200_000, 200_000, None),
|
| 221 |
+
("omi2", "permissive", 300_000, 300_000, None), ("mathinstruct", "permissive", 270_000, 270_000, None), ("sqa", "sharealike", 10_000, 40_000, None)]),
|
| 222 |
+
"plan": ("planning-instruct", [("plan", "default", 10**9, 1_000_000, {"Planning": 100_000, "Advice seeking": 60_000, "Brainstorming": 50_000, "Reasoning": 50_000})]),
|
| 223 |
+
}
|
| 224 |
+
T = pa.string()
|
| 225 |
+
SCHEMAS = {
|
| 226 |
+
"stem": pa.schema([("text", T), ("source", T), ("license", T), ("subject", T), ("url", T), ("n_chars", pa.int64())]),
|
| 227 |
+
"wiki": pa.schema([("id", T), ("title", T), ("url", T), ("text", T), ("subject", T), ("stem_score", pa.float32()), ("n_chars", pa.int64()), ("license", T)]),
|
| 228 |
+
"cot": pa.schema([("messages", pa.list_(pa.struct([("role", T), ("content", T)]))), ("source", T), ("license", T), ("generated_by", T), ("subject", T), ("has_code", pa.bool_()), ("n_chars", pa.int64())]),
|
| 229 |
+
"plan": pa.schema([("messages", pa.list_(pa.struct([("role", T), ("content", T)]))), ("tag", T), ("difficulty", T), ("quality", T), ("source", T), ("license", T), ("generated_by", T), ("n_chars", pa.int64())]),
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
class Shards:
|
| 234 |
+
def __init__(s, out, cfg, schema): s.d, s.schema, s.buf, s.nb, s.k, s.n = f"{out}/data/{cfg}", schema, [], 0, 0, 0; os.makedirs(s.d, exist_ok=True)
|
| 235 |
+
def add(s, r): s.buf.append(r); s.nb += r["n_chars"]; s.n += 1; (s.flush() if s.nb > 250_000_000 else None)
|
| 236 |
+
def flush(s):
|
| 237 |
+
if not s.buf: return
|
| 238 |
+
pq.write_table(pa.Table.from_pylist(s.buf, schema=s.schema), f"{s.d}/train-{s.k:05d}.parquet", compression="zstd"); s.buf, s.nb, s.k = [], 0, s.k + 1
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def pump(pool, name, batches, handle, window=20):
|
| 242 |
+
pend = collections.deque()
|
| 243 |
+
for b in batches:
|
| 244 |
+
pend.append(pool.apply_async(work, ((name, b),)))
|
| 245 |
+
while len(pend) >= window:
|
| 246 |
+
if handle(*pend.popleft().get()): return
|
| 247 |
+
while pend:
|
| 248 |
+
if handle(*pend.popleft().get()): return
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
def build(which):
|
| 252 |
+
repo, plan = PLANS[which]; out = f"out_{repo}" + ("_dry" if LIMIT else "")
|
| 253 |
+
shutil.rmtree(out, ignore_errors=True); schema = SCHEMAS[which]; cols = set(schema.names)
|
| 254 |
+
build_H(); seen, shards, stats = set(), {}, {}
|
| 255 |
+
for key, cfg, cap, scan, percap in plan:
|
| 256 |
+
if LIMIT: cap, scan = min(cap, LIMIT), LIMIT * 40
|
| 257 |
+
sh = shards.setdefault(cfg, Shards(out, cfg, schema)); st = stats[key] = collections.Counter(); st["cfg"] = cfg; capn = collections.Counter(); n = [0]
|
| 258 |
+
def handle(kept, nin, ncon):
|
| 259 |
+
st["scanned"] += nin; st["decontaminated"] += ncon
|
| 260 |
+
for x in kept:
|
| 261 |
+
d = x.pop("_dig")
|
| 262 |
+
if d in seen: st["duplicates"] += 1; continue
|
| 263 |
+
ck = x.pop("_cap", None) or (x["source"] if percap and isinstance(percap, int) else None)
|
| 264 |
+
lim = percap if isinstance(percap, int) else (percap or {}).get(ck)
|
| 265 |
+
if ck is not None and lim is not None and capn[ck] >= lim: continue
|
| 266 |
+
seen.add(d); capn[ck] += 1; sh.add({k: x.get(k) for k in schema.names}); st["kept"] += 1; st["chars"] += x["n_chars"]; n[0] += 1
|
| 267 |
+
if n[0] >= cap: return True
|
| 268 |
+
if st["scanned"] % 50_000 < 200: print(key, dict(st), flush=True)
|
| 269 |
+
return False
|
| 270 |
+
it = itertools.islice(SRC[key](), scan)
|
| 271 |
+
batches = iter(lambda it=it: list(itertools.islice(it, 200)), [])
|
| 272 |
+
with Pool(WORKERS) as pool: pump(pool, key, batches, handle)
|
| 273 |
+
print("DONE", key, dict(st), flush=True)
|
| 274 |
+
for sh in shards.values(): sh.flush()
|
| 275 |
+
stats = {k: dict(v) for k, v in stats.items()}
|
| 276 |
+
json.dump(stats, open(f"{out}/build_stats.json", "w"), indent=1)
|
| 277 |
+
shutil.copy(__file__, f"{out}/build_script.py")
|
| 278 |
+
shutil.copy("cards.py", f"{out}/cards.py")
|
| 279 |
+
write_card(which, repo, out, stats, {c: s.n for c, s in shards.items()})
|
| 280 |
+
if LIMIT: print("DRY RUN OK", stats); return
|
| 281 |
+
api = HfApi(); rid = f"{USER}/{repo}"; api.create_repo(rid, repo_type="dataset", private=True, exist_ok=True)
|
| 282 |
+
api.upload_folder(folder_path=out, repo_id=rid, repo_type="dataset", commit_message="Initial release (private)")
|
| 283 |
+
print("BUILD_DONE", rid, flush=True)
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
# ---------------- dataset cards ----------------
|
| 287 |
+
def write_card(which, repo, out, stats, counts):
|
| 288 |
+
from cards import card
|
| 289 |
+
open(f"{out}/README.md", "w", encoding="utf8").write(card(which, repo, stats, counts))
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
def calib():
|
| 293 |
+
"""Print STEM-score distributions so thresholds are chosen on evidence."""
|
| 294 |
+
for name, n in (("wiki", 8000), ("fweb", 4000), ("cosmo", 3000)):
|
| 295 |
+
sc = []
|
| 296 |
+
for r in itertools.islice(SRC[name](), n):
|
| 297 |
+
s, sub = stem_score(r["text"]); sc.append((s, sub, r.get("title") or r["text"][:60].replace("\n", " ")))
|
| 298 |
+
v = sorted(x[0] for x in sc); q = lambda p: round(v[int(p * (len(v) - 1))], 1)
|
| 299 |
+
print(f"== {name}: quantiles 50/75/90/95/99% = {q(.5)} {q(.75)} {q(.9)} {q(.95)} {q(.99)}")
|
| 300 |
+
for lo, hi in ((6, 10), (10, 14), (14, 18), (18, 24), (24, 40)):
|
| 301 |
+
ex = [f"{x[2][:38]} ({x[0]:.0f},{x[1]})" for x in sc if lo <= x[0] < hi][:6]
|
| 302 |
+
print(f" [{lo},{hi}) n={sum(lo <= x[0] < hi for x in sc)}: {ex}")
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
if __name__ == "__main__":
|
| 306 |
+
os.environ.setdefault("PYTHONHASHSEED", "0")
|
| 307 |
+
calib() if WHICH == "calib" else build(WHICH)
|
build_stats.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"owm": {
|
| 3 |
+
"cfg": "core",
|
| 4 |
+
"scanned": 312200,
|
| 5 |
+
"decontaminated": 1722,
|
| 6 |
+
"kept": 300000,
|
| 7 |
+
"chars": 2361451861,
|
| 8 |
+
"duplicates": 32
|
| 9 |
+
},
|
| 10 |
+
"finemath": {
|
| 11 |
+
"cfg": "core",
|
| 12 |
+
"scanned": 307800,
|
| 13 |
+
"decontaminated": 2182,
|
| 14 |
+
"kept": 300000,
|
| 15 |
+
"chars": 1509336892,
|
| 16 |
+
"duplicates": 1916
|
| 17 |
+
},
|
| 18 |
+
"cosmo": {
|
| 19 |
+
"cfg": "core",
|
| 20 |
+
"scanned": 1500000,
|
| 21 |
+
"decontaminated": 74,
|
| 22 |
+
"kept": 69612,
|
| 23 |
+
"chars": 302316289,
|
| 24 |
+
"duplicates": 499
|
| 25 |
+
},
|
| 26 |
+
"fweb": {
|
| 27 |
+
"cfg": "core",
|
| 28 |
+
"scanned": 2485200,
|
| 29 |
+
"decontaminated": 42,
|
| 30 |
+
"kept": 200000,
|
| 31 |
+
"chars": 870400040,
|
| 32 |
+
"duplicates": 2014
|
| 33 |
+
},
|
| 34 |
+
"se": {
|
| 35 |
+
"cfg": "sharealike",
|
| 36 |
+
"scanned": 5233000,
|
| 37 |
+
"decontaminated": 5186,
|
| 38 |
+
"kept": 300000,
|
| 39 |
+
"chars": 1053510138,
|
| 40 |
+
"duplicates": 1992
|
| 41 |
+
}
|
| 42 |
+
}
|
cards.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Dataset card generator for dsb.py."""
|
| 2 |
+
U = "sandysanta"
|
| 3 |
+
DECON = ("**Benchmark decontamination:** documents sharing any 13-word overlap with the test questions/answers of GSM8K, MATH (all 7 subjects), MMLU (all) or "
|
| 4 |
+
"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.")
|
| 5 |
+
DEDUPE = "**Deduplication:** exact (normalized-text MD5) across all sources and configs. There is **no fuzzy/near-duplicate removal**, so near-identical documents can remain."
|
| 6 |
+
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."
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def table(stats, cols=("kept", "chars")):
|
| 10 |
+
rows = ["| Source key | Config | Rows kept | ~Tokens (chars/4) | Scanned | Decontaminated | Exact duplicates |", "|---|---|---|---|---|---|---|"]
|
| 11 |
+
for k, v in stats.items():
|
| 12 |
+
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):,} |")
|
| 13 |
+
return "\n".join(rows)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def yaml(title, counts, lic, tags, task="text-generation"):
|
| 17 |
+
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))
|
| 18 |
+
return f"---\nlicense: {lic}\npretty_name: {title}\nlanguage: [en]\ntask_categories: [{task}]\ntags: [{', '.join(tags)}]\nconfigs:\n{cfgs}\n---\n"
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def card(which, repo, stats, counts):
|
| 22 |
+
tot = sum(v.get("kept", 0) for v in stats.values()); tok = sum(v.get("chars", 0) for v in stats.values()) // 4
|
| 23 |
+
cfgs = "\n".join(f"| `{c}` | {n:,} |" for c, n in counts.items())
|
| 24 |
+
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"
|
| 25 |
+
if which == "stem":
|
| 26 |
+
return yaml("STEM Text Corpus", counts, "other", ["stem", "math", "science", "pretraining", "compilation"]) + head + f"""## Sources and licenses
|
| 27 |
+
{table(stats)}
|
| 28 |
+
|
| 29 |
+
| Source | Upstream | License as stated |
|
| 30 |
+
|---|---|---|
|
| 31 |
+
| `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) |
|
| 32 |
+
| `finemath-4plus` | [HuggingFaceTB/finemath](https://huggingface.co/datasets/HuggingFaceTB/finemath) | ODC-By 1.0 |
|
| 33 |
+
| `cosmopedia-v2` | [HuggingFaceTB/smollm-corpus](https://huggingface.co/datasets/HuggingFaceTB/smollm-corpus) | ODC-By 1.0 (synthetic text generated with Mixtral) |
|
| 34 |
+
| `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) |
|
| 35 |
+
| `stackexchange/*` | [common-pile/stackexchange](https://huggingface.co/datasets/common-pile/stackexchange) | **CC BY-SA** (share-alike): kept in its own config, `sharealike` |
|
| 36 |
+
|
| 37 |
+
## Columns
|
| 38 |
+
`text`, `source`, `license`, `subject` (math / physics / chemistry / biology / cs / eng / earth), `url`, `n_chars`.
|
| 39 |
+
|
| 40 |
+
## How it was built
|
| 41 |
+
- **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.
|
| 42 |
+
- Stack Exchange: only STEM sites, capped at 25,000 posts per site.
|
| 43 |
+
- {DECON.format(st=4)}
|
| 44 |
+
- {DEDUPE}
|
| 45 |
+
- Only a slice of each upstream dataset is included (see "Scanned" and the caps in `build_script.py`).
|
| 46 |
+
|
| 47 |
+
## Limitations
|
| 48 |
+
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.
|
| 49 |
+
|
| 50 |
+
{PRIV}
|
| 51 |
+
"""
|
| 52 |
+
if which == "wiki":
|
| 53 |
+
return yaml("Wikipedia STEM", counts, "cc-by-sa-3.0", ["wikipedia", "stem", "science", "math"]) + head + f"""## Source
|
| 54 |
+
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).
|
| 55 |
+
|
| 56 |
+
{table(stats)}
|
| 57 |
+
|
| 58 |
+
## Columns
|
| 59 |
+
`id`, `title`, `url`, `text`, `subject`, `stem_score`, `n_chars`, `license`.
|
| 60 |
+
|
| 61 |
+
## How it was built
|
| 62 |
+
- Kept articles of at least 1,500 characters, excluding "List of ..." and disambiguation pages.
|
| 63 |
+
- **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.
|
| 64 |
+
- **No LaTeX:** the Hugging Face Wikipedia dump strips mathematical markup, so formulas are missing from the text.
|
| 65 |
+
- {DECON.format(st=4)}
|
| 66 |
+
- {DEDUPE}
|
| 67 |
+
|
| 68 |
+
{PRIV}
|
| 69 |
+
"""
|
| 70 |
+
if which == "cot":
|
| 71 |
+
return yaml("STEM Chain-of-Thought SFT", counts, "other", ["math", "science", "chain-of-thought", "sft", "instruction", "compilation"]) + head + f"""## Sources, generators and licenses
|
| 72 |
+
{table(stats)}
|
| 73 |
+
|
| 74 |
+
| Source | Upstream | License | Generated by |
|
| 75 |
+
|---|---|---|---|
|
| 76 |
+
| `numina-cot/*` | [AI-MO/NuminaMath-CoT](https://huggingface.co/datasets/AI-MO/NuminaMath-CoT) | Apache-2.0 | GPT-4o |
|
| 77 |
+
| `metamathqa/*` | [meta-math/MetaMathQA](https://huggingface.co/datasets/meta-math/MetaMathQA) | MIT | GPT-3.5-turbo |
|
| 78 |
+
| `orca-math-200k` | [microsoft/orca-math-word-problems-200k](https://huggingface.co/datasets/microsoft/orca-math-word-problems-200k) | MIT | GPT-4-Turbo |
|
| 79 |
+
| `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 |
|
| 80 |
+
| `mathinstruct-cot` | [TIGER-Lab/MathInstruct](https://huggingface.co/datasets/TIGER-Lab/MathInstruct) | MIT | mixed |
|
| 81 |
+
| `scienceqa-text` | [derek-thomas/ScienceQA](https://huggingface.co/datasets/derek-thomas/ScienceQA) (text-only rows) | CC-BY-SA-4.0 | human |
|
| 82 |
+
|
| 83 |
+
**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).
|
| 84 |
+
|
| 85 |
+
## Columns
|
| 86 |
+
`messages` (list of `{{role, content}}`: one user turn, one assistant turn), `source`, `license`, `generated_by`, `subject`, `has_code`, `n_chars`.
|
| 87 |
+
|
| 88 |
+
## How it was built
|
| 89 |
+
- Unified chat format. MathInstruct program-of-thought rows and any row containing code were dropped (the focus is natural-language reasoning).
|
| 90 |
+
- **Answers are not verified.** Solutions are model-generated and can be wrong.
|
| 91 |
+
- {DECON.format(st=1)} (applied to the problem text.)
|
| 92 |
+
- {DEDUPE}
|
| 93 |
+
|
| 94 |
+
{PRIV}
|
| 95 |
+
"""
|
| 96 |
+
return yaml("Planning and Advice Instructions", counts, "other", ["instruction", "planning", "reasoning", "sft", "compilation"], "text-generation") + head + f"""## Source and license
|
| 97 |
+
{table(stats)}
|
| 98 |
+
|
| 99 |
+
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.
|
| 100 |
+
|
| 101 |
+
## Columns
|
| 102 |
+
`messages` (list of `{{role, content}}`), `tag` (Magpie `primary_tag`), `difficulty`, `quality`, `source`, `license`, `generated_by`, `n_chars`.
|
| 103 |
+
|
| 104 |
+
## How it was built
|
| 105 |
+
- 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).
|
| 106 |
+
- Original model answers are kept as-is (they are not in a fixed Goal/Steps/Risks template).
|
| 107 |
+
- {DECON.format(st=1)}
|
| 108 |
+
- {DEDUPE}
|
| 109 |
+
|
| 110 |
+
{PRIV}
|
| 111 |
+
"""
|
data/core/train-00000.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4db36d15ec2b2ae74f4ede9098201140610a7f2d8df7380eb1c5d61f196fcc11
|
| 3 |
+
size 96982510
|
data/core/train-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b952e2171b11c92a0e864fc913909262740336b3d5572f0f35110f93bc9e92c3
|
| 3 |
+
size 96602233
|
data/core/train-00002.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8e2ed17eb47b421d933ea51e72cfafde378c5db0ecd10ad12d62e23bc6226a3f
|
| 3 |
+
size 96084044
|
data/core/train-00003.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bff1192b5a68956609493e1691a8faf494bc2a4be31a491c35465d0bf0b438b9
|
| 3 |
+
size 96030461
|
data/core/train-00004.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:81f78af6980458b630dab195d47f74bb7f2074b4e596155eed9dc1ff9bb9d5b9
|
| 3 |
+
size 96297690
|
data/core/train-00005.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:15fa6477fcba45f93745244da92e984c1af70ae66f31771cfc06fb85c5e5e272
|
| 3 |
+
size 96534655
|
data/core/train-00006.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0a315510a960c9b0714afb8f10f8da33970a077c6b9c2173881110deac89576c
|
| 3 |
+
size 96297427
|
data/core/train-00007.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d8a4828302b5efab7abcd3a033ee5c8d97f45bf9f2a947e8a655a431ec793216
|
| 3 |
+
size 96320419
|
data/core/train-00008.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0931b9ec27d5b516bca07aac3b3720daacfde906d58f7328923bc955006137bd
|
| 3 |
+
size 96025975
|
data/core/train-00009.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f6173bca4280821f0fa64a7f010a1821473b11d7b19f5a12848a533a82812e25
|
| 3 |
+
size 96450156
|
data/core/train-00010.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:625443a871cb0bfbaa3100e95681a7e25f3f341e5fc786ff0bc1e6446f35ff91
|
| 3 |
+
size 96479811
|
data/core/train-00011.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ab5b1b20d8284439a2b85b7cff8cb83a56e9fe96b04bcee9824a512bd181139c
|
| 3 |
+
size 96528605
|
data/core/train-00012.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:25325274b3bef37ef9ca2cea75fcff7fd6752543a24fb1b2695df32950b62fc6
|
| 3 |
+
size 96022027
|
data/core/train-00013.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:555fecc4782baea9474fb64e9907c6e77c8959060288bafa15773948febed4c2
|
| 3 |
+
size 96217139
|
data/core/train-00014.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:31c1652278e40eb4324be609ecea16af6dbb84318335330a80f1867321a7eccc
|
| 3 |
+
size 96249495
|
data/core/train-00015.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1da95cdb07d064c8dc28cafe4f7828a2a1d77186d3d2f6a7111f1fda46c8917e
|
| 3 |
+
size 96738309
|
data/core/train-00016.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c3109666737b691ff42a5eb17adf857c2cb05ef41abf5efb0f73114cb1b5e64
|
| 3 |
+
size 99037821
|
data/core/train-00017.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9caf2e3ce58b2dd66cb7289fed6202dce3ab537defd5fcb1041e938f0fc0582a
|
| 3 |
+
size 103521189
|
data/core/train-00018.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5abab8916c93a3d49bab5d60c91b5aa92ff83b05fd121a3f84bd0bfb80f1af53
|
| 3 |
+
size 103419665
|
data/core/train-00019.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3f3f8ed674c629c2d827bd6d979b46fef7f0f32495362273f7eff9273bd902c9
|
| 3 |
+
size 102970589
|
data/core/train-00020.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c9f5ac2a7ae31ed0ccb1a951f20b15d0aca3abd6d6def45737029dd2fa924e65
|
| 3 |
+
size 17936510
|
data/sharealike/train-00000.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b455498eb5f2adeadca0cb4cacd43c6eb8a8258e510a5b978c13c9933589c96c
|
| 3 |
+
size 102354044
|
data/sharealike/train-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9bdfe8f2a3f536d61d6827801217173826f2414e1d49ce0d4968febbbb55f976
|
| 3 |
+
size 100568303
|
data/sharealike/train-00002.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:16be3f6e47578b74d226d9725a0ad113bc9f4c051cda7cf9bf8b6d578e8f32c6
|
| 3 |
+
size 103299528
|
data/sharealike/train-00003.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d61b54142ec97dc6867ce96d4cc2f80f7ec8ceb704bea1181b18a37dc42c5329
|
| 3 |
+
size 101703532
|
data/sharealike/train-00004.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:61a94683d2be1f655e27a4923dbab152e7450967464e1f0414cb6e5c3f14e534
|
| 3 |
+
size 21781711
|