File size: 4,956 Bytes
73eb01c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
license: cc0-1.0
language: en
pretty_name: ChessModel-XPU formal teacher dataset
tags:
  - chess
  - alphazero
  - stockfish
  - knowledge-distillation
  - game
  - reinforcement-learning
size_categories:
  - 1M<n<10M
---

# ChessModel-XPU formal teacher dataset

Stockfish-18-labeled chess positions used to train the
[`jinshuoli/chessmodel`](https://huggingface.co/jinshuoli/chessmodel) checkpoint,
part of the [ChessModel-XPU](https://github.com/JinShuo-Li/ChessModel) project.

It is a **custom-format** dataset of bit-packed board tensors plus sparse
Stockfish-derived policy / WDL targets. It is **not** loadable with
`datasets.load_dataset(...)`; use the project's `TeacherDataset` loader (see
below). Game-level train/validation split — adjacent positions from the same game
are never spread across splits.

## Source and provenance

| | |
|---|---|
| Source games | [Lichess Elite database, December 2023](https://database.lichess.org/) (`lichess_elite_2023-12`), licensed **CC0 1.0** |
| Source SHA-256 | `a6a5a8253cf357d31b7b5c1895a63dfbf64cc93b4504398f748cb69a31c0eff0` |
| Teacher | Stockfish 18 — MultiPV 8, 10000 nodes/position, WDL enabled, temperature 0.15 |
| Split | Deterministic game-level 90 / 10 split, seed 7, minimum 16 plies per game |
| Prep script | [`scripts/prepare_formal_pgn.py`](https://github.com/JinShuo-Li/ChessModel/blob/main/scripts/prepare_formal_pgn.py) |

Preparation removed parse failures, non-standard start positions, games without a
decisive/draw result, short games (< 16 plies), and duplicate move sequences, then
made the deterministic game-level split.

## Contents

The dataset mirrors the repository layout, so downloading it into a clone of the
project makes the workflow commands resolve unchanged:

| Path | Description |
|---|---|
| `data/formal_1m_train/shard-00000…00244.npz` | 245 training shards |
| `data/formal_50k_validation/shard-*.npz` | 13 validation shards |
| `datasets/formal_train.pgn` | Source training PGN (game-level split) |
| `datasets/formal_validation.pgn` | Source validation PGN (game-level split) |
| `datasets/formal_pgn_metadata.json` | Provenance metadata (source hash, counts, split params) |

Total ≈ 370 MB.

## Statistics

From `datasets/formal_pgn_metadata.json`:

| | |
|---|---|
| Parsed games | 315,135 |
| Accepted games | 312,603 |
| Train / validation games | 281,003 / 31,600 |
| Train / validation positions | 2,971,862 / 334,836 |
| Validation percent | 10 |
| Seed | 7 |

## Shard format

Each `.npz` shard is a project-defined record containing:

- Bit-packed board planes (`112 × 8 × 8`, canonically oriented to the side to move:
  up to 8 history frames, castling rights, en-passant, side to move, halfmove and
  fullmove clocks).
- Sparse policy target over the AlphaZero `8×8×73 = 4672` move encoding.
- Win/Draw/Loss target derived from Stockfish WDL.
- A shard format version, per-shard SHA-256 integrity check, Stockfish/node
  metadata, and the FEN (for legal-move masking and audit).

`TeacherDataset` loads each shard's bit-packed boards and sparse targets once and
unpacks lazily, so the full million-position dataset stays out of resident memory.

## How to load

Clone the repo and download the dataset into it, then use the project loader:

```bash
git clone https://github.com/JinShuo-Li/ChessModel.git
cd ChessModel
hf download jinshuoli/chessmodel-data --repo-type dataset --local-dir .
```

```python
from torch.utils.data import DataLoader
from chess_ai.data.dataset import TeacherDataset

train = TeacherDataset("data/formal_1m_train")          # 245 shards
val   = TeacherDataset("data/formal_50k_validation")     # 13 shards
loader = DataLoader(train, batch_size=512, shuffle=True)
```

Verify integrity with the project's verifier:

```bash
python scripts/verify_teacher_dataset.py --dataset data/formal_1m_train
python scripts/verify_teacher_dataset.py --dataset data/formal_50k_validation
```

## Intended use and limitations

- **Intended:** training / evaluating compact neural chess models via Stockfish
  distillation, and reproducing the project's training pipeline.
- **Custom format:** not consumable by the HF dataset viewer or
  `datasets.load_dataset()`; requires the project's loader.
- **Labels are Stockfish outputs:** policy/WDL targets reflect Stockfish 18 search
  at the configured node budget, not human game outcomes (game results are used
  only for splitting/filtering).

## License and attribution

- Source game data: © Lichess, **CC0 1.0** (public domain).
- The loading code and preparation scripts are MIT-licensed in the
  [source repository](https://github.com/JinShuo-Li/ChessModel).
- Stockfish is used solely as a teacher/labeling tool and is **not** distributed
  here.

## Related

- Trained checkpoint: [`jinshuoli/chessmodel`](https://huggingface.co/jinshuoli/chessmodel)
- Source code & documentation: [github.com/JinShuo-Li/ChessModel](https://github.com/JinShuo-Li/ChessModel)