Dataset Viewer
The dataset viewer is not available for this subset.
Cannot get the split names for the config 'default' of the dataset.
Exception:    SplitsNotFoundError
Message:      The split names could not be parsed from the dataset config.
Traceback:    Traceback (most recent call last):
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 290, in _generate_tables
                  pa_table = paj.read_json(
                      io.BytesIO(batch), read_options=paj.ReadOptions(block_size=block_size)
                  )
                File "pyarrow/_json.pyx", line 342, in pyarrow._json.read_json
                File "pyarrow/error.pxi", line 155, in pyarrow.lib.pyarrow_internal_check_status
                  return check_status(status)
                File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
                  raise convert_status(status)
              pyarrow.lib.ArrowInvalid: JSON parse error: Column(/record_dtype/formats/[]/[]) changed from string to number in row 0
              
              During handling of the above exception, another exception occurred:
              
              Traceback (most recent call last):
                File "/usr/local/lib/python3.14/site-packages/datasets/inspect.py", line 286, in get_dataset_config_info
                  for split_generator in builder._split_generators(
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~^
                      StreamingDownloadManager(base_path=builder.base_path, download_config=download_config)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  )
                  ^
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 101, in _split_generators
                  pa_table = next(iter(self._generate_tables(**splits[0].gen_kwargs, allow_full_read=False)))[1]
                             ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 304, in _generate_tables
                  batch = json_encode_fields_in_json_lines(original_batch, json_field_paths)
                File "/usr/local/lib/python3.14/site-packages/datasets/utils/json.py", line 111, in json_encode_fields_in_json_lines
                  examples = [ujson_loads(line) for line in original_batch.splitlines()]
                              ~~~~~~~~~~~^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/utils/json.py", line 20, in ujson_loads
                  return pd.io.json.ujson_loads(*args, **kwargs)
                         ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
              ValueError: Expected object or value
              
              The above exception was the direct cause of the following exception:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/split_names.py", line 68, in compute_split_names_from_streaming_response
                  for split in get_dataset_split_names(
                               ~~~~~~~~~~~~~~~~~~~~~~~^
                      path=dataset,
                      ^^^^^^^^^^^^^
                      config_name=config,
                      ^^^^^^^^^^^^^^^^^^^
                      token=hf_token,
                      ^^^^^^^^^^^^^^^
                  )
                  ^
                File "/usr/local/lib/python3.14/site-packages/datasets/inspect.py", line 340, in get_dataset_split_names
                  info = get_dataset_config_info(
                      path,
                  ...<6 lines>...
                      **config_kwargs,
                  )
                File "/usr/local/lib/python3.14/site-packages/datasets/inspect.py", line 291, in get_dataset_config_info
                  raise SplitsNotFoundError("The split names could not be parsed from the dataset config.") from err
              datasets.inspect.SplitsNotFoundError: The split names could not be parsed from the dataset config.

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

ChessTransformer flat shards

Tokenized chess positions from Lichess, in a flat fixed-width format designed to be memory-mapped and read at hundreds of thousands of samples/s so it can feed a multi-GPU node.

Two sets, same record format, differing only in source corpus and positions-per-game:

set source games samples compressed decompressed notes
full_k4 26,269,077 105,076,308 4.8 GB 20 GB the large corpus; too big for a Kaggle working disk
elite_k16 1,533,352 24,498,538 967 MB 4.95 GB fits page cache on a 30 GB box, and Kaggle's ~20 GB disk

elite_k16 is the set every correctness measurement in the companion repo was taken against (encoding equivalence, the ply-distribution check, and the loss-equivalence gate against the original HDF5 pipeline). full_k4 is the one to train on at scale.

Pick by whether the set fits your RAM β€” that decision also flips the optimal num_workers; see the throughput note below.

Each row is one position plus the move actually played from it, the legal-move set, and the game outcome. Everything expensive β€” gzip decompression, the python-chess replay, legal-move enumeration, tokenizing β€” was paid once at build time.

Built by scripts/build_shards.py in the ChessTransformer repo. The design rationale and the measurements behind every choice below are in doc/dataset_shards.md there.

Contents

full_k4/   meta.json + shard_0000.npy.zst .. shard_0255.npy.zst   (~410,456 rows each)
elite_k16/ meta.json + shard_0000.npy.zst .. shard_0255.npy.zst   (~95,700 rows each)

Shards are zstd -3. meta.json in each directory is the complete build recipe: K, seed, sampling mode and weighting, ELO bounds, git sha, and per-shard game ranges and row counts.

The split table below is for full_k4; elite_k16 uses the same scheme with 5 val and 5 test shards (23,541,776 train / 478,073 val / 478,689 test samples).

split shards samples games
train the other 252 103,434,492 25,858,623
val 51, 102 820,908 205,227
test 153, 204 820,908 205,227

Splits reserve whole shards, and a shard is a contiguous range of games, so no game appears on two sides of the split. Splitting on samples instead would put positions from the same game in both train and val and make val loss quietly optimistic. The reserved shard ids are spread across the range rather than taken from the front, because games sit in roughly chronological order and the corpus drifts (both game length and ELO) β€” a prefix is not representative.

Record format

One row is 202 bytes, a packed NumPy structured dtype. Offsets are explicit so both uint16 fields land 2-byte aligned; an unaligned memmap view drops NumPy into a per-element copy on every gather.

