Add dataset card and release build script (draft for review)

#1
by davanstrien HF Staff - opened
Files changed (2) hide show
  1. README.md +245 -0
  2. scripts/release_build.py +134 -0
README.md ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: mixed
4
+ pretty_name: Curation decision mix (draft)
5
+ task_categories: [text-classification, zero-shot-classification]
6
+ tags: [data-curation, decision-model, gliclass, provenance]
7
+ size_categories: [100K<n<1M]
8
+ configs:
9
+ - {config_name: all, data_files: "data/*/train.parquet", default: true}
10
+ - {config_name: base, data_files: data/base/train.parquet}
11
+ - {config_name: decisionbank, data_files: data/decisionbank/train.parquet}
12
+ - {config_name: prompt, data_files: data/prompt/train.parquet}
13
+ - {config_name: web, data_files: data/web/train.parquet}
14
+ - {config_name: nls, data_files: data/nls/train.parquet}
15
+ - {config_name: tool, data_files: data/tool/train.parquet}
16
+ - {config_name: harvard, data_files: data/harvard/train.parquet}
17
+ - {config_name: arxiv, data_files: data/arxiv/train.parquet}
18
+ - {config_name: procpile, data_files: data/procpile/train.parquet}
19
+ ---
20
+
21
+ <!-- DRAFT 2026-10-28, private review PR. -->
22
+
23
+ # Curation decision mix — draft
24
+
25
+ The training data of `davanstrien/ultrabert-380m-curation`, a small classifier that answers curation questions about web pages, prompts,
26
+ maths problems and library records ("what topic is this page?", "how educational is it?", "how hard is this
27
+ problem?"). Each row is a text, a question, a set of options and a probability for each option. Every row records
28
+ where it came from, who made its label and under which licence.
29
+
30
+ | | |
31
+ |---|---|
32
+ | Rows | 516,964 released, from a 535,730-row training mix; 18,766 base rows without a verified open licence are left out (see Licences) |
33
+ | Sources | 9: public task collections, DecisionBank, curation labels from web/prompt datasets, library catalogues, program-computed tasks |
34
+ | Row shapes | decision rows `{state, question, target}` and GLiClass rows `{text, all_labels, true_labels, prompt}` |
35
+ | Labels made by | dataset gold, library cataloguers, programs, and LLMs (named per source and per row) |
36
+ | Licence | mixed, per row; web page text is **not** included (labels plus a pointer to the source row; rebuild snippet below) |
37
+ | Trains | `davanstrien/ultrabert-380m-curation` (UltraBERT-380M + GLiClass head; 12,000 steps over this mix) |
38
+ | Build | mix builder on Hugging Face Jobs (CPU), then `scripts/release_build.py` (in this repo) for the release; file checksum (sha256) `3a1d0fa84e7342f7…`; test sets fixed before the mix was built, and every row checked against them |
39
+
40
+ ```python
41
+ import json
42
+ from datasets import load_dataset
43
+ ds = load_dataset("davanstrien/curation-decision-mix", "all", split="train") # or one config per source, e.g. "decisionbank"
44
+ ok = ds.filter(lambda r: r["licence_class"] == "permissive") # filter by licence before reuse
45
+ q = json.loads(ds[0]["question"]) # nested fields are JSON strings
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Layout
51
+
52
+ One config per source, plus `all`. Splitting by source keeps licence terms together, so a user can take only the parts
53
+ whose terms suit them.
54
+
55
+ | Config | Rows (training mix) | Shape |
56
+ |---|---:|---|
57
+ | `base` | 173,859 (192,625 in training; licence filter) | GLiClass |
58
+ | `decisionbank` | 165,277 | decision |
59
+ | `prompt` | 52,491 | decision |
60
+ | `web` | 41,890 (labels only; `state` empty until rebuilt) | decision |
61
+ | `nls` | 23,846 | GLiClass |
62
+ | `tool` | 21,089 | GLiClass |
63
+ | `harvard` | 13,918 | decision |
64
+ | `arxiv` | 13,597 | GLiClass |
65
+ | `procpile` | 10,997 | GLiClass |
66
+
67
+ Columns (union of both shapes; unused fields are null):
68
+
69
+ | Column | Meaning |
70
+ |---|---|
71
+ | `id` | stable row id; prefix names the source (`db/…`, `procpile-…`, `knowledgator/gliclass-v2.0:…`) |
72
+ | `config`, `src` | source group and the finer origin (e.g. `db_bitext_support`, a tasksource task) |
73
+ | `row_type` | `decision` or `gliclass` |
74
+ | `teacher` | who made the label (e.g. `Llama-3.1-405B`, `cataloguer`, `program`, `50% source label + 50% Qwen3.8-27B`) |
75
+ | `licence_class`, `licence` | `permissive` / `sa` (share-alike) / `publisher` (text not redistributed), and the licence id |
76
+ | `state` | the input (decision rows): a string, or a record as a JSON string |
77
+ | `question` | JSON string: `{type: noul|choice, instructions, criteria}`; `noul` = yes/no; `choice` options are `{key: description}`; graded scales use `level_<k>` keys, lowest first |
78
+ | `target` | JSON string: probability per option (soft targets allowed; sums to 1 for single-answer rows) |
79
+ | `text`, `all_labels`, `true_labels`, `prompt` | GLiClass rows: text, label list, `{label: score}` or a list (JSON string), optional prompt |
80
+ | `multi_label` | true when several options can be correct (per-option yes/no loss in training) |
81
+ | `source_dataset`, `source_row` | `web` rows only: source dataset and row index in its `train` split |
82
+
83
+ Example decision row (DecisionBank, shortened):
84
+
85
+ ```json
86
+ {"id": "db/decider/bitext_support/286978::q1", "src": "db_bitext_support", "row_type": "decision",
87
+ "teacher": "50% decider label + 50% Qwen3.8-27B", "licence_class": "sa", "licence": "cdla-sharing-1.0",
88
+ "state": "how do i remove several articles from order {{Order Number}}",
89
+ "question": {"type": "choice", "instructions": "What is the specific intent of this request?",
90
+ "criteria": {"change order": "change order", "get refund": "get refund", "...": "..."}},
91
+ "target": {"change order": 1.0, "get refund": 0.0, "...": 0.0}}
92
+ ```
93
+
94
+ Example GLiClass row (procedural pile, shortened):
95
+
96
+ ```json
97
+ {"id": "procpile-game_forced_win-89307", "row_type": "gliclass", "teacher": "program",
98
+ "text": "In this graph game, decide whether player can force a win. … The answer is Yes or No.",
99
+ "all_labels": ["No", "Yes"], "true_labels": {"No": 0.0, "Yes": 1.0}, "prompt": ""}
100
+ ```
101
+
102
+ **Web text.** The `web` config carries labels only. `source_dataset` and `source_row` point at the row in the
103
+ source dataset's `train` split; the training text was the first 3,000 characters. To rebuild it for your own use
104
+ (do not redistribute it):
105
+
106
+ ```python
107
+ src = {}
108
+ def rebuild(r):
109
+ if r["source_dataset"] not in src:
110
+ src[r["source_dataset"]] = load_dataset(r["source_dataset"], split="train")
111
+ return {"state": src[r["source_dataset"]][r["source_row"]]["text"][:3000]}
112
+ web = load_dataset("davanstrien/curation-decision-mix", "web", split="train").map(rebuild)
113
+ ```
114
+
115
+ Row indices assume the source datasets are unchanged since October 2026.
116
+
117
+ ---
118
+
119
+ ## Sources
120
+
121
+ | Source | Rows | What the rows ask | Labels made by | Licence |
122
+ |---|---:|---|---|---|
123
+ | base (tasksource + knowledgator GLiClass data) | 173,859 (192,625 trained on) | many public classification tasks | dataset gold; knowledgator gliclass-v2.0 / v3-logic (LLM-generated) | per source repo, in `licence`; only rows with a verified permissive, share-alike or other open licence are released (see Licences) |
124
+ | DecisionBank-260k (jgeuter/DecisionBank) | 165,277 | public tasks, written and programmatic decision questions | 50 % source label + 50 % Qwen3.8-27B; Qwen3.8-27B with thinking; 50 % Jeff 1.0 teachers (Qwen3.6-27B, Qwen3.5-122B-A10B) + 50 % Qwen3.8-27B (4,188 rows); code | per row: CC BY / CC BY-SA, Apache, MIT, CC0 (public domain), CDLA-Sharing only (non-commercial, research-only, unknown and other terms dropped) |
125
+ | prompt slice | 52,491 | NuminaMath-1.5 question type / problem type / validity; DeepMath-103K difficulty / topic; WebInstruct-verified answer type / category / difficulty; LMArena criteria and tags | dataset columns (NuminaMath, WebInstruct: labeller not documented); GPT-4o (DeepMath); LMArena classifiers | Apache-2.0; MIT; Apache-2.0; CC-BY-4.0 |
126
+ | web slice (**ids and labels only**) | 41,890 | WebOrganizer topic and format; FineWeb-Edu educational value | Llama-3.1-405B (WebOrganizer; the annotation datasets state no licence); Llama-3-70B (FineWeb-Edu) | labels: none stated; ODC-By. Page text: publisher copyright, not included (rebuild snippet above) |
127
+ | National Library of Scotland catalogue | 23,846 | subject areas of library records | National Library of Scotland cataloguers | CC0 |
128
+ | tool lane | 21,089 | tool selection | program-computed | permissive |
129
+ | Harvard modern catalogue | 13,918 | Library of Congress subject class, literary form, government publication | Harvard Library cataloguers (from their catalogue records) | CC0 |
130
+ | arXiv | 13,597 | arXiv subject category | author-chosen categories | arXiv metadata (CC0) |
131
+ | procedural pile | 10,997 | program-checkable reasoning | program-computed | CC BY 4.0 (attribute) |
132
+
133
+ ---
134
+
135
+ ## How the mix was designed
136
+
137
+ The mix is the result of a series of screened experiments (2026-10-23 → 10-27). Each choice below states what it rests
138
+ on: earlier decision-model reports, published curation work, or our own measurements. "Curation score" is the
139
+ benchmark used for selection: the mean of 16 curation test sets, balanced by family (see the model card).
140
+
141
+ **1. Start from a broad public base, cleaned by task identity.** The base follows the GLiClass v4 recipe
142
+ (knowledgator): tasksource classification tasks plus knowledgator's GLiClass training sets, so the model keeps general
143
+ zero-shot skill. Contamination was screened by task, not only by canary strings: tasksource re-hosts BIG-bench tasks
144
+ without the canary, and whole sources (math_qa, cosmos_qa, vitaminc, qasc, social_i_qa, …) were removed (2.7 % of
145
+ the pool).
146
+
147
+ **2. Prefer clean, audited, family-covering data to volume.** Earlier decision-model reports found bulk open decision
148
+ data neutral or harmful, gains staying inside the task families covered, and source audits worth more than extra rows.
149
+ Our own runs agreed: adding bulk without audits did not help; diverse, audited sources did (+4 points over the base
150
+ alone on a sample of a public decision benchmark suite). So every source was audited before training:
151
+ - **Text-blind baselines** on every source (majority label, longest option, options-only ranker). A generated-schema
152
+ source that looked like +4.5 turned out to be mostly a "longest option is right" shortcut (real gain ≈ +2.3), so
153
+ sources with option-only leaks were fixed or dropped.
154
+ - **Distractors weighted by gold frequency.** With uniformly sampled wrong options, a real-label source (arXiv)
155
+ leaked a label prior (+18 points over chance from the options alone). The Harvard rows needed the same fix
156
+ (options-only 52 % before it).
157
+ - **Same writing style for every class.** A source where one class was human-written and the other LLM-written taught
158
+ "LLM style means unsupported" and was dropped.
159
+
160
+ **3. Train on the labels real curation pipelines use.** The curation slices reuse public labels from curation work:
161
+ WebOrganizer topic and format (Wettig et al., 2025, *Organize the Web*), FineWeb-Edu educational value (Penedo et
162
+ al., 2024), and prompt tags from NuminaMath-1.5, DeepMath-103K, WebInstruct-verified and LMArena. Fixed-head
163
+ classifiers trained on the same labels were used as a ceiling check before any claim (they still win their own
164
+ labels: 0.87 / 0.83 vs 0.84 / 0.74 for WebOrganizer topic / format).
165
+
166
+ **4. Keep the third-party labels; document them.** We tested replacing every LLM-made label with labels from a panel
167
+ of open models (2 seeds). The panel matched the 405B topic labels well (0.815) but lost 5.1 curation-score points,
168
+ almost all on graded axes (maths difficulty, educational value). Rubric-anchored prompts helped the panel (+0.07
169
+ rank correlation against Omni-MATH human ratings) but did not close the gap. So the release keeps the original labels and
170
+ states each labeller, model and licence (Sources table and the `teacher` column).
171
+
172
+ **5. Add human-made labels where they exist.** Library catalogue records (National Library of Scotland, Harvard) carry
173
+ labels made by cataloguers. Harvard rows lifted an unseen library scheme by +4.6 accuracy (3 seeds, all 9 seed pairs
174
+ positive) without hurting the curation score; the cost to watch is the Aegis safety test set (−4.7).
175
+
176
+ **6. Add DecisionBank, licence-filtered.** DecisionBank rows added +0.70 curation-score points at equal steps and +0.77 at equal passes
177
+ over the other rows (3 seeds each, all 9 pairs positive), mostly on evals whose gold is independent of any training
178
+ labeller. Only rows with allowed licences were kept; the HelpSteer families were dropped because they are held-out test sets.
179
+
180
+ **7. Program-computed lanes for reasoning and tools.** Procedural reasoning tasks, tool selection and arXiv
181
+ categories have labels that are computed or author-chosen, so they carry no labeller bias. They help general decision
182
+ tasks more than the curation score.
183
+
184
+ ### How train and eval were split
185
+
186
+ - **Evals first.** The eval sets (v3: 40 sets, 72,533 rows) were frozen before any mix was built, and every mix was
187
+ decontaminated against all of them (exact, normalised, prefix, number-stripped skeleton, containment, 13-gram).
188
+ - **Hold out whole sources and schemes, not random rows.** Dev sets drawn from the training pool overestimate held-out
189
+ scores (earlier reports saw dev scores rise while scores on private test sets fell, and data shaped like a benchmark
190
+ inflate that benchmark's public score). So held-out test sets
191
+ are whole sources (HelpSteer2/3, Polaris, Aegis, WildGuard) and label schemes not seen in training (the item types of
192
+ US company filings, SEC form 8-K; a library item-form scheme).
193
+ - **Separate same-labeller from independent gold.** Where an eval's gold comes from the same LLM that labelled
194
+ training rows (WebOrganizer, FineWeb-Edu, DeepMath), it partly measures agreement with that labeller. The fair
195
+ comparison uses independent gold (Omni-MATH human ratings, Essential-Web), reported apart in the model card.
196
+ - **Seeds and review.** Each data choice was screened with ≥ 2 training seeds and claimed with ≥ 3; every claimed result was reviewed by
197
+ two independent reviewers before adoption.
198
+
199
+ ## Decontamination
200
+
201
+ Every row was checked against every text in the test sets (version v3). Removed: 1,562 base rows (478 overlaps +
202
+ 1,084 rows from HelpSteer3 sources, a held-out test source), 1,035 DecisionBank rows (mostly HelpSteer3 / Aegis
203
+ prompts), 1 Harvard row; the HelpSteer families of DecisionBank were dropped before the build. A 12-gram
204
+ near-duplicate check found 15 of 1,038 HelpSteer2 and 15 of 1,832 HelpSteer3 eval items sharing text with a
205
+ DecisionBank row. The catalogue test sets were kept out by id and title when the Harvard and National Library of Scotland sources were built.
206
+
207
+ ## Licences
208
+
209
+ Licence classes in the training mix: permissive 396,026 rows, share-alike 97,814, publisher terms 41,890 (web text;
210
+ trained on, never redistributed). DecisionBank's own parts are CC BY-SA 4.0; share-alike rows keep their licence in
211
+ this dataset. The model is released under Apache-2.0 (share-alike data may train a permissively licensed model).
212
+
213
+ Base rows, by the licence on the source repo's card (or, for tasksource tasks, the origin dataset's card; not legal
214
+ advice): of 200,000 rows before decontamination, 178,084 verified permissive, 1,127 share-alike (CC BY-SA), 497 under
215
+ other open licences (Mozilla Public License, Academic Free License), 13,263 not traced to an origin, 5,971 with no
216
+ licence stated and 1,058 under the GPL. The model was trained on all of them. This dataset releases only the
217
+ permissive, share-alike and other-open rows (173,859 after decontamination); the per-row licence is in `licence`.
218
+
219
+ ## Compute
220
+
221
+ Every step ran on [Hugging Face Jobs](https://huggingface.co/docs/huggingface_hub/guides/jobs), with sources, mixes
222
+ and test sets in Hugging Face storage buckets mounted into each job.
223
+ - **Building the data** (source conversion, licence filtering, decontamination, the mix itself) ran on CPU jobs; the
224
+ final mix build takes about 16 minutes.
225
+ - **Labelling experiments** (open-model panels, rubric and pairwise checks; see design note 4) called LLMs through
226
+ Hugging Face Inference Providers from Jobs. Those labels are not in the final mix.
227
+ - **Training and evaluation** of each data choice ran on single RTX PRO 6000 GPU jobs, about an hour per training run.
228
+ - The release build (`scripts/release_build.py`) is a CPU job that reads the mix from a bucket and writes this repo.
229
+
230
+ ## Known issues
231
+
232
+ - Several label sources are LLM outputs (named above and per row); the WebOrganizer annotation datasets carry no
233
+ licence statement; the Llama 3 / 3.1 licences apply to the Llama-made labels.
234
+ - Use terms of the original sources apply to their rows; check `licence` / `src` per row before reuse.
235
+ - Multilingual rows (DecisionBank) are present; the model was evaluated in English only.
236
+ - Maths difficulty labels are the weakest question type (LLM-made; human ratings agree only moderately).
237
+
238
+ ## Notes for agents
239
+
240
+ - Filter on `licence_class` / `licence` before redistributing any subset; never redistribute rebuilt `web` text.
241
+ - `target` is a distribution, not a class index; take `argmax` for hard labels. Graded questions (`level_<k>` keys)
242
+ are ordered: use the expected level or a rank correlation (Spearman), not top-1 accuracy alone.
243
+ - This release is not the exact training mix: 18,766 base rows are left out and web text is removed.
244
+ - Evals are not in this dataset; they are listed by name in the model card. Do not train on Omni-MATH, Essential-Web,
245
+ HelpSteer, Polaris, Aegis or WildGuard if you want to compare with the model card.
scripts/release_build.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.11"
3
+ # dependencies = ["polars", "huggingface_hub>=1.32"]
4
+ # ///
5
+ """Build the released dataset from the training mix (cur-cand v1) and upload it to a private dataset repo.
6
+
7
+ One parquet per config (source group), under data/<config>/. Release rules:
8
+ - base: keep rows whose source repo has a verified permissive, share-alike or other open licence
9
+ (analysis/release/base_licence_map.json); drop GPL, unresolved and no-licence rows. Fill `licence` per row.
10
+ - web: page text is not redistributed; `state` is set to "" and `source_dataset` / `source_row` point at the
11
+ source row (train split) so the text can be rebuilt.
12
+ - nested fields (state when it is a record, question, target, true_labels) are stored as JSON strings.
13
+ usage (CPU Job, dm-curation mounted at /c): python release_build.py --repo davanstrien/<name> [--dry-run]
14
+ """
15
+
16
+ import argparse
17
+ import collections
18
+ import json
19
+ import tempfile
20
+ from pathlib import Path
21
+
22
+ import polars as pl
23
+ from huggingface_hub import HfApi
24
+
25
+ MIX = Path("/c/mixes/cur-cand/v1")
26
+ LICMAP = Path("/c/analysis/release/base_licence_map.json")
27
+ CONFIG = {
28
+ "base-r1g": "base", "decisionbank": "decisionbank", "prompt-slice-tpm": "prompt", "web-slice-tpm": "web",
29
+ "nls": "nls", "tool": "tool", "harvard-modern": "harvard", "fh-arxiv": "arxiv", "procpile": "procpile",
30
+ }
31
+ # Licence per config where the whole source shares one licence (dataset card, Sources table); None = per src.
32
+ CONFIG_LICENCE = {"nls": "cc0-1.0", "harvard": "cc0-1.0", "arxiv": "cc0-1.0", "procpile": "cc-by-4.0"}
33
+ # Licence by src prefix for configs that mix sources (dataset card, Sources table).
34
+ SRC_LICENCE = {"numina_": "apache-2.0", "wi_": "apache-2.0", "dm_": "mit", "arena_": "cc-by-4.0",
35
+ "fineweb_edu": "odc-by", "weborganizer_": None,
36
+ "tool": "per package: mit / bsd / apache-2.0 / psf"}
37
+ # Web rows: the id suffix is the row index in the source dataset's train split (scripts/cur_build.py).
38
+ WEB_SOURCE = {"cur-wo-topic-": "WebOrganizer/TopicAnnotations-Llama-3.1-405B-FP8",
39
+ "cur-wo-format-": "WebOrganizer/FormatAnnotations-Llama-3.1-405B-FP8",
40
+ "cur-fwe-": "HuggingFaceFW/fineweb-edu-llama3-annotations"}
41
+ COLUMNS = ["id", "config", "src", "row_type", "teacher", "licence_class", "licence", "state", "question", "target",
42
+ "text", "all_labels", "true_labels", "prompt", "multi_label", "source_dataset", "source_row"]
43
+
44
+
45
+ def as_json(v):
46
+ return None if v is None else json.dumps(v, ensure_ascii=False, sort_keys=False)
47
+
48
+
49
+ def main():
50
+ ap = argparse.ArgumentParser()
51
+ ap.add_argument("--repo", required=True)
52
+ ap.add_argument("--dry-run", action="store_true")
53
+ args = ap.parse_args()
54
+
55
+ licmap = json.loads(LICMAP.read_text())
56
+ man = pl.read_parquet(MIX / "manifest.parquet", columns=["id", "source", "row_type"])
57
+ source_of = dict(zip(man["id"].to_list(), man["source"].to_list()))
58
+
59
+ rows = collections.defaultdict(list)
60
+ stats = collections.Counter()
61
+ extra_keys = collections.Counter()
62
+ no_licence = collections.Counter()
63
+ with open(MIX / "mix.jsonl") as f:
64
+ for line in f:
65
+ r = json.loads(line)
66
+ config = CONFIG[Path(source_of[r["id"]]).parent.name]
67
+ stats[f"{config}:in"] += 1
68
+ licence = r.get("licence") or CONFIG_LICENCE.get(config)
69
+ if licence is None:
70
+ for prefix, lic in SRC_LICENCE.items():
71
+ if r.get("src", "").startswith(prefix):
72
+ licence = lic
73
+ break
74
+ if config == "base":
75
+ repo = "/".join(r["src"].split("/")[:2])
76
+ entry = licmap[repo]
77
+ if not entry["keep"]:
78
+ stats[f"base:drop_{entry['status']}"] += 1
79
+ continue
80
+ licence = entry["licence"]
81
+ row_type = "gliclass" if "all_labels" in r else "decision"
82
+ state = r.get("state")
83
+ source_dataset = source_row = None
84
+ if config == "web":
85
+ state = ""
86
+ prefix = next(p for p in WEB_SOURCE if r["id"].startswith(p))
87
+ source_dataset, source_row = WEB_SOURCE[prefix], int(r["id"][len(prefix):])
88
+ out = {
89
+ "id": r["id"], "config": config, "src": r.get("src"), "row_type": row_type,
90
+ "teacher": r.get("teacher"), "licence_class": r.get("licence_class"), "licence": licence,
91
+ "state": state if state is None or isinstance(state, str) else as_json(state),
92
+ "question": as_json(r.get("question")), "target": as_json(r.get("target")),
93
+ "text": r.get("text"), "all_labels": r.get("all_labels"),
94
+ "true_labels": as_json(r.get("true_labels")), "prompt": r.get("prompt"),
95
+ "multi_label": bool(r.get("multi_label", False)),
96
+ "source_dataset": source_dataset, "source_row": source_row,
97
+ }
98
+ for k in r:
99
+ if k not in out:
100
+ extra_keys[k] += 1
101
+ if licence is None:
102
+ no_licence[(config, out["src"])] += 1
103
+ rows[config].append(out)
104
+ stats[f"{config}:out"] += 1
105
+
106
+ schema = {c: pl.Utf8 for c in COLUMNS}
107
+ schema["all_labels"] = pl.List(pl.Utf8)
108
+ schema["multi_label"] = pl.Boolean
109
+ schema["source_row"] = pl.Int64
110
+ print(json.dumps(dict(sorted(stats.items())), indent=1))
111
+ print("dropped keys (not released):", dict(extra_keys))
112
+ print("no licence (config, src):", no_licence.most_common())
113
+ print("total out:", sum(len(v) for v in rows.values()))
114
+ for config, rs in rows.items():
115
+ ex = {k: (v[:120] if isinstance(v, str) else v) for k, v in rs[0].items()}
116
+ print(config, json.dumps(ex, ensure_ascii=False)[:600])
117
+ if args.dry_run:
118
+ return
119
+
120
+ api = HfApi()
121
+ api.create_repo(args.repo, repo_type="dataset", private=True, exist_ok=True)
122
+ with tempfile.TemporaryDirectory() as d:
123
+ for config, rs in rows.items():
124
+ p = Path(d) / "data" / config
125
+ p.mkdir(parents=True)
126
+ pl.DataFrame(rs, schema=schema).write_parquet(p / "train.parquet")
127
+ (Path(d) / "release_stats.json").write_text(json.dumps(dict(sorted(stats.items())), indent=1))
128
+ api.upload_folder(repo_id=args.repo, repo_type="dataset", folder_path=d,
129
+ commit_message="Add release build of the cur-cand v1 training mix")
130
+ print("uploaded", api.list_repo_files(args.repo, repo_type="dataset"))
131
+
132
+
133
+ if __name__ == "__main__":
134
+ main()