Datasets:
Twist Shan commited on
Publish v1.0.0 formal hard-Sudoku splits
Browse filesTrain on balanced original, r0, and r1_4; reserve r5_19 for OOD evaluation. Includes deterministic builder, provenance hashes, and overlap audit.
- README.md +122 -0
- data/test.parquet +3 -0
- data/test_ood_confirm.parquet +3 -0
- data/train.parquet +3 -0
- data/validation.parquet +3 -0
- metadata/audit.json +224 -0
- metadata/manifest.json +329 -0
- metadata/split_spec.json +40 -0
- requirements.txt +1 -0
- scripts/build_dataset.py +984 -0
README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
task_categories:
|
| 4 |
+
- text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- sudoku
|
| 7 |
+
- reasoning
|
| 8 |
+
- planning
|
| 9 |
+
- discrete-diffusion
|
| 10 |
+
- out-of-distribution
|
| 11 |
+
pretty_name: Sudoku DLM Reasoning
|
| 12 |
+
configs:
|
| 13 |
+
- config_name: default
|
| 14 |
+
data_files:
|
| 15 |
+
- split: train
|
| 16 |
+
path: data/train.parquet
|
| 17 |
+
- split: validation
|
| 18 |
+
path: data/validation.parquet
|
| 19 |
+
- split: test
|
| 20 |
+
path: data/test.parquet
|
| 21 |
+
- split: test_ood_confirm
|
| 22 |
+
path: data/test_ood_confirm.parquet
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
# Sudoku DLM Reasoning
|
| 26 |
+
|
| 27 |
+
`stwistzz/Sudoku_DLM_Reasoning` is a deterministic 9x9 Sudoku benchmark for studying masked
|
| 28 |
+
diffusion language models, depth, and iterative decoding. Version 1.0.0
|
| 29 |
+
trains only on `original`, `r0`, and `r1_4`; `r5_19` is held out for adjacent
|
| 30 |
+
difficulty extrapolation.
|
| 31 |
+
|
| 32 |
+
## Splits
|
| 33 |
+
|
| 34 |
+
| split | original | r0 | r1_4 | r5_19 | total |
|
| 35 |
+
|---|---:|---:|---:|---:|---:|
|
| 36 |
+
| train | 65,536 | 65,536 | 65,536 | 0 | 196,608 |
|
| 37 |
+
| validation | 2,048 | 2,048 | 2,048 | 0 | 6,144 |
|
| 38 |
+
| test | 1,000 | 1,000 | 1,000 | 1,000 | 4,000 |
|
| 39 |
+
| test_ood_confirm | 0 | 0 | 0 | 4,000 | 4,000 |
|
| 40 |
+
|
| 41 |
+
The primary zero-shot protocol selects the checkpoint, decoding strategy, and
|
| 42 |
+
number of decoding steps using only `validation`. It must not use `r5_19` before
|
| 43 |
+
the final `test` evaluation. `test_ood_confirm` is reserved for confirming a
|
| 44 |
+
small number of already-selected configurations; it is not a tuning split.
|
| 45 |
+
|
| 46 |
+
## Difficulty
|
| 47 |
+
|
| 48 |
+
`r0`, `r1_4`, and `r5_19` use the number of tdoku backtracks. Higher values are
|
| 49 |
+
harder. `original` comes from a separate easy Sudoku collection and is not on the
|
| 50 |
+
same numeric scale.
|
| 51 |
+
|
| 52 |
+
The evaluation sample deliberately covers subranges:
|
| 53 |
+
|
| 54 |
+
- `r1_4`: `[1,2)`, `[2,3)`, `[3,4)`, `[4,5)`
|
| 55 |
+
- `r5_19`: `[5,8)`, `[8,12)`, `[12,16)`, `[16,20)`
|
| 56 |
+
|
| 57 |
+
The 1,000-row test allocation uses 250 rows from each subrange. The 4,000-row
|
| 58 |
+
confirmation allocation uses 1,000 rows from each `r5_19` subrange. Within a
|
| 59 |
+
subrange, source collection and clue count retain their upstream proportions.
|
| 60 |
+
|
| 61 |
+
## Deterministic construction
|
| 62 |
+
|
| 63 |
+
- Upstream repository: [`fhyfhy/diffusion-vs-ar-hard-sudoku`](https://huggingface.co/datasets/fhyfhy/diffusion-vs-ar-hard-sudoku)
|
| 64 |
+
- Pinned upstream revision: `527859f62c745c16833aded130ad9f9ddddb76af`
|
| 65 |
+
- Release seed: `20260815`
|
| 66 |
+
- Sampling: proportional metadata-stratified bottom-k by SHA-256 rank
|
| 67 |
+
- Leakage checks: exact puzzle plus digit-renaming-normalized puzzle/solution pair
|
| 68 |
+
- Validation: 81-character format, clue consistency, and Sudoku row/column/box validity
|
| 69 |
+
|
| 70 |
+
The source train/test boundary is preserved. Validation rows come only from
|
| 71 |
+
unused upstream training rows. Test and confirmation rows come only from upstream
|
| 72 |
+
test files. Full file hashes, row provenance, exclusions, and pairwise overlap
|
| 73 |
+
checks are in `metadata/manifest.json` and `metadata/audit.json`.
|
| 74 |
+
|
| 75 |
+
The upstream Sudoku Extreme corpus states that its official train and test sets
|
| 76 |
+
are mathematically inequivalent. This release additionally audits exact and digit
|
| 77 |
+
renaming overlap across the mixed original/Extreme sources. It does not implement
|
| 78 |
+
full canonicalization over every Sudoku row, column, band, stack, and transpose
|
| 79 |
+
symmetry; that remains a documented limitation.
|
| 80 |
+
|
| 81 |
+
## Schema
|
| 82 |
+
|
| 83 |
+
The main columns are `puzzle`, `solution`, `difficulty_bucket`,
|
| 84 |
+
`difficulty_subbucket`, `official_rating`, `clues`, `source_collection`, and
|
| 85 |
+
`release_split`. `example_id`, `puzzle_id`, and `digit_normalized_id` are stable
|
| 86 |
+
SHA-256 identifiers. `source_file` and `source_row_index` provide exact provenance.
|
| 87 |
+
|
| 88 |
+
```python
|
| 89 |
+
from datasets import load_dataset
|
| 90 |
+
|
| 91 |
+
dataset = load_dataset("stwistzz/Sudoku_DLM_Reasoning")
|
| 92 |
+
train = dataset["train"]
|
| 93 |
+
validation = dataset["validation"]
|
| 94 |
+
test = dataset["test"]
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
Puzzles and solutions are 81-character row-major strings. `0` denotes an empty
|
| 98 |
+
cell in `puzzle`.
|
| 99 |
+
|
| 100 |
+
## Rebuild
|
| 101 |
+
|
| 102 |
+
Download the pinned source CSV files listed in `metadata/manifest.json`, then run:
|
| 103 |
+
|
| 104 |
+
```bash
|
| 105 |
+
python scripts/build_dataset.py \
|
| 106 |
+
--source-dir /path/to/source \
|
| 107 |
+
--output-dir /path/to/release \
|
| 108 |
+
--dataset-id stwistzz/Sudoku_DLM_Reasoning \
|
| 109 |
+
--seed 20260815
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
The builder requires Python 3.10+ and PyArrow.
|
| 113 |
+
|
| 114 |
+
## Attribution and license
|
| 115 |
+
|
| 116 |
+
The data is derived from
|
| 117 |
+
[`fhyfhy/diffusion-vs-ar-hard-sudoku`](https://huggingface.co/datasets/fhyfhy/diffusion-vs-ar-hard-sudoku),
|
| 118 |
+
which packages the original Sudoku data from
|
| 119 |
+
[`HKUNLP/diffusion-vs-ar`](https://github.com/HKUNLP/diffusion-vs-ar) and the
|
| 120 |
+
[`sapientinc/sudoku-extreme`](https://huggingface.co/datasets/sapientinc/sudoku-extreme)
|
| 121 |
+
corpus. Please consult and comply with the licenses and attribution requirements
|
| 122 |
+
of all upstream sources. This derived release does not grant rights beyond them.
|
data/test.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b5d26f815582561672ead76547bc0c5618e5fbff1b8d031b3c9aa14d0e3d180e
|
| 3 |
+
size 742254
|
data/test_ood_confirm.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9312e11fb4034585f4640ac663cc43d99f968b63e419aacc0314efae5d20157
|
| 3 |
+
size 731113
|
data/train.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:265e248af10ec7d7c0fb70f99ad91bd21fc2a66b835c0d0805bedb9764950c13
|
| 3 |
+
size 36554476
|
data/validation.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2d63592476956148d5ae836d21ff19b5a7962bcb3caf3e4147e77faa2e09b688
|
| 3 |
+
size 1144080
|
metadata/audit.json
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"dataset_version": "1.0.0",
|
| 3 |
+
"pairwise_overlap": {
|
| 4 |
+
"test__vs__test_ood_confirm": {
|
| 5 |
+
"digit_normalized_id": 0,
|
| 6 |
+
"example_id": 0,
|
| 7 |
+
"puzzle_id": 0
|
| 8 |
+
},
|
| 9 |
+
"train__vs__test": {
|
| 10 |
+
"digit_normalized_id": 0,
|
| 11 |
+
"example_id": 0,
|
| 12 |
+
"puzzle_id": 0
|
| 13 |
+
},
|
| 14 |
+
"train__vs__test_ood_confirm": {
|
| 15 |
+
"digit_normalized_id": 0,
|
| 16 |
+
"example_id": 0,
|
| 17 |
+
"puzzle_id": 0
|
| 18 |
+
},
|
| 19 |
+
"train__vs__validation": {
|
| 20 |
+
"digit_normalized_id": 0,
|
| 21 |
+
"example_id": 0,
|
| 22 |
+
"puzzle_id": 0
|
| 23 |
+
},
|
| 24 |
+
"validation__vs__test": {
|
| 25 |
+
"digit_normalized_id": 0,
|
| 26 |
+
"example_id": 0,
|
| 27 |
+
"puzzle_id": 0
|
| 28 |
+
},
|
| 29 |
+
"validation__vs__test_ood_confirm": {
|
| 30 |
+
"digit_normalized_id": 0,
|
| 31 |
+
"example_id": 0,
|
| 32 |
+
"puzzle_id": 0
|
| 33 |
+
}
|
| 34 |
+
},
|
| 35 |
+
"seed": "20260815",
|
| 36 |
+
"selected_splits": {
|
| 37 |
+
"test": {
|
| 38 |
+
"clues": {
|
| 39 |
+
"max": 36,
|
| 40 |
+
"mean": 27.65425,
|
| 41 |
+
"min": 17
|
| 42 |
+
},
|
| 43 |
+
"difficulty_buckets": {
|
| 44 |
+
"original": 1000,
|
| 45 |
+
"r0": 1000,
|
| 46 |
+
"r1_4": 1000,
|
| 47 |
+
"r5_19": 1000
|
| 48 |
+
},
|
| 49 |
+
"difficulty_subbuckets": {
|
| 50 |
+
"original": 1000,
|
| 51 |
+
"r0": 1000,
|
| 52 |
+
"r12_15": 250,
|
| 53 |
+
"r16_19": 250,
|
| 54 |
+
"r1_2": 250,
|
| 55 |
+
"r2_3": 250,
|
| 56 |
+
"r3_4": 250,
|
| 57 |
+
"r4_5": 250,
|
| 58 |
+
"r5_7": 250,
|
| 59 |
+
"r8_11": 250
|
| 60 |
+
},
|
| 61 |
+
"official_rating": {
|
| 62 |
+
"max": 19.0,
|
| 63 |
+
"mean": 4.712,
|
| 64 |
+
"min": 0.0
|
| 65 |
+
},
|
| 66 |
+
"rows": 4000,
|
| 67 |
+
"source_collections": {
|
| 68 |
+
"01_file1": 337,
|
| 69 |
+
"diffusion_vs_ar_original": 1000,
|
| 70 |
+
"puzzles0_kaggle": 163,
|
| 71 |
+
"puzzles1_unbiased": 1559,
|
| 72 |
+
"puzzles2_17_clue": 78,
|
| 73 |
+
"puzzles4_forum_hardest_1905": 850,
|
| 74 |
+
"puzzles5_forum_hardest_1905_11+": 13
|
| 75 |
+
},
|
| 76 |
+
"unique_digit_normalized_ids": 4000,
|
| 77 |
+
"unique_example_ids": 4000,
|
| 78 |
+
"unique_puzzle_ids": 4000
|
| 79 |
+
},
|
| 80 |
+
"test_ood_confirm": {
|
| 81 |
+
"clues": {
|
| 82 |
+
"max": 29,
|
| 83 |
+
"mean": 24.933,
|
| 84 |
+
"min": 17
|
| 85 |
+
},
|
| 86 |
+
"difficulty_buckets": {
|
| 87 |
+
"r5_19": 4000
|
| 88 |
+
},
|
| 89 |
+
"difficulty_subbuckets": {
|
| 90 |
+
"r12_15": 1000,
|
| 91 |
+
"r16_19": 1000,
|
| 92 |
+
"r5_7": 1000,
|
| 93 |
+
"r8_11": 1000
|
| 94 |
+
},
|
| 95 |
+
"official_rating": {
|
| 96 |
+
"max": 19.0,
|
| 97 |
+
"mean": 11.61,
|
| 98 |
+
"min": 5.0
|
| 99 |
+
},
|
| 100 |
+
"rows": 4000,
|
| 101 |
+
"source_collections": {
|
| 102 |
+
"01_file1": 1120,
|
| 103 |
+
"puzzles1_unbiased": 96,
|
| 104 |
+
"puzzles2_17_clue": 2,
|
| 105 |
+
"puzzles4_forum_hardest_1905": 2728,
|
| 106 |
+
"puzzles5_forum_hardest_1905_11+": 54
|
| 107 |
+
},
|
| 108 |
+
"unique_digit_normalized_ids": 4000,
|
| 109 |
+
"unique_example_ids": 4000,
|
| 110 |
+
"unique_puzzle_ids": 4000
|
| 111 |
+
},
|
| 112 |
+
"train": {
|
| 113 |
+
"clues": {
|
| 114 |
+
"max": 37,
|
| 115 |
+
"mean": 28.56609598795573,
|
| 116 |
+
"min": 17
|
| 117 |
+
},
|
| 118 |
+
"difficulty_buckets": {
|
| 119 |
+
"original": 65536,
|
| 120 |
+
"r0": 65536,
|
| 121 |
+
"r1_4": 65536
|
| 122 |
+
},
|
| 123 |
+
"difficulty_subbuckets": {
|
| 124 |
+
"original": 65536,
|
| 125 |
+
"r0": 65536,
|
| 126 |
+
"r1_2": 29584,
|
| 127 |
+
"r2_3": 16809,
|
| 128 |
+
"r3_4": 10244,
|
| 129 |
+
"r4_5": 8899
|
| 130 |
+
},
|
| 131 |
+
"official_rating": {
|
| 132 |
+
"max": 4.0,
|
| 133 |
+
"mean": 0.9882354736328125,
|
| 134 |
+
"min": 0.0
|
| 135 |
+
},
|
| 136 |
+
"rows": 196608,
|
| 137 |
+
"source_collections": {
|
| 138 |
+
"01_file1": 2235,
|
| 139 |
+
"diffusion_vs_ar_original": 65536,
|
| 140 |
+
"puzzles0_kaggle": 10672,
|
| 141 |
+
"puzzles1_unbiased": 106434,
|
| 142 |
+
"puzzles2_17_clue": 5208,
|
| 143 |
+
"puzzles3_magictour_top1465": 82,
|
| 144 |
+
"puzzles4_forum_hardest_1905": 6354,
|
| 145 |
+
"puzzles5_forum_hardest_1905_11+": 87
|
| 146 |
+
},
|
| 147 |
+
"unique_digit_normalized_ids": 196608,
|
| 148 |
+
"unique_example_ids": 196608,
|
| 149 |
+
"unique_puzzle_ids": 196608
|
| 150 |
+
},
|
| 151 |
+
"validation": {
|
| 152 |
+
"clues": {
|
| 153 |
+
"max": 36,
|
| 154 |
+
"mean": 28.565592447916668,
|
| 155 |
+
"min": 17
|
| 156 |
+
},
|
| 157 |
+
"difficulty_buckets": {
|
| 158 |
+
"original": 2048,
|
| 159 |
+
"r0": 2048,
|
| 160 |
+
"r1_4": 2048
|
| 161 |
+
},
|
| 162 |
+
"difficulty_subbuckets": {
|
| 163 |
+
"original": 2048,
|
| 164 |
+
"r0": 2048,
|
| 165 |
+
"r1_2": 924,
|
| 166 |
+
"r2_3": 525,
|
| 167 |
+
"r3_4": 319,
|
| 168 |
+
"r4_5": 280
|
| 169 |
+
},
|
| 170 |
+
"official_rating": {
|
| 171 |
+
"max": 4.0,
|
| 172 |
+
"mean": 0.989013671875,
|
| 173 |
+
"min": 0.0
|
| 174 |
+
},
|
| 175 |
+
"rows": 6144,
|
| 176 |
+
"source_collections": {
|
| 177 |
+
"01_file1": 72,
|
| 178 |
+
"diffusion_vs_ar_original": 2048,
|
| 179 |
+
"puzzles0_kaggle": 333,
|
| 180 |
+
"puzzles1_unbiased": 3327,
|
| 181 |
+
"puzzles2_17_clue": 163,
|
| 182 |
+
"puzzles4_forum_hardest_1905": 199,
|
| 183 |
+
"puzzles5_forum_hardest_1905_11+": 2
|
| 184 |
+
},
|
| 185 |
+
"unique_digit_normalized_ids": 6144,
|
| 186 |
+
"unique_example_ids": 6144,
|
| 187 |
+
"unique_puzzle_ids": 6144
|
| 188 |
+
}
|
| 189 |
+
},
|
| 190 |
+
"source_test_scan": {
|
| 191 |
+
"accepted_counts": {
|
| 192 |
+
"original": 1000,
|
| 193 |
+
"r0": 61127,
|
| 194 |
+
"r1_4": 58717,
|
| 195 |
+
"r5_19": 111831
|
| 196 |
+
},
|
| 197 |
+
"exclusions": {},
|
| 198 |
+
"raw_counts": {
|
| 199 |
+
"original": 1000,
|
| 200 |
+
"r0": 61127,
|
| 201 |
+
"r1_4": 58717,
|
| 202 |
+
"r5_19": 111831
|
| 203 |
+
}
|
| 204 |
+
},
|
| 205 |
+
"source_train_scan": {
|
| 206 |
+
"accepted_counts": {
|
| 207 |
+
"original": 100000,
|
| 208 |
+
"r0": 553009,
|
| 209 |
+
"r1_4": 529736
|
| 210 |
+
},
|
| 211 |
+
"exclusions": {},
|
| 212 |
+
"raw_counts": {
|
| 213 |
+
"original": 100000,
|
| 214 |
+
"r0": 553009,
|
| 215 |
+
"r1_4": 529736
|
| 216 |
+
}
|
| 217 |
+
},
|
| 218 |
+
"strict_selected_rows_verified": 210752,
|
| 219 |
+
"symmetry_audit_scope": {
|
| 220 |
+
"digit_renaming": true,
|
| 221 |
+
"exact_puzzle": true,
|
| 222 |
+
"full_row_column_band_stack_transpose_group": false
|
| 223 |
+
}
|
| 224 |
+
}
|
metadata/manifest.json
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"audit_file": "metadata/audit.json",
|
| 3 |
+
"dataset_id": "stwistzz/Sudoku_DLM_Reasoning",
|
| 4 |
+
"dataset_version": "1.0.0",
|
| 5 |
+
"files": {
|
| 6 |
+
"data/test.parquet": {
|
| 7 |
+
"bytes": 742254,
|
| 8 |
+
"rows": 4000,
|
| 9 |
+
"sha256": "b5d26f815582561672ead76547bc0c5618e5fbff1b8d031b3c9aa14d0e3d180e"
|
| 10 |
+
},
|
| 11 |
+
"data/test_ood_confirm.parquet": {
|
| 12 |
+
"bytes": 731113,
|
| 13 |
+
"rows": 4000,
|
| 14 |
+
"sha256": "e9312e11fb4034585f4640ac663cc43d99f968b63e419aacc0314efae5d20157"
|
| 15 |
+
},
|
| 16 |
+
"data/train.parquet": {
|
| 17 |
+
"bytes": 36554476,
|
| 18 |
+
"rows": 196608,
|
| 19 |
+
"sha256": "265e248af10ec7d7c0fb70f99ad91bd21fc2a66b835c0d0805bedb9764950c13"
|
| 20 |
+
},
|
| 21 |
+
"data/validation.parquet": {
|
| 22 |
+
"bytes": 1144080,
|
| 23 |
+
"rows": 6144,
|
| 24 |
+
"sha256": "2d63592476956148d5ae836d21ff19b5a7962bcb3caf3e4147e77faa2e09b688"
|
| 25 |
+
},
|
| 26 |
+
"metadata/audit.json": {
|
| 27 |
+
"bytes": 5465,
|
| 28 |
+
"sha256": "81a54e426eccad84ee3ce42f4f5609ad73aa8addf65cf9799d99875b4b75bb26"
|
| 29 |
+
},
|
| 30 |
+
"metadata/split_spec.json": {
|
| 31 |
+
"bytes": 849,
|
| 32 |
+
"sha256": "be57f555641388613768d8eb4fa0b041345154b556e36e388a35509d25164280"
|
| 33 |
+
},
|
| 34 |
+
"scripts/build_dataset.py": {
|
| 35 |
+
"bytes": 37701,
|
| 36 |
+
"sha256": "2ebef7a4e6d268bfecbbacdd38f3f6e585d3a9b4169c522497efeb146829deac"
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"generated_at_utc": "2026-08-15T16:35:33.206067+00:00",
|
| 40 |
+
"schema": [
|
| 41 |
+
{
|
| 42 |
+
"name": "example_id",
|
| 43 |
+
"type": "string"
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"name": "puzzle_id",
|
| 47 |
+
"type": "string"
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"name": "digit_normalized_id",
|
| 51 |
+
"type": "string"
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"name": "puzzle",
|
| 55 |
+
"type": "string"
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"name": "solution",
|
| 59 |
+
"type": "string"
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"name": "difficulty_bucket",
|
| 63 |
+
"type": "string"
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"name": "difficulty_subbucket",
|
| 67 |
+
"type": "string"
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"name": "source_family",
|
| 71 |
+
"type": "string"
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"name": "source_collection",
|
| 75 |
+
"type": "string"
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"name": "official_rating",
|
| 79 |
+
"type": "double"
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"name": "rating_type",
|
| 83 |
+
"type": "string"
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"name": "clues",
|
| 87 |
+
"type": "int16"
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"name": "upstream_split",
|
| 91 |
+
"type": "string"
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"name": "release_split",
|
| 95 |
+
"type": "string"
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"name": "evaluation_role",
|
| 99 |
+
"type": "string"
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"name": "is_ood",
|
| 103 |
+
"type": "bool"
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"name": "source_file",
|
| 107 |
+
"type": "string"
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
"name": "source_row_index",
|
| 111 |
+
"type": "int64"
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"name": "stratum",
|
| 115 |
+
"type": "string"
|
| 116 |
+
}
|
| 117 |
+
],
|
| 118 |
+
"seed": "20260815",
|
| 119 |
+
"source": {
|
| 120 |
+
"files": {
|
| 121 |
+
"processed/sudoku_extreme_test_r0.csv": {
|
| 122 |
+
"bytes": 13913402,
|
| 123 |
+
"difficulty_bucket": "r0",
|
| 124 |
+
"expected_rows": 61127,
|
| 125 |
+
"sha256": "37c7b2dae5a09341bfc8dbd3c674d7671d7bf5df8a2dedcc69992e7202796bd6",
|
| 126 |
+
"upstream_split": "test"
|
| 127 |
+
},
|
| 128 |
+
"processed/sudoku_extreme_test_r1_4.csv": {
|
| 129 |
+
"bytes": 13545003,
|
| 130 |
+
"difficulty_bucket": "r1_4",
|
| 131 |
+
"expected_rows": 58717,
|
| 132 |
+
"sha256": "398d806a65818104b2696e1363aded5d1b4d328789547bd2b68a263735282cf8",
|
| 133 |
+
"upstream_split": "test"
|
| 134 |
+
},
|
| 135 |
+
"processed/sudoku_extreme_test_r5_19.csv": {
|
| 136 |
+
"bytes": 26407097,
|
| 137 |
+
"difficulty_bucket": "r5_19",
|
| 138 |
+
"expected_rows": 111831,
|
| 139 |
+
"sha256": "93852c0de8b7c6731a247ad6b28d4f64bfd33aa752a121b989180a7a767d7b5b",
|
| 140 |
+
"upstream_split": "test"
|
| 141 |
+
},
|
| 142 |
+
"processed/sudoku_extreme_train_r0.csv": {
|
| 143 |
+
"bytes": 126425169,
|
| 144 |
+
"difficulty_bucket": "r0",
|
| 145 |
+
"expected_rows": 553009,
|
| 146 |
+
"sha256": "c2d1930e4ca1d857943042e7ea0396bb7de29d4f793ac9e9cc304ed3de80f035",
|
| 147 |
+
"upstream_split": "train"
|
| 148 |
+
},
|
| 149 |
+
"processed/sudoku_extreme_train_r1_4.csv": {
|
| 150 |
+
"bytes": 122726060,
|
| 151 |
+
"difficulty_bucket": "r1_4",
|
| 152 |
+
"expected_rows": 529736,
|
| 153 |
+
"sha256": "b7f8701f34aba3003298d03580a53d1ac73c1f5930704d621b11781977f891b8",
|
| 154 |
+
"upstream_split": "train"
|
| 155 |
+
},
|
| 156 |
+
"sudoku_test.csv": {
|
| 157 |
+
"bytes": 165019,
|
| 158 |
+
"difficulty_bucket": "original",
|
| 159 |
+
"expected_rows": 1000,
|
| 160 |
+
"sha256": "36779035c7278bef48f1f4edba67def0d463195ca333ce1857c0bf79e48153c4",
|
| 161 |
+
"upstream_split": "test"
|
| 162 |
+
},
|
| 163 |
+
"sudoku_train.csv": {
|
| 164 |
+
"bytes": 16500019,
|
| 165 |
+
"difficulty_bucket": "original",
|
| 166 |
+
"expected_rows": 100000,
|
| 167 |
+
"sha256": "b9c13489f2a68af96074c12feccaf90bb9e87e0589df41bef4922b0ebe219a4e",
|
| 168 |
+
"upstream_split": "train"
|
| 169 |
+
}
|
| 170 |
+
},
|
| 171 |
+
"repo_id": "fhyfhy/diffusion-vs-ar-hard-sudoku",
|
| 172 |
+
"revision": "527859f62c745c16833aded130ad9f9ddddb76af"
|
| 173 |
+
},
|
| 174 |
+
"split_spec_file": "metadata/split_spec.json",
|
| 175 |
+
"splits": {
|
| 176 |
+
"test": {
|
| 177 |
+
"clues": {
|
| 178 |
+
"max": 36,
|
| 179 |
+
"mean": 27.65425,
|
| 180 |
+
"min": 17
|
| 181 |
+
},
|
| 182 |
+
"difficulty_buckets": {
|
| 183 |
+
"original": 1000,
|
| 184 |
+
"r0": 1000,
|
| 185 |
+
"r1_4": 1000,
|
| 186 |
+
"r5_19": 1000
|
| 187 |
+
},
|
| 188 |
+
"difficulty_subbuckets": {
|
| 189 |
+
"original": 1000,
|
| 190 |
+
"r0": 1000,
|
| 191 |
+
"r12_15": 250,
|
| 192 |
+
"r16_19": 250,
|
| 193 |
+
"r1_2": 250,
|
| 194 |
+
"r2_3": 250,
|
| 195 |
+
"r3_4": 250,
|
| 196 |
+
"r4_5": 250,
|
| 197 |
+
"r5_7": 250,
|
| 198 |
+
"r8_11": 250
|
| 199 |
+
},
|
| 200 |
+
"official_rating": {
|
| 201 |
+
"max": 19.0,
|
| 202 |
+
"mean": 4.712,
|
| 203 |
+
"min": 0.0
|
| 204 |
+
},
|
| 205 |
+
"rows": 4000,
|
| 206 |
+
"source_collections": {
|
| 207 |
+
"01_file1": 337,
|
| 208 |
+
"diffusion_vs_ar_original": 1000,
|
| 209 |
+
"puzzles0_kaggle": 163,
|
| 210 |
+
"puzzles1_unbiased": 1559,
|
| 211 |
+
"puzzles2_17_clue": 78,
|
| 212 |
+
"puzzles4_forum_hardest_1905": 850,
|
| 213 |
+
"puzzles5_forum_hardest_1905_11+": 13
|
| 214 |
+
},
|
| 215 |
+
"unique_digit_normalized_ids": 4000,
|
| 216 |
+
"unique_example_ids": 4000,
|
| 217 |
+
"unique_puzzle_ids": 4000
|
| 218 |
+
},
|
| 219 |
+
"test_ood_confirm": {
|
| 220 |
+
"clues": {
|
| 221 |
+
"max": 29,
|
| 222 |
+
"mean": 24.933,
|
| 223 |
+
"min": 17
|
| 224 |
+
},
|
| 225 |
+
"difficulty_buckets": {
|
| 226 |
+
"r5_19": 4000
|
| 227 |
+
},
|
| 228 |
+
"difficulty_subbuckets": {
|
| 229 |
+
"r12_15": 1000,
|
| 230 |
+
"r16_19": 1000,
|
| 231 |
+
"r5_7": 1000,
|
| 232 |
+
"r8_11": 1000
|
| 233 |
+
},
|
| 234 |
+
"official_rating": {
|
| 235 |
+
"max": 19.0,
|
| 236 |
+
"mean": 11.61,
|
| 237 |
+
"min": 5.0
|
| 238 |
+
},
|
| 239 |
+
"rows": 4000,
|
| 240 |
+
"source_collections": {
|
| 241 |
+
"01_file1": 1120,
|
| 242 |
+
"puzzles1_unbiased": 96,
|
| 243 |
+
"puzzles2_17_clue": 2,
|
| 244 |
+
"puzzles4_forum_hardest_1905": 2728,
|
| 245 |
+
"puzzles5_forum_hardest_1905_11+": 54
|
| 246 |
+
},
|
| 247 |
+
"unique_digit_normalized_ids": 4000,
|
| 248 |
+
"unique_example_ids": 4000,
|
| 249 |
+
"unique_puzzle_ids": 4000
|
| 250 |
+
},
|
| 251 |
+
"train": {
|
| 252 |
+
"clues": {
|
| 253 |
+
"max": 37,
|
| 254 |
+
"mean": 28.56609598795573,
|
| 255 |
+
"min": 17
|
| 256 |
+
},
|
| 257 |
+
"difficulty_buckets": {
|
| 258 |
+
"original": 65536,
|
| 259 |
+
"r0": 65536,
|
| 260 |
+
"r1_4": 65536
|
| 261 |
+
},
|
| 262 |
+
"difficulty_subbuckets": {
|
| 263 |
+
"original": 65536,
|
| 264 |
+
"r0": 65536,
|
| 265 |
+
"r1_2": 29584,
|
| 266 |
+
"r2_3": 16809,
|
| 267 |
+
"r3_4": 10244,
|
| 268 |
+
"r4_5": 8899
|
| 269 |
+
},
|
| 270 |
+
"official_rating": {
|
| 271 |
+
"max": 4.0,
|
| 272 |
+
"mean": 0.9882354736328125,
|
| 273 |
+
"min": 0.0
|
| 274 |
+
},
|
| 275 |
+
"rows": 196608,
|
| 276 |
+
"source_collections": {
|
| 277 |
+
"01_file1": 2235,
|
| 278 |
+
"diffusion_vs_ar_original": 65536,
|
| 279 |
+
"puzzles0_kaggle": 10672,
|
| 280 |
+
"puzzles1_unbiased": 106434,
|
| 281 |
+
"puzzles2_17_clue": 5208,
|
| 282 |
+
"puzzles3_magictour_top1465": 82,
|
| 283 |
+
"puzzles4_forum_hardest_1905": 6354,
|
| 284 |
+
"puzzles5_forum_hardest_1905_11+": 87
|
| 285 |
+
},
|
| 286 |
+
"unique_digit_normalized_ids": 196608,
|
| 287 |
+
"unique_example_ids": 196608,
|
| 288 |
+
"unique_puzzle_ids": 196608
|
| 289 |
+
},
|
| 290 |
+
"validation": {
|
| 291 |
+
"clues": {
|
| 292 |
+
"max": 36,
|
| 293 |
+
"mean": 28.565592447916668,
|
| 294 |
+
"min": 17
|
| 295 |
+
},
|
| 296 |
+
"difficulty_buckets": {
|
| 297 |
+
"original": 2048,
|
| 298 |
+
"r0": 2048,
|
| 299 |
+
"r1_4": 2048
|
| 300 |
+
},
|
| 301 |
+
"difficulty_subbuckets": {
|
| 302 |
+
"original": 2048,
|
| 303 |
+
"r0": 2048,
|
| 304 |
+
"r1_2": 924,
|
| 305 |
+
"r2_3": 525,
|
| 306 |
+
"r3_4": 319,
|
| 307 |
+
"r4_5": 280
|
| 308 |
+
},
|
| 309 |
+
"official_rating": {
|
| 310 |
+
"max": 4.0,
|
| 311 |
+
"mean": 0.989013671875,
|
| 312 |
+
"min": 0.0
|
| 313 |
+
},
|
| 314 |
+
"rows": 6144,
|
| 315 |
+
"source_collections": {
|
| 316 |
+
"01_file1": 72,
|
| 317 |
+
"diffusion_vs_ar_original": 2048,
|
| 318 |
+
"puzzles0_kaggle": 333,
|
| 319 |
+
"puzzles1_unbiased": 3327,
|
| 320 |
+
"puzzles2_17_clue": 163,
|
| 321 |
+
"puzzles4_forum_hardest_1905": 199,
|
| 322 |
+
"puzzles5_forum_hardest_1905_11+": 2
|
| 323 |
+
},
|
| 324 |
+
"unique_digit_normalized_ids": 6144,
|
| 325 |
+
"unique_example_ids": 6144,
|
| 326 |
+
"unique_puzzle_ids": 6144
|
| 327 |
+
}
|
| 328 |
+
}
|
| 329 |
+
}
|
metadata/split_spec.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bucket_mix": "equal across training buckets; natural proportions within buckets",
|
| 3 |
+
"confirm_subbucket_targets": {
|
| 4 |
+
"r5_19": {
|
| 5 |
+
"r12_15": 1000,
|
| 6 |
+
"r16_19": 1000,
|
| 7 |
+
"r5_7": 1000,
|
| 8 |
+
"r8_11": 1000
|
| 9 |
+
}
|
| 10 |
+
},
|
| 11 |
+
"counts": {
|
| 12 |
+
"test_ood_confirm": 4000,
|
| 13 |
+
"test_per_bucket": 1000,
|
| 14 |
+
"train_per_bucket": 65536,
|
| 15 |
+
"validation_per_bucket": 2048
|
| 16 |
+
},
|
| 17 |
+
"dataset_version": "1.0.0",
|
| 18 |
+
"ood_bucket": "r5_19",
|
| 19 |
+
"seed": "20260815",
|
| 20 |
+
"selection": "metadata-stratified bottom-k SHA-256 rank",
|
| 21 |
+
"test_subbucket_targets": {
|
| 22 |
+
"r1_4": {
|
| 23 |
+
"r1_2": 250,
|
| 24 |
+
"r2_3": 250,
|
| 25 |
+
"r3_4": 250,
|
| 26 |
+
"r4_5": 250
|
| 27 |
+
},
|
| 28 |
+
"r5_19": {
|
| 29 |
+
"r12_15": 250,
|
| 30 |
+
"r16_19": 250,
|
| 31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
|
|
|
|
|
|
| 1 |
+
"""Build the versioned Sudoku_DLM_Reasoning dataset release.
|
| 2 |
+
|
| 3 |
+
The release is deliberately small enough for controlled model and decoding
|
| 4 |
+
experiments while preserving the upstream train/test boundary:
|
| 5 |
+
|
| 6 |
+
* train: 65,536 examples from each of original, r0, and r1_4
|
| 7 |
+
* validation: 2,048 examples from each of original, r0, and r1_4
|
| 8 |
+
* test: 1,000 examples from each of original, r0, r1_4, and r5_19
|
| 9 |
+
* confirm: 4,000 additional r5_19 examples, reserved for final confirmation
|
| 10 |
+
|
| 11 |
+
Selection is deterministic. Rows are ranked by SHA-256 within metadata strata,
|
| 12 |
+
not by their position in the source CSV. Exact-puzzle and digit-renaming overlap
|
| 13 |
+
is excluded across all released splits.
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
from __future__ import annotations
|
| 17 |
+
|
| 18 |
+
import argparse
|
| 19 |
+
import csv
|
| 20 |
+
import hashlib
|
| 21 |
+
import heapq
|
| 22 |
+
import json
|
| 23 |
+
import math
|
| 24 |
+
import shutil
|
| 25 |
+
from collections import Counter, defaultdict
|
| 26 |
+
from dataclasses import dataclass
|
| 27 |
+
from datetime import datetime, timezone
|
| 28 |
+
from pathlib import Path
|
| 29 |
+
from typing import Iterable, Iterator, Mapping, MutableMapping, Sequence
|
| 30 |
+
|
| 31 |
+
import pyarrow as pa
|
| 32 |
+
import pyarrow.parquet as pq
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
DATASET_VERSION = "1.0.0"
|
| 36 |
+
DEFAULT_DATASET_ID = "stwistzz/Sudoku_DLM_Reasoning"
|
| 37 |
+
DEFAULT_SEED = "20260815"
|
| 38 |
+
SOURCE_REPO = "fhyfhy/diffusion-vs-ar-hard-sudoku"
|
| 39 |
+
SOURCE_REVISION = "527859f62c745c16833aded130ad9f9ddddb76af"
|
| 40 |
+
|
| 41 |
+
TRAIN_PER_BUCKET = 65_536
|
| 42 |
+
VALIDATION_PER_BUCKET = 2_048
|
| 43 |
+
TEST_PER_BUCKET = 1_000
|
| 44 |
+
OOD_CONFIRM_SIZE = 4_000
|
| 45 |
+
|
| 46 |
+
BUCKET_ORDER = {"original": 0, "r0": 1, "r1_4": 2, "r5_19": 3}
|
| 47 |
+
TEST_PRIORITY = ("r5_19", "r1_4", "r0", "original")
|
| 48 |
+
TRAIN_PRIORITY = ("r1_4", "r0", "original")
|
| 49 |
+
|
| 50 |
+
SCHEMA = pa.schema(
|
| 51 |
+
[
|
| 52 |
+
pa.field("example_id", pa.string(), nullable=False),
|
| 53 |
+
pa.field("puzzle_id", pa.string(), nullable=False),
|
| 54 |
+
pa.field("digit_normalized_id", pa.string(), nullable=False),
|
| 55 |
+
pa.field("puzzle", pa.string(), nullable=False),
|
| 56 |
+
pa.field("solution", pa.string(), nullable=False),
|
| 57 |
+
pa.field("difficulty_bucket", pa.string(), nullable=False),
|
| 58 |
+
pa.field("difficulty_subbucket", pa.string(), nullable=False),
|
| 59 |
+
pa.field("source_family", pa.string(), nullable=False),
|
| 60 |
+
pa.field("source_collection", pa.string(), nullable=False),
|
| 61 |
+
pa.field("official_rating", pa.float64(), nullable=True),
|
| 62 |
+
pa.field("rating_type", pa.string(), nullable=False),
|
| 63 |
+
pa.field("clues", pa.int16(), nullable=False),
|
| 64 |
+
pa.field("upstream_split", pa.string(), nullable=False),
|
| 65 |
+
pa.field("release_split", pa.string(), nullable=False),
|
| 66 |
+
pa.field("evaluation_role", pa.string(), nullable=False),
|
| 67 |
+
pa.field("is_ood", pa.bool_(), nullable=False),
|
| 68 |
+
pa.field("source_file", pa.string(), nullable=False),
|
| 69 |
+
pa.field("source_row_index", pa.int64(), nullable=False),
|
| 70 |
+
pa.field("stratum", pa.string(), nullable=False),
|
| 71 |
+
]
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
@dataclass(frozen=True)
|
| 76 |
+
class PoolSpec:
|
| 77 |
+
bucket: str
|
| 78 |
+
upstream_split: str
|
| 79 |
+
relative_path: str
|
| 80 |
+
expected_rows: int
|
| 81 |
+
is_original: bool = False
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
POOLS = {
|
| 85 |
+
("original", "train"): PoolSpec(
|
| 86 |
+
"original", "train", "sudoku_train.csv", 100_000, True
|
| 87 |
+
),
|
| 88 |
+
("original", "test"): PoolSpec(
|
| 89 |
+
"original", "test", "sudoku_test.csv", 1_000, True
|
| 90 |
+
),
|
| 91 |
+
("r0", "train"): PoolSpec(
|
| 92 |
+
"r0", "train", "processed/sudoku_extreme_train_r0.csv", 553_009
|
| 93 |
+
),
|
| 94 |
+
("r0", "test"): PoolSpec(
|
| 95 |
+
"r0", "test", "processed/sudoku_extreme_test_r0.csv", 61_127
|
| 96 |
+
),
|
| 97 |
+
("r1_4", "train"): PoolSpec(
|
| 98 |
+
"r1_4", "train", "processed/sudoku_extreme_train_r1_4.csv", 529_736
|
| 99 |
+
),
|
| 100 |
+
("r1_4", "test"): PoolSpec(
|
| 101 |
+
"r1_4", "test", "processed/sudoku_extreme_test_r1_4.csv", 58_717
|
| 102 |
+
),
|
| 103 |
+
("r5_19", "test"): PoolSpec(
|
| 104 |
+
"r5_19", "test", "processed/sudoku_extreme_test_r5_19.csv", 111_831
|
| 105 |
+
),
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def parse_args() -> argparse.Namespace:
|
| 110 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 111 |
+
parser.add_argument("--source-dir", type=Path, required=True)
|
| 112 |
+
parser.add_argument("--output-dir", type=Path, required=True)
|
| 113 |
+
parser.add_argument("--dataset-id", default=DEFAULT_DATASET_ID)
|
| 114 |
+
parser.add_argument("--seed", default=DEFAULT_SEED)
|
| 115 |
+
return parser.parse_args()
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def sha256_text(value: str) -> str:
|
| 119 |
+
return hashlib.sha256(value.encode("utf-8")).hexdigest()
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def sha256_file(path: Path) -> str:
|
| 123 |
+
digest = hashlib.sha256()
|
| 124 |
+
with path.open("rb") as handle:
|
| 125 |
+
for chunk in iter(lambda: handle.read(1024 * 1024), b""):
|
| 126 |
+
digest.update(chunk)
|
| 127 |
+
return digest.hexdigest()
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def digit_normalized_pair(puzzle: str, solution: str) -> tuple[str, str]:
|
| 131 |
+
"""Canonicalize digit names using their first occurrence in the solution."""
|
| 132 |
+
mapping: dict[str, str] = {}
|
| 133 |
+
for digit in solution:
|
| 134 |
+
if digit not in mapping:
|
| 135 |
+
mapping[digit] = str(len(mapping) + 1)
|
| 136 |
+
if len(mapping) != 9:
|
| 137 |
+
raise ValueError("solution does not contain all nine digits")
|
| 138 |
+
normalized_solution = "".join(mapping[digit] for digit in solution)
|
| 139 |
+
normalized_puzzle = "".join("0" if digit == "0" else mapping[digit] for digit in puzzle)
|
| 140 |
+
return normalized_puzzle, normalized_solution
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def subbucket(bucket: str, rating: float | None) -> str:
|
| 144 |
+
if bucket in {"original", "r0"}:
|
| 145 |
+
return bucket
|
| 146 |
+
if rating is None:
|
| 147 |
+
raise ValueError(f"missing official rating for {bucket}")
|
| 148 |
+
if bucket == "r1_4":
|
| 149 |
+
if not 1 <= rating < 5:
|
| 150 |
+
raise ValueError(f"rating {rating} is outside r1_4")
|
| 151 |
+
lower = math.floor(rating)
|
| 152 |
+
return f"r{lower}_{lower + 1}"
|
| 153 |
+
if bucket == "r5_19":
|
| 154 |
+
if not 5 <= rating < 20:
|
| 155 |
+
raise ValueError(f"rating {rating} is outside r5_19")
|
| 156 |
+
if rating < 8:
|
| 157 |
+
return "r5_7"
|
| 158 |
+
if rating < 12:
|
| 159 |
+
return "r8_11"
|
| 160 |
+
if rating < 16:
|
| 161 |
+
return "r12_15"
|
| 162 |
+
return "r16_19"
|
| 163 |
+
raise ValueError(f"unknown difficulty bucket: {bucket}")
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
def make_stratum(record: Mapping[str, object]) -> str:
|
| 167 |
+
bucket = str(record["difficulty_bucket"])
|
| 168 |
+
clues = int(record["clues"])
|
| 169 |
+
if bucket == "original":
|
| 170 |
+
return f"bucket=original|clues={clues}"
|
| 171 |
+
source = str(record["source_collection"])
|
| 172 |
+
if bucket == "r0":
|
| 173 |
+
return f"bucket=r0|source={source}|clues={clues}"
|
| 174 |
+
return (
|
| 175 |
+
f"bucket={bucket}|sub={record['difficulty_subbucket']}|"
|
| 176 |
+
f"source={source}|clues={clues}"
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
def validate_strings(puzzle: str, solution: str, context: str) -> None:
|
| 181 |
+
if len(puzzle) != 81 or any(char not in "0123456789" for char in puzzle):
|
| 182 |
+
raise ValueError(f"{context}: puzzle must contain 81 digits")
|
| 183 |
+
if len(solution) != 81 or any(char not in "123456789" for char in solution):
|
| 184 |
+
raise ValueError(f"{context}: solution must contain 81 digits 1-9")
|
| 185 |
+
for index, clue in enumerate(puzzle):
|
| 186 |
+
if clue != "0" and clue != solution[index]:
|
| 187 |
+
raise ValueError(f"{context}: clue disagrees with solution at cell {index}")
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def validate_solution(solution: str, context: str) -> None:
|
| 191 |
+
expected = set("123456789")
|
| 192 |
+
rows = [solution[index : index + 9] for index in range(0, 81, 9)]
|
| 193 |
+
columns = [solution[index::9] for index in range(9)]
|
| 194 |
+
boxes = []
|
| 195 |
+
for box_row in range(3):
|
| 196 |
+
for box_col in range(3):
|
| 197 |
+
cells = []
|
| 198 |
+
for row in range(box_row * 3, box_row * 3 + 3):
|
| 199 |
+
start = row * 9 + box_col * 3
|
| 200 |
+
cells.extend(solution[start : start + 3])
|
| 201 |
+
boxes.append("".join(cells))
|
| 202 |
+
if any(set(unit) != expected for unit in rows + columns + boxes):
|
| 203 |
+
raise ValueError(f"{context}: invalid completed Sudoku solution")
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def iter_pool(source_dir: Path, spec: PoolSpec) -> Iterator[dict[str, object]]:
|
| 207 |
+
path = source_dir / Path(spec.relative_path)
|
| 208 |
+
with path.open("r", encoding="utf-8", newline="") as handle:
|
| 209 |
+
reader = csv.DictReader(handle)
|
| 210 |
+
required = {"quizzes", "solutions"}
|
| 211 |
+
if not required.issubset(reader.fieldnames or []):
|
| 212 |
+
raise ValueError(f"{path}: missing required columns {sorted(required)}")
|
| 213 |
+
for row_index, row in enumerate(reader):
|
| 214 |
+
puzzle = row["quizzes"].strip()
|
| 215 |
+
solution = row["solutions"].strip()
|
| 216 |
+
context = f"{spec.relative_path}:{row_index + 2}"
|
| 217 |
+
validate_strings(puzzle, solution, context)
|
| 218 |
+
clues = sum(char != "0" for char in puzzle)
|
| 219 |
+
|
| 220 |
+
if spec.is_original:
|
| 221 |
+
source_family = "original"
|
| 222 |
+
source_collection = "diffusion_vs_ar_original"
|
| 223 |
+
official_rating = None
|
| 224 |
+
rating_type = "not_rated"
|
| 225 |
+
else:
|
| 226 |
+
if row.get("dataset") != "sudoku_extreme":
|
| 227 |
+
raise ValueError(f"{context}: unexpected dataset family {row.get('dataset')!r}")
|
| 228 |
+
if row.get("difficulty_bucket") != spec.bucket:
|
| 229 |
+
raise ValueError(f"{context}: unexpected difficulty bucket")
|
| 230 |
+
if row.get("split") != spec.upstream_split:
|
| 231 |
+
raise ValueError(f"{context}: unexpected upstream split")
|
| 232 |
+
source_family = "sudoku_extreme"
|
| 233 |
+
source_collection = row["source"].strip()
|
| 234 |
+
official_rating = float(row["official_rating"])
|
| 235 |
+
rating_type = row["rating_type"].strip()
|
| 236 |
+
declared_clues = int(row["clues"])
|
| 237 |
+
if declared_clues != clues:
|
| 238 |
+
raise ValueError(
|
| 239 |
+
f"{context}: declared clues {declared_clues} != computed clues {clues}"
|
| 240 |
+
)
|
| 241 |
+
|
| 242 |
+
normalized_puzzle, normalized_solution = digit_normalized_pair(puzzle, solution)
|
| 243 |
+
record: dict[str, object] = {
|
| 244 |
+
"example_id": sha256_text(f"{puzzle}|{solution}"),
|
| 245 |
+
"puzzle_id": sha256_text(puzzle),
|
| 246 |
+
"digit_normalized_id": sha256_text(
|
| 247 |
+
f"{normalized_puzzle}|{normalized_solution}"
|
| 248 |
+
),
|
| 249 |
+
"puzzle": puzzle,
|
| 250 |
+
"solution": solution,
|
| 251 |
+
"difficulty_bucket": spec.bucket,
|
| 252 |
+
"difficulty_subbucket": subbucket(spec.bucket, official_rating),
|
| 253 |
+
"source_family": source_family,
|
| 254 |
+
"source_collection": source_collection,
|
| 255 |
+
"official_rating": official_rating,
|
| 256 |
+
"rating_type": rating_type,
|
| 257 |
+
"clues": clues,
|
| 258 |
+
"upstream_split": spec.upstream_split,
|
| 259 |
+
"source_file": spec.relative_path.replace("\\", "/"),
|
| 260 |
+
"source_row_index": row_index,
|
| 261 |
+
}
|
| 262 |
+
record["stratum"] = make_stratum(record)
|
| 263 |
+
yield record
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
def ordered_specs(split: str, priority: Sequence[str]) -> list[PoolSpec]:
|
| 267 |
+
return [POOLS[(bucket, split)] for bucket in priority]
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def scan_pools(
|
| 271 |
+
source_dir: Path,
|
| 272 |
+
specs: Sequence[PoolSpec],
|
| 273 |
+
*,
|
| 274 |
+
protected_puzzles: set[str] | None = None,
|
| 275 |
+
protected_digit_normalized: set[str] | None = None,
|
| 276 |
+
collect_all_ids: bool = False,
|
| 277 |
+
) -> dict[str, object]:
|
| 278 |
+
protected_puzzles = protected_puzzles or set()
|
| 279 |
+
protected_digit_normalized = protected_digit_normalized or set()
|
| 280 |
+
seen_puzzles: set[str] = set()
|
| 281 |
+
seen_digit_normalized: set[str] = set()
|
| 282 |
+
all_puzzles: set[str] = set()
|
| 283 |
+
all_digit_normalized: set[str] = set()
|
| 284 |
+
counts: dict[str, Counter[str]] = defaultdict(Counter)
|
| 285 |
+
stratum_groups: dict[str, str] = {}
|
| 286 |
+
raw_counts: Counter[str] = Counter()
|
| 287 |
+
accepted_counts: Counter[str] = Counter()
|
| 288 |
+
exclusions: Counter[str] = Counter()
|
| 289 |
+
|
| 290 |
+
for spec in specs:
|
| 291 |
+
for record in iter_pool(source_dir, spec):
|
| 292 |
+
raw_counts[spec.bucket] += 1
|
| 293 |
+
puzzle_id = str(record["puzzle_id"])
|
| 294 |
+
normalized_id = str(record["digit_normalized_id"])
|
| 295 |
+
if collect_all_ids:
|
| 296 |
+
all_puzzles.add(puzzle_id)
|
| 297 |
+
all_digit_normalized.add(normalized_id)
|
| 298 |
+
if puzzle_id in protected_puzzles:
|
| 299 |
+
exclusions["protected_exact_puzzle"] += 1
|
| 300 |
+
continue
|
| 301 |
+
if normalized_id in protected_digit_normalized:
|
| 302 |
+
exclusions["protected_digit_normalized"] += 1
|
| 303 |
+
continue
|
| 304 |
+
if puzzle_id in seen_puzzles:
|
| 305 |
+
exclusions["duplicate_exact_puzzle"] += 1
|
| 306 |
+
continue
|
| 307 |
+
if normalized_id in seen_digit_normalized:
|
| 308 |
+
exclusions["duplicate_digit_normalized"] += 1
|
| 309 |
+
continue
|
| 310 |
+
seen_puzzles.add(puzzle_id)
|
| 311 |
+
seen_digit_normalized.add(normalized_id)
|
| 312 |
+
stratum = str(record["stratum"])
|
| 313 |
+
group = str(record["difficulty_subbucket"])
|
| 314 |
+
if stratum in stratum_groups and stratum_groups[stratum] != group:
|
| 315 |
+
raise AssertionError(f"stratum {stratum} mapped to two groups")
|
| 316 |
+
stratum_groups[stratum] = group
|
| 317 |
+
counts[spec.bucket][stratum] += 1
|
| 318 |
+
accepted_counts[spec.bucket] += 1
|
| 319 |
+
|
| 320 |
+
if raw_counts[spec.bucket] != spec.expected_rows:
|
| 321 |
+
raise ValueError(
|
| 322 |
+
f"{spec.relative_path}: expected {spec.expected_rows} rows, "
|
| 323 |
+
f"found {raw_counts[spec.bucket]}"
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
return {
|
| 327 |
+
"counts": dict(counts),
|
| 328 |
+
"stratum_groups": stratum_groups,
|
| 329 |
+
"raw_counts": dict(raw_counts),
|
| 330 |
+
"accepted_counts": dict(accepted_counts),
|
| 331 |
+
"exclusions": dict(exclusions),
|
| 332 |
+
"seen_puzzles": seen_puzzles,
|
| 333 |
+
"seen_digit_normalized": seen_digit_normalized,
|
| 334 |
+
"all_puzzles": all_puzzles,
|
| 335 |
+
"all_digit_normalized": all_digit_normalized,
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
def allocate_proportional(counts: Mapping[str, int], total: int) -> dict[str, int]:
|
| 340 |
+
available = sum(counts.values())
|
| 341 |
+
if total < 0 or total > available:
|
| 342 |
+
raise ValueError(f"cannot allocate {total} rows from {available}")
|
| 343 |
+
if total == 0:
|
| 344 |
+
return {key: 0 for key in counts}
|
| 345 |
+
exact = {key: value * total / available for key, value in counts.items()}
|
| 346 |
+
allocation = {key: min(value, math.floor(exact[key])) for key, value in counts.items()}
|
| 347 |
+
remaining = total - sum(allocation.values())
|
| 348 |
+
order = sorted(
|
| 349 |
+
counts,
|
| 350 |
+
key=lambda key: (-(exact[key] - math.floor(exact[key])), key),
|
| 351 |
+
)
|
| 352 |
+
while remaining:
|
| 353 |
+
changed = False
|
| 354 |
+
for key in order:
|
| 355 |
+
if allocation[key] < counts[key]:
|
| 356 |
+
allocation[key] += 1
|
| 357 |
+
remaining -= 1
|
| 358 |
+
changed = True
|
| 359 |
+
if remaining == 0:
|
| 360 |
+
break
|
| 361 |
+
if not changed:
|
| 362 |
+
raise AssertionError("capacity-aware quota allocation stalled")
|
| 363 |
+
return allocation
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
def subtract_counts(
|
| 367 |
+
counts: Mapping[str, int], allocation: Mapping[str, int]
|
| 368 |
+
) -> dict[str, int]:
|
| 369 |
+
return {key: counts[key] - allocation.get(key, 0) for key in counts}
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
def add_allocations(*allocations: Mapping[str, int]) -> dict[str, int]:
|
| 373 |
+
result: Counter[str] = Counter()
|
| 374 |
+
for allocation in allocations:
|
| 375 |
+
result.update(allocation)
|
| 376 |
+
return dict(result)
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
def allocate_balanced_groups(
|
| 380 |
+
counts: Mapping[str, int],
|
| 381 |
+
stratum_groups: Mapping[str, str],
|
| 382 |
+
targets: Mapping[str, int],
|
| 383 |
+
) -> dict[str, int]:
|
| 384 |
+
allocation: dict[str, int] = {key: 0 for key in counts}
|
| 385 |
+
for group, target in targets.items():
|
| 386 |
+
group_counts = {
|
| 387 |
+
key: value for key, value in counts.items() if stratum_groups[key] == group
|
| 388 |
+
}
|
| 389 |
+
if not group_counts:
|
| 390 |
+
raise ValueError(f"no rows available for required group {group}")
|
| 391 |
+
allocation.update(allocate_proportional(group_counts, target))
|
| 392 |
+
if sum(allocation.values()) != sum(targets.values()):
|
| 393 |
+
raise AssertionError("balanced group allocation returned the wrong total")
|
| 394 |
+
return allocation
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
def allocation_rank(seed: str, scope: str, bucket: str, example_id: str) -> int:
|
| 398 |
+
digest = hashlib.sha256(f"{seed}|{scope}|{bucket}|{example_id}".encode()).digest()
|
| 399 |
+
return int.from_bytes(digest, byteorder="big", signed=False)
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
def collect_ranked_candidates(
|
| 403 |
+
source_dir: Path,
|
| 404 |
+
specs: Sequence[PoolSpec],
|
| 405 |
+
capacities: Mapping[str, int],
|
| 406 |
+
*,
|
| 407 |
+
seed: str,
|
| 408 |
+
scope: str,
|
| 409 |
+
protected_puzzles: set[str] | None = None,
|
| 410 |
+
protected_digit_normalized: set[str] | None = None,
|
| 411 |
+
) -> dict[str, list[dict[str, object]]]:
|
| 412 |
+
protected_puzzles = protected_puzzles or set()
|
| 413 |
+
protected_digit_normalized = protected_digit_normalized or set()
|
| 414 |
+
seen_puzzles: set[str] = set()
|
| 415 |
+
seen_digit_normalized: set[str] = set()
|
| 416 |
+
heaps: dict[str, list[tuple[int, str, dict[str, object]]]] = defaultdict(list)
|
| 417 |
+
|
| 418 |
+
for spec in specs:
|
| 419 |
+
for record in iter_pool(source_dir, spec):
|
| 420 |
+
puzzle_id = str(record["puzzle_id"])
|
| 421 |
+
normalized_id = str(record["digit_normalized_id"])
|
| 422 |
+
if puzzle_id in protected_puzzles or normalized_id in protected_digit_normalized:
|
| 423 |
+
continue
|
| 424 |
+
if puzzle_id in seen_puzzles or normalized_id in seen_digit_normalized:
|
| 425 |
+
continue
|
| 426 |
+
seen_puzzles.add(puzzle_id)
|
| 427 |
+
seen_digit_normalized.add(normalized_id)
|
| 428 |
+
|
| 429 |
+
stratum = str(record["stratum"])
|
| 430 |
+
capacity = capacities.get(stratum, 0)
|
| 431 |
+
if capacity == 0:
|
| 432 |
+
continue
|
| 433 |
+
rank = allocation_rank(seed, scope, spec.bucket, str(record["example_id"]))
|
| 434 |
+
record["_allocation_rank"] = rank
|
| 435 |
+
heap = heaps[stratum]
|
| 436 |
+
entry = (-rank, str(record["example_id"]), record)
|
| 437 |
+
if len(heap) < capacity:
|
| 438 |
+
heapq.heappush(heap, entry)
|
| 439 |
+
elif rank < -heap[0][0]:
|
| 440 |
+
heapq.heapreplace(heap, entry)
|
| 441 |
+
|
| 442 |
+
selected: dict[str, list[dict[str, object]]] = {}
|
| 443 |
+
for stratum, capacity in capacities.items():
|
| 444 |
+
records = [entry[2] for entry in heaps.get(stratum, [])]
|
| 445 |
+
records.sort(key=lambda record: (int(record["_allocation_rank"]), record["example_id"]))
|
| 446 |
+
if len(records) != capacity:
|
| 447 |
+
raise ValueError(
|
| 448 |
+
f"stratum {stratum}: selected {len(records)} rows, expected {capacity}"
|
| 449 |
+
)
|
| 450 |
+
selected[stratum] = records
|
| 451 |
+
return selected
|
| 452 |
+
|
| 453 |
+
|
| 454 |
+
def assign_release_rows(
|
| 455 |
+
selected: Mapping[str, Sequence[dict[str, object]]],
|
| 456 |
+
first_allocation: Mapping[str, int],
|
| 457 |
+
second_allocation: Mapping[str, int] | None,
|
| 458 |
+
*,
|
| 459 |
+
first_split: str,
|
| 460 |
+
second_split: str | None,
|
| 461 |
+
) -> tuple[list[dict[str, object]], list[dict[str, object]]]:
|
| 462 |
+
first_rows: list[dict[str, object]] = []
|
| 463 |
+
second_rows: list[dict[str, object]] = []
|
| 464 |
+
second_allocation = second_allocation or {}
|
| 465 |
+
for stratum, records in selected.items():
|
| 466 |
+
first_n = first_allocation.get(stratum, 0)
|
| 467 |
+
second_n = second_allocation.get(stratum, 0)
|
| 468 |
+
if len(records) != first_n + second_n:
|
| 469 |
+
raise AssertionError(f"allocation mismatch for {stratum}")
|
| 470 |
+
for record in records[:first_n]:
|
| 471 |
+
first_rows.append(finalize_record(record, first_split))
|
| 472 |
+
for record in records[first_n : first_n + second_n]:
|
| 473 |
+
if second_split is None:
|
| 474 |
+
raise AssertionError("second allocation supplied without a split name")
|
| 475 |
+
second_rows.append(finalize_record(record, second_split))
|
| 476 |
+
return first_rows, second_rows
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
def finalize_record(record: Mapping[str, object], release_split: str) -> dict[str, object]:
|
| 480 |
+
result = {key: value for key, value in record.items() if not key.startswith("_")}
|
| 481 |
+
bucket = str(result["difficulty_bucket"])
|
| 482 |
+
is_ood = bucket == "r5_19"
|
| 483 |
+
if release_split == "train":
|
| 484 |
+
role = "train_id"
|
| 485 |
+
elif release_split == "validation":
|
| 486 |
+
role = "validation_id"
|
| 487 |
+
elif release_split == "test":
|
| 488 |
+
role = "test_ood" if is_ood else "test_id"
|
| 489 |
+
elif release_split == "test_ood_confirm":
|
| 490 |
+
role = "confirm_ood"
|
| 491 |
+
else:
|
| 492 |
+
raise ValueError(f"unknown release split {release_split}")
|
| 493 |
+
result["release_split"] = release_split
|
| 494 |
+
result["evaluation_role"] = role
|
| 495 |
+
result["is_ood"] = is_ood
|
| 496 |
+
return result
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
def stable_output_order(rows: list[dict[str, object]], seed: str, split: str) -> None:
|
| 500 |
+
rows.sort(
|
| 501 |
+
key=lambda row: sha256_text(f"{seed}|output|{split}|{row['example_id']}")
|
| 502 |
+
)
|
| 503 |
+
|
| 504 |
+
|
| 505 |
+
def strict_validate_selected(rows: Sequence[Mapping[str, object]]) -> None:
|
| 506 |
+
for row in rows:
|
| 507 |
+
context = f"selected:{row['release_split']}:{row['example_id']}"
|
| 508 |
+
validate_strings(str(row["puzzle"]), str(row["solution"]), context)
|
| 509 |
+
validate_solution(str(row["solution"]), context)
|
| 510 |
+
|
| 511 |
+
|
| 512 |
+
def summarize_rows(rows: Sequence[Mapping[str, object]]) -> dict[str, object]:
|
| 513 |
+
bucket_counts = Counter(str(row["difficulty_bucket"]) for row in rows)
|
| 514 |
+
subbucket_counts = Counter(str(row["difficulty_subbucket"]) for row in rows)
|
| 515 |
+
source_counts = Counter(str(row["source_collection"]) for row in rows)
|
| 516 |
+
clue_counts = [int(row["clues"]) for row in rows]
|
| 517 |
+
ratings = [float(row["official_rating"]) for row in rows if row["official_rating"] is not None]
|
| 518 |
+
return {
|
| 519 |
+
"rows": len(rows),
|
| 520 |
+
"difficulty_buckets": dict(sorted(bucket_counts.items())),
|
| 521 |
+
"difficulty_subbuckets": dict(sorted(subbucket_counts.items())),
|
| 522 |
+
"source_collections": dict(sorted(source_counts.items())),
|
| 523 |
+
"clues": {
|
| 524 |
+
"min": min(clue_counts),
|
| 525 |
+
"max": max(clue_counts),
|
| 526 |
+
"mean": sum(clue_counts) / len(clue_counts),
|
| 527 |
+
},
|
| 528 |
+
"official_rating": (
|
| 529 |
+
{
|
| 530 |
+
"min": min(ratings),
|
| 531 |
+
"max": max(ratings),
|
| 532 |
+
"mean": sum(ratings) / len(ratings),
|
| 533 |
+
}
|
| 534 |
+
if ratings
|
| 535 |
+
else None
|
| 536 |
+
),
|
| 537 |
+
"unique_example_ids": len({str(row["example_id"]) for row in rows}),
|
| 538 |
+
"unique_puzzle_ids": len({str(row["puzzle_id"]) for row in rows}),
|
| 539 |
+
"unique_digit_normalized_ids": len(
|
| 540 |
+
{str(row["digit_normalized_id"]) for row in rows}
|
| 541 |
+
),
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
|
| 545 |
+
def overlap_audit(splits: Mapping[str, Sequence[Mapping[str, object]]]) -> dict[str, object]:
|
| 546 |
+
identifiers = ("example_id", "puzzle_id", "digit_normalized_id")
|
| 547 |
+
sets = {
|
| 548 |
+
split: {identifier: {str(row[identifier]) for row in rows} for identifier in identifiers}
|
| 549 |
+
for split, rows in splits.items()
|
| 550 |
+
}
|
| 551 |
+
pairwise: dict[str, dict[str, int]] = {}
|
| 552 |
+
split_names = list(splits)
|
| 553 |
+
for left_index, left in enumerate(split_names):
|
| 554 |
+
for right in split_names[left_index + 1 :]:
|
| 555 |
+
key = f"{left}__vs__{right}"
|
| 556 |
+
pairwise[key] = {
|
| 557 |
+
identifier: len(sets[left][identifier] & sets[right][identifier])
|
| 558 |
+
for identifier in identifiers
|
| 559 |
+
}
|
| 560 |
+
if any(value for result in pairwise.values() for value in result.values()):
|
| 561 |
+
raise ValueError(f"cross-split overlap detected: {pairwise}")
|
| 562 |
+
return pairwise
|
| 563 |
+
|
| 564 |
+
|
| 565 |
+
def write_parquet(path: Path, rows: list[dict[str, object]]) -> None:
|
| 566 |
+
table = pa.Table.from_pylist(rows, schema=SCHEMA)
|
| 567 |
+
pq.write_table(
|
| 568 |
+
table,
|
| 569 |
+
path,
|
| 570 |
+
compression="zstd",
|
| 571 |
+
compression_level=9,
|
| 572 |
+
use_dictionary=True,
|
| 573 |
+
write_statistics=True,
|
| 574 |
+
row_group_size=8_192,
|
| 575 |
+
)
|
| 576 |
+
|
| 577 |
+
|
| 578 |
+
def write_json(path: Path, value: object) -> None:
|
| 579 |
+
path.write_text(
|
| 580 |
+
json.dumps(value, indent=2, sort_keys=True, ensure_ascii=False, allow_nan=False) + "\n",
|
| 581 |
+
encoding="utf-8",
|
| 582 |
+
)
|
| 583 |
+
|
| 584 |
+
|
| 585 |
+
def source_metadata(source_dir: Path, specs: Iterable[PoolSpec]) -> dict[str, object]:
|
| 586 |
+
result: dict[str, object] = {}
|
| 587 |
+
for spec in sorted(set(specs), key=lambda item: item.relative_path):
|
| 588 |
+
path = source_dir / spec.relative_path
|
| 589 |
+
result[spec.relative_path] = {
|
| 590 |
+
"bytes": path.stat().st_size,
|
| 591 |
+
"sha256": sha256_file(path),
|
| 592 |
+
"expected_rows": spec.expected_rows,
|
| 593 |
+
"upstream_split": spec.upstream_split,
|
| 594 |
+
"difficulty_bucket": spec.bucket,
|
| 595 |
+
}
|
| 596 |
+
return result
|
| 597 |
+
|
| 598 |
+
|
| 599 |
+
def render_readme(dataset_id: str, seed: str) -> str:
|
| 600 |
+
return f"""---
|
| 601 |
+
license: other
|
| 602 |
+
task_categories:
|
| 603 |
+
- text-generation
|
| 604 |
+
tags:
|
| 605 |
+
- sudoku
|
| 606 |
+
- reasoning
|
| 607 |
+
- planning
|
| 608 |
+
- discrete-diffusion
|
| 609 |
+
- out-of-distribution
|
| 610 |
+
pretty_name: Sudoku DLM Reasoning
|
| 611 |
+
configs:
|
| 612 |
+
- config_name: default
|
| 613 |
+
data_files:
|
| 614 |
+
- split: train
|
| 615 |
+
path: data/train.parquet
|
| 616 |
+
- split: validation
|
| 617 |
+
path: data/validation.parquet
|
| 618 |
+
- split: test
|
| 619 |
+
path: data/test.parquet
|
| 620 |
+
- split: test_ood_confirm
|
| 621 |
+
path: data/test_ood_confirm.parquet
|
| 622 |
+
---
|
| 623 |
+
|
| 624 |
+
# Sudoku DLM Reasoning
|
| 625 |
+
|
| 626 |
+
`{dataset_id}` is a deterministic 9x9 Sudoku benchmark for studying masked
|
| 627 |
+
diffusion language models, depth, and iterative decoding. Version {DATASET_VERSION}
|
| 628 |
+
trains only on `original`, `r0`, and `r1_4`; `r5_19` is held out for adjacent
|
| 629 |
+
difficulty extrapolation.
|
| 630 |
+
|
| 631 |
+
## Splits
|
| 632 |
+
|
| 633 |
+
| split | original | r0 | r1_4 | r5_19 | total |
|
| 634 |
+
|---|---:|---:|---:|---:|---:|
|
| 635 |
+
| train | 65,536 | 65,536 | 65,536 | 0 | 196,608 |
|
| 636 |
+
| validation | 2,048 | 2,048 | 2,048 | 0 | 6,144 |
|
| 637 |
+
| test | 1,000 | 1,000 | 1,000 | 1,000 | 4,000 |
|
| 638 |
+
| test_ood_confirm | 0 | 0 | 0 | 4,000 | 4,000 |
|
| 639 |
+
|
| 640 |
+
The primary zero-shot protocol selects the checkpoint, decoding strategy, and
|
| 641 |
+
number of decoding steps using only `validation`. It must not use `r5_19` before
|
| 642 |
+
the final `test` evaluation. `test_ood_confirm` is reserved for confirming a
|
| 643 |
+
small number of already-selected configurations; it is not a tuning split.
|
| 644 |
+
|
| 645 |
+
## Difficulty
|
| 646 |
+
|
| 647 |
+
`r0`, `r1_4`, and `r5_19` use the number of tdoku backtracks. Higher values are
|
| 648 |
+
harder. `original` comes from a separate easy Sudoku collection and is not on the
|
| 649 |
+
same numeric scale.
|
| 650 |
+
|
| 651 |
+
The evaluation sample deliberately covers subranges:
|
| 652 |
+
|
| 653 |
+
- `r1_4`: `[1,2)`, `[2,3)`, `[3,4)`, `[4,5)`
|
| 654 |
+
- `r5_19`: `[5,8)`, `[8,12)`, `[12,16)`, `[16,20)`
|
| 655 |
+
|
| 656 |
+
The 1,000-row test allocation uses 250 rows from each subrange. The 4,000-row
|
| 657 |
+
confirmation allocation uses 1,000 rows from each `r5_19` subrange. Within a
|
| 658 |
+
subrange, source collection and clue count retain their upstream proportions.
|
| 659 |
+
|
| 660 |
+
## Deterministic construction
|
| 661 |
+
|
| 662 |
+
- Upstream repository: [`{SOURCE_REPO}`](https://huggingface.co/datasets/{SOURCE_REPO})
|
| 663 |
+
- Pinned upstream revision: `{SOURCE_REVISION}`
|
| 664 |
+
- Release seed: `{seed}`
|
| 665 |
+
- Sampling: proportional metadata-stratified bottom-k by SHA-256 rank
|
| 666 |
+
- Leakage checks: exact puzzle plus digit-renaming-normalized puzzle/solution pair
|
| 667 |
+
- Validation: 81-character format, clue consistency, and Sudoku row/column/box validity
|
| 668 |
+
|
| 669 |
+
The source train/test boundary is preserved. Validation rows come only from
|
| 670 |
+
unused upstream training rows. Test and confirmation rows come only from upstream
|
| 671 |
+
test files. Full file hashes, row provenance, exclusions, and pairwise overlap
|
| 672 |
+
checks are in `metadata/manifest.json` and `metadata/audit.json`.
|
| 673 |
+
|
| 674 |
+
The upstream Sudoku Extreme corpus states that its official train and test sets
|
| 675 |
+
are mathematically inequivalent. This release additionally audits exact and digit
|
| 676 |
+
renaming overlap across the mixed original/Extreme sources. It does not implement
|
| 677 |
+
full canonicalization over every Sudoku row, column, band, stack, and transpose
|
| 678 |
+
symmetry; that remains a documented limitation.
|
| 679 |
+
|
| 680 |
+
## Schema
|
| 681 |
+
|
| 682 |
+
The main columns are `puzzle`, `solution`, `difficulty_bucket`,
|
| 683 |
+
`difficulty_subbucket`, `official_rating`, `clues`, `source_collection`, and
|
| 684 |
+
`release_split`. `example_id`, `puzzle_id`, and `digit_normalized_id` are stable
|
| 685 |
+
SHA-256 identifiers. `source_file` and `source_row_index` provide exact provenance.
|
| 686 |
+
|
| 687 |
+
```python
|
| 688 |
+
from datasets import load_dataset
|
| 689 |
+
|
| 690 |
+
dataset = load_dataset("{dataset_id}")
|
| 691 |
+
train = dataset["train"]
|
| 692 |
+
validation = dataset["validation"]
|
| 693 |
+
test = dataset["test"]
|
| 694 |
+
```
|
| 695 |
+
|
| 696 |
+
Puzzles and solutions are 81-character row-major strings. `0` denotes an empty
|
| 697 |
+
cell in `puzzle`.
|
| 698 |
+
|
| 699 |
+
## Rebuild
|
| 700 |
+
|
| 701 |
+
Download the pinned source CSV files listed in `metadata/manifest.json`, then run:
|
| 702 |
+
|
| 703 |
+
```bash
|
| 704 |
+
python scripts/build_dataset.py \\
|
| 705 |
+
--source-dir /path/to/source \\
|
| 706 |
+
--output-dir /path/to/release \\
|
| 707 |
+
--dataset-id {dataset_id} \\
|
| 708 |
+
--seed {seed}
|
| 709 |
+
```
|
| 710 |
+
|
| 711 |
+
The builder requires Python 3.10+ and PyArrow.
|
| 712 |
+
|
| 713 |
+
## Attribution and license
|
| 714 |
+
|
| 715 |
+
The data is derived from
|
| 716 |
+
[`fhyfhy/diffusion-vs-ar-hard-sudoku`](https://huggingface.co/datasets/{SOURCE_REPO}),
|
| 717 |
+
which packages the original Sudoku data from
|
| 718 |
+
[`HKUNLP/diffusion-vs-ar`](https://github.com/HKUNLP/diffusion-vs-ar) and the
|
| 719 |
+
[`sapientinc/sudoku-extreme`](https://huggingface.co/datasets/sapientinc/sudoku-extreme)
|
| 720 |
+
corpus. Please consult and comply with the licenses and attribution requirements
|
| 721 |
+
of all upstream sources. This derived release does not grant rights beyond them.
|
| 722 |
+
"""
|
| 723 |
+
|
| 724 |
+
|
| 725 |
+
def build_dataset(
|
| 726 |
+
source_dir: Path,
|
| 727 |
+
output_dir: Path,
|
| 728 |
+
*,
|
| 729 |
+
dataset_id: str,
|
| 730 |
+
seed: str,
|
| 731 |
+
) -> None:
|
| 732 |
+
if not source_dir.is_dir():
|
| 733 |
+
raise FileNotFoundError(f"source directory does not exist: {source_dir}")
|
| 734 |
+
if output_dir.exists() and any(output_dir.iterdir()):
|
| 735 |
+
raise FileExistsError(f"output directory must be absent or empty: {output_dir}")
|
| 736 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
| 737 |
+
data_dir = output_dir / "data"
|
| 738 |
+
metadata_dir = output_dir / "metadata"
|
| 739 |
+
scripts_dir = output_dir / "scripts"
|
| 740 |
+
data_dir.mkdir()
|
| 741 |
+
metadata_dir.mkdir()
|
| 742 |
+
scripts_dir.mkdir()
|
| 743 |
+
|
| 744 |
+
test_specs = ordered_specs("test", TEST_PRIORITY)
|
| 745 |
+
train_specs = ordered_specs("train", TRAIN_PRIORITY)
|
| 746 |
+
|
| 747 |
+
print("[1/8] Scanning and de-duplicating all protected upstream test pools...")
|
| 748 |
+
test_scan = scan_pools(source_dir, test_specs, collect_all_ids=True)
|
| 749 |
+
|
| 750 |
+
print("[2/8] Scanning train pools and excluding all test-equivalent rows...")
|
| 751 |
+
train_scan = scan_pools(
|
| 752 |
+
source_dir,
|
| 753 |
+
train_specs,
|
| 754 |
+
protected_puzzles=test_scan["all_puzzles"],
|
| 755 |
+
protected_digit_normalized=test_scan["all_digit_normalized"],
|
| 756 |
+
)
|
| 757 |
+
|
| 758 |
+
train_allocations: dict[str, dict[str, int]] = {}
|
| 759 |
+
validation_allocations: dict[str, dict[str, int]] = {}
|
| 760 |
+
for bucket in TRAIN_PRIORITY:
|
| 761 |
+
counts = train_scan["counts"][bucket]
|
| 762 |
+
train_quota = allocate_proportional(counts, TRAIN_PER_BUCKET)
|
| 763 |
+
validation_quota = allocate_proportional(
|
| 764 |
+
subtract_counts(counts, train_quota), VALIDATION_PER_BUCKET
|
| 765 |
+
)
|
| 766 |
+
train_allocations[bucket] = train_quota
|
| 767 |
+
validation_allocations[bucket] = validation_quota
|
| 768 |
+
|
| 769 |
+
test_allocations: dict[str, dict[str, int]] = {}
|
| 770 |
+
confirm_allocations: dict[str, dict[str, int]] = {}
|
| 771 |
+
for bucket in TEST_PRIORITY:
|
| 772 |
+
counts = test_scan["counts"][bucket]
|
| 773 |
+
if bucket in {"original", "r0"}:
|
| 774 |
+
test_quota = allocate_proportional(counts, TEST_PER_BUCKET)
|
| 775 |
+
elif bucket == "r1_4":
|
| 776 |
+
test_quota = allocate_balanced_groups(
|
| 777 |
+
counts,
|
| 778 |
+
test_scan["stratum_groups"],
|
| 779 |
+
{"r1_2": 250, "r2_3": 250, "r3_4": 250, "r4_5": 250},
|
| 780 |
+
)
|
| 781 |
+
else:
|
| 782 |
+
test_quota = allocate_balanced_groups(
|
| 783 |
+
counts,
|
| 784 |
+
test_scan["stratum_groups"],
|
| 785 |
+
{"r5_7": 250, "r8_11": 250, "r12_15": 250, "r16_19": 250},
|
| 786 |
+
)
|
| 787 |
+
test_allocations[bucket] = test_quota
|
| 788 |
+
remaining = subtract_counts(counts, test_quota)
|
| 789 |
+
if bucket == "r5_19":
|
| 790 |
+
confirm_allocations[bucket] = allocate_balanced_groups(
|
| 791 |
+
remaining,
|
| 792 |
+
test_scan["stratum_groups"],
|
| 793 |
+
{
|
| 794 |
+
"r5_7": 1_000,
|
| 795 |
+
"r8_11": 1_000,
|
| 796 |
+
"r12_15": 1_000,
|
| 797 |
+
"r16_19": 1_000,
|
| 798 |
+
},
|
| 799 |
+
)
|
| 800 |
+
else:
|
| 801 |
+
confirm_allocations[bucket] = {key: 0 for key in counts}
|
| 802 |
+
|
| 803 |
+
train_quota_all = add_allocations(*train_allocations.values())
|
| 804 |
+
validation_quota_all = add_allocations(*validation_allocations.values())
|
| 805 |
+
test_quota_all = add_allocations(*test_allocations.values())
|
| 806 |
+
confirm_quota_all = add_allocations(*confirm_allocations.values())
|
| 807 |
+
|
| 808 |
+
print("[3/8] Selecting deterministic train and validation rows...")
|
| 809 |
+
selected_train = collect_ranked_candidates(
|
| 810 |
+
source_dir,
|
| 811 |
+
train_specs,
|
| 812 |
+
add_allocations(train_quota_all, validation_quota_all),
|
| 813 |
+
seed=seed,
|
| 814 |
+
scope="train_validation",
|
| 815 |
+
protected_puzzles=test_scan["all_puzzles"],
|
| 816 |
+
protected_digit_normalized=test_scan["all_digit_normalized"],
|
| 817 |
+
)
|
| 818 |
+
train_rows, validation_rows = assign_release_rows(
|
| 819 |
+
selected_train,
|
| 820 |
+
train_quota_all,
|
| 821 |
+
validation_quota_all,
|
| 822 |
+
first_split="train",
|
| 823 |
+
second_split="validation",
|
| 824 |
+
)
|
| 825 |
+
|
| 826 |
+
print("[4/8] Selecting deterministic ID/OOD test and OOD confirmation rows...")
|
| 827 |
+
selected_test = collect_ranked_candidates(
|
| 828 |
+
source_dir,
|
| 829 |
+
test_specs,
|
| 830 |
+
add_allocations(test_quota_all, confirm_quota_all),
|
| 831 |
+
seed=seed,
|
| 832 |
+
scope="test_confirm",
|
| 833 |
+
)
|
| 834 |
+
test_rows, confirm_rows = assign_release_rows(
|
| 835 |
+
selected_test,
|
| 836 |
+
test_quota_all,
|
| 837 |
+
confirm_quota_all,
|
| 838 |
+
first_split="test",
|
| 839 |
+
second_split="test_ood_confirm",
|
| 840 |
+
)
|
| 841 |
+
|
| 842 |
+
splits = {
|
| 843 |
+
"train": train_rows,
|
| 844 |
+
"validation": validation_rows,
|
| 845 |
+
"test": test_rows,
|
| 846 |
+
"test_ood_confirm": confirm_rows,
|
| 847 |
+
}
|
| 848 |
+
expected_sizes = {
|
| 849 |
+
"train": 3 * TRAIN_PER_BUCKET,
|
| 850 |
+
"validation": 3 * VALIDATION_PER_BUCKET,
|
| 851 |
+
"test": 4 * TEST_PER_BUCKET,
|
| 852 |
+
"test_ood_confirm": OOD_CONFIRM_SIZE,
|
| 853 |
+
}
|
| 854 |
+
for split, rows in splits.items():
|
| 855 |
+
if len(rows) != expected_sizes[split]:
|
| 856 |
+
raise AssertionError(f"{split}: got {len(rows)}, expected {expected_sizes[split]}")
|
| 857 |
+
stable_output_order(rows, seed, split)
|
| 858 |
+
|
| 859 |
+
print("[5/8] Strictly validating every selected puzzle and solution...")
|
| 860 |
+
for rows in splits.values():
|
| 861 |
+
strict_validate_selected(rows)
|
| 862 |
+
overlaps = overlap_audit(splits)
|
| 863 |
+
|
| 864 |
+
print("[6/8] Writing Parquet splits...")
|
| 865 |
+
parquet_paths: dict[str, Path] = {}
|
| 866 |
+
for split, rows in splits.items():
|
| 867 |
+
path = data_dir / f"{split}.parquet"
|
| 868 |
+
write_parquet(path, rows)
|
| 869 |
+
parquet_paths[split] = path
|
| 870 |
+
|
| 871 |
+
split_summaries = {split: summarize_rows(rows) for split, rows in splits.items()}
|
| 872 |
+
audit = {
|
| 873 |
+
"dataset_version": DATASET_VERSION,
|
| 874 |
+
"seed": seed,
|
| 875 |
+
"selected_splits": split_summaries,
|
| 876 |
+
"pairwise_overlap": overlaps,
|
| 877 |
+
"source_test_scan": {
|
| 878 |
+
key: test_scan[key]
|
| 879 |
+
for key in ("raw_counts", "accepted_counts", "exclusions")
|
| 880 |
+
},
|
| 881 |
+
"source_train_scan": {
|
| 882 |
+
key: train_scan[key]
|
| 883 |
+
for key in ("raw_counts", "accepted_counts", "exclusions")
|
| 884 |
+
},
|
| 885 |
+
"symmetry_audit_scope": {
|
| 886 |
+
"exact_puzzle": True,
|
| 887 |
+
"digit_renaming": True,
|
| 888 |
+
"full_row_column_band_stack_transpose_group": False,
|
| 889 |
+
},
|
| 890 |
+
"strict_selected_rows_verified": sum(len(rows) for rows in splits.values()),
|
| 891 |
+
}
|
| 892 |
+
write_json(metadata_dir / "audit.json", audit)
|
| 893 |
+
|
| 894 |
+
split_spec = {
|
| 895 |
+
"dataset_version": DATASET_VERSION,
|
| 896 |
+
"seed": seed,
|
| 897 |
+
"training_buckets": ["original", "r0", "r1_4"],
|
| 898 |
+
"ood_bucket": "r5_19",
|
| 899 |
+
"counts": {
|
| 900 |
+
"train_per_bucket": TRAIN_PER_BUCKET,
|
| 901 |
+
"validation_per_bucket": VALIDATION_PER_BUCKET,
|
| 902 |
+
"test_per_bucket": TEST_PER_BUCKET,
|
| 903 |
+
"test_ood_confirm": OOD_CONFIRM_SIZE,
|
| 904 |
+
},
|
| 905 |
+
"test_subbucket_targets": {
|
| 906 |
+
"r1_4": {"r1_2": 250, "r2_3": 250, "r3_4": 250, "r4_5": 250},
|
| 907 |
+
"r5_19": {"r5_7": 250, "r8_11": 250, "r12_15": 250, "r16_19": 250},
|
| 908 |
+
},
|
| 909 |
+
"confirm_subbucket_targets": {
|
| 910 |
+
"r5_19": {
|
| 911 |
+
"r5_7": 1_000,
|
| 912 |
+
"r8_11": 1_000,
|
| 913 |
+
"r12_15": 1_000,
|
| 914 |
+
"r16_19": 1_000,
|
| 915 |
+
}
|
| 916 |
+
},
|
| 917 |
+
"selection": "metadata-stratified bottom-k SHA-256 rank",
|
| 918 |
+
"bucket_mix": "equal across training buckets; natural proportions within buckets",
|
| 919 |
+
}
|
| 920 |
+
write_json(metadata_dir / "split_spec.json", split_spec)
|
| 921 |
+
|
| 922 |
+
print("[7/8] Writing dataset card, provenance, and reproducibility files...")
|
| 923 |
+
(output_dir / "README.md").write_text(render_readme(dataset_id, seed), encoding="utf-8")
|
| 924 |
+
(output_dir / "requirements.txt").write_text(
|
| 925 |
+
"pyarrow>=17\n", encoding="utf-8"
|
| 926 |
+
)
|
| 927 |
+
shutil.copy2(Path(__file__), scripts_dir / "build_dataset.py")
|
| 928 |
+
|
| 929 |
+
all_specs = list(POOLS.values())
|
| 930 |
+
source_files = source_metadata(source_dir, all_specs)
|
| 931 |
+
release_files = {
|
| 932 |
+
path.relative_to(output_dir).as_posix(): {
|
| 933 |
+
"bytes": path.stat().st_size,
|
| 934 |
+
"sha256": sha256_file(path),
|
| 935 |
+
"rows": len(splits[split]),
|
| 936 |
+
}
|
| 937 |
+
for split, path in parquet_paths.items()
|
| 938 |
+
}
|
| 939 |
+
release_files["metadata/audit.json"] = {
|
| 940 |
+
"bytes": (metadata_dir / "audit.json").stat().st_size,
|
| 941 |
+
"sha256": sha256_file(metadata_dir / "audit.json"),
|
| 942 |
+
}
|
| 943 |
+
release_files["metadata/split_spec.json"] = {
|
| 944 |
+
"bytes": (metadata_dir / "split_spec.json").stat().st_size,
|
| 945 |
+
"sha256": sha256_file(metadata_dir / "split_spec.json"),
|
| 946 |
+
}
|
| 947 |
+
release_files["scripts/build_dataset.py"] = {
|
| 948 |
+
"bytes": (scripts_dir / "build_dataset.py").stat().st_size,
|
| 949 |
+
"sha256": sha256_file(scripts_dir / "build_dataset.py"),
|
| 950 |
+
}
|
| 951 |
+
manifest = {
|
| 952 |
+
"dataset_id": dataset_id,
|
| 953 |
+
"dataset_version": DATASET_VERSION,
|
| 954 |
+
"generated_at_utc": datetime.now(timezone.utc).isoformat(),
|
| 955 |
+
"seed": seed,
|
| 956 |
+
"source": {
|
| 957 |
+
"repo_id": SOURCE_REPO,
|
| 958 |
+
"revision": SOURCE_REVISION,
|
| 959 |
+
"files": source_files,
|
| 960 |
+
},
|
| 961 |
+
"schema": [{"name": field.name, "type": str(field.type)} for field in SCHEMA],
|
| 962 |
+
"splits": split_summaries,
|
| 963 |
+
"files": release_files,
|
| 964 |
+
"audit_file": "metadata/audit.json",
|
| 965 |
+
"split_spec_file": "metadata/split_spec.json",
|
| 966 |
+
}
|
| 967 |
+
write_json(metadata_dir / "manifest.json", manifest)
|
| 968 |
+
|
| 969 |
+
print("[8/8] Build complete.")
|
| 970 |
+
print(json.dumps({"output_dir": str(output_dir), "splits": expected_sizes}, indent=2))
|
| 971 |
+
|
| 972 |
+
|
| 973 |
+
def main() -> None:
|
| 974 |
+
args = parse_args()
|
| 975 |
+
build_dataset(
|
| 976 |
+
args.source_dir.resolve(),
|
| 977 |
+
args.output_dir.resolve(),
|
| 978 |
+
dataset_id=args.dataset_id,
|
| 979 |
+
seed=str(args.seed),
|
| 980 |
+
)
|
| 981 |
+
|
| 982 |
+
|
| 983 |
+
if __name__ == "__main__":
|
| 984 |
+
main()
|