offset dtype field notes
0–63 u1Γ—64 position board tokens, 0 = empty, 1–6 white P/N/B/R/Q/K, 7–12 black
64–191 u2Γ—64 legal_idx flat legal actions from_square*73 + plane, target first, 4672-padded
192 u1 legal_cnt valid entries in legal_idx
193 u1 from_square target move source, 0–63
194 u1 action_plane target move AlphaZero plane, 0–72
195 u1 castling_rights 4-bit mask, 0–15
196 u1 en_passant_file 0–7 = files a–h, 8 = none
197 u1 is_white side to move
198 i1 result 0 = draw, 1 = white win, 2 = black win
199 u1 β€” pad, keeps move_number aligned
200–201 u2 move_number ply index

The legal mask is stored as indices, not as a dense array. A (64, 73) bool mask is 4,672 bytes and would dominate the record 20:1; a fixed-width uint16 index list capped at C=64 is 129 bytes. Fixed width is what makes one memmap row equal one sample. The target move's index is written first, so clipping at the cap can only ever drop an alternative legal move, never the label β€” 3,390 of 105M rows (0.0032%) hit the cap.

Padding is 64*73 = 4672, one past the end of the action space, so a GPU scatter_ can park it in a scratch column that is then sliced off. Writing padding as 0 instead would mark square a1 / plane 0 legal on every single sample.

Usage

# swap full_k4 for elite_k16 if you want the smaller, page-cache-resident set
hf download tchauffi/chesstransformer-shards --repo-type dataset \
  --include 'full_k4/*' --local-dir data/shards
cd data/shards/full_k4 && ls *.zst | xargs -P 8 -I{} zstd -q -d --rm {}

Rebuilding the dense (B, 64, 73) mask belongs on the GPU, not in the dataloader β€” returning it from the loader would put 2.4 MB per batch of 512 back on the host-to-device wire, which is the cost this format exists to remove:

import numpy as np, torch

shard = np.load("full_k4/shard_0000.npy", mmap_mode="r")   # never np.load without mmap_mode
rows = shard[np.sort(np.random.default_rng(0).integers(0, len(shard), 512))]

idx = torch.from_numpy(np.ascontiguousarray(rows["legal_idx"]).astype(np.int64))
flat = torch.zeros(len(idx), 64 * 73 + 1, dtype=torch.bool)
flat.scatter_(1, idx, True)
legal_planes = flat[:, : 64 * 73].view(-1, 64, 73)         # the pad column is sliced off here

A ready loader (FlatShardDataset, batch-level gather, DistributedSampler-compatible) is in the ChessTransformer repo at src/chesstransformer/datasets/flat_shard_dataset.py.

Size num_workers by whether the shards fit page cache, not by core count. Measured on a 16-core box with 30 GB RAM:

workers elite_k16 (4.95 GB, cached) full_k4 (20 GB, NVMe)
0 144,272 22,424
1 68,796 165,791
4 115,585 379,329
8 138,911 439,824

Same code, opposite recommendation. Cached, a fetch is a memory read and the only variable cost is IPC, so 0 workers wins and one worker is worse than none. Uncached, every fetch is a 4 KB page fault and the cost is queue depth: 22,424 samples/s Γ— 4 KB β‰ˆ 22k IOPS is single-threaded random read at QD1, and 439,824 β‰ˆ 1.8 GB/s is what the drive does at depth 8. The workers stop being CPU parallelism and become I/O parallelism.

How it was built

uv run scripts/build_shards.py \
  --h5 data/elite_db_full.h5 --out data/shards/full_k4 \
  --positions-per-game 4 --num-shards 256 --val-shards 2 --test-shards 2 --workers 14

44.9 minutes on 14 cores (elite_k16: same script against elite_db.h5 with -k 16, 5.8 min).

Rather than materializing all 2.23 billion plies, K=4 positions per game are drawn at build time using the same triangular middlegame weighting the online sampler used, without replacement. The shard therefore is the sampling distribution and a consumer just shuffles uniformly. Measured total variation distance against the online sampler's ply marginal: 0.0035.

Reproducibility was verified, not assumed: rebuilding shards 7 and 200 of full_k4, and 11 and 77 of elite_k16, from commit b376cb3 with these settings reproduces this data byte-for-byte. Note the shards were built from the working tree that became that commit, so meta.json's original git_sha pointed one commit earlier; this is corrected and explained in its build_note.

Caveats

  • No ELO filter. Both sets contain all games in their source database (full_k4 median average ELO ~2426, 66.5% β‰₯2400; elite_k16 median ~2492, 82.7% β‰₯2400). The ChessTransformer trainer defaults to --min-elo 2400, so this is a superset of that default population. build_shards.py --min-elo applies the filter at build time if you want to match it.
  • The K positions per game are frozen. A consumer sees the same K positions from a given game every pass, where sampling online would draw fresh ones. At 105M samples this is unlikely to bind, but rebuilding with a different --seed is the fix if it ever does.
  • result is 0/1/2, not -1/0/1. It is the raw value from the source database.
  • is_white is a flag, not an index. If your loss uses it as a boolean mask, cast it β€” leaving it as uint8 silently turns masking into fancy indexing.

Provenance and license

Derived from the Lichess open database, which is released under CC0 1.0. This derived dataset is released under the same terms. Positions were encoded with the AlphaZero-style 8Γ—8Γ—73 action representation (Silver et al., 2018).

Downloads last month
541