Dataset Viewer
Duplicate
The dataset viewer is not available for this split.
The info cannot be fetched for the config 'default' of the dataset.
Error code:   InfoError
Exception:    HfHubHTTPError
Message:      (Request ID: Root=1-6a672ed9-55ba2a5f4eed19c24ba06a67;775e539c-1020-4309-ba6b-00477a92e6b8)

429 Too Many Requests: you have reached your 'api' rate limit.
Retry after 87 seconds (0/500 requests remaining in current 300s window).
Url: https://huggingface.co/api/datasets/shazmate/lichess-chess-tokens/revision/cb90f1bb2eab0b905e84e14f2d1d24ec5f9d1d94.
We had to rate limit your IP (52.1.96.215). To continue using our service, create a HF account or login to your existing account, and make sure you pass a HF_TOKEN if you're using the API.
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/split/first_rows.py", line 227, in compute_first_rows_from_streaming_response
                  info = get_dataset_config_info(path=dataset, config_name=config, token=hf_token)
                File "/usr/local/lib/python3.14/site-packages/datasets/inspect.py", line 268, in get_dataset_config_info
                  builder = load_dataset_builder(
                      path,
                  ...<6 lines>...
                      **config_kwargs,
                  )
                File "/src/services/worker/src/worker/utils.py", line 390, in safe_load_dataset_builder
                  dataset_module = dataset_module_factory(
                      repo_dir,
                      revision=revision,
                      download_config=download_config,
                  )
                File "/usr/local/lib/python3.14/site-packages/datasets/load.py", line 1217, in dataset_module_factory
                  raise e1 from None
                File "/usr/local/lib/python3.14/site-packages/datasets/load.py", line 1192, in dataset_module_factory
                  ).get_module()
                    ~~~~~~~~~~^^
                File "/usr/local/lib/python3.14/site-packages/datasets/load.py", line 608, in get_module
                  standalone_yaml_path = cached_path(
                      hf_dataset_url(self.name, config.REPOYAML_FILENAME, revision=self.commit_hash),
                      download_config=download_config,
                  )
                File "/usr/local/lib/python3.14/site-packages/datasets/utils/file_utils.py", line 180, in cached_path
                  ).resolve_path(url_or_filename)
                    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/huggingface_hub/hf_file_system.py", line 339, in resolve_path
                  repo_and_revision_exist, err = self._repo_and_revision_exist(parsed.type, parsed.id, revision)
                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/huggingface_hub/hf_file_system.py", line 252, in _repo_and_revision_exist
                  self._api.repo_info(
                  ~~~~~~~~~~~~~~~~~~~^
                      repo_id, revision=revision, repo_type=repo_type, timeout=constants.HF_HUB_ETAG_TIMEOUT
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  )
                  ^
                File "/usr/local/lib/python3.14/site-packages/huggingface_hub/utils/_validators.py", line 88, in _inner_fn
                  return fn(*args, **kwargs)
                File "/usr/local/lib/python3.14/site-packages/huggingface_hub/hf_api.py", line 3598, in repo_info
                  return method(
                      repo_id,
                  ...<4 lines>...
                      files_metadata=files_metadata,
                  )
                File "/usr/local/lib/python3.14/site-packages/huggingface_hub/utils/_validators.py", line 88, in _inner_fn
                  return fn(*args, **kwargs)
                File "/usr/local/lib/python3.14/site-packages/huggingface_hub/hf_api.py", line 3360, in dataset_info
                  hf_raise_for_status(r)
                  ~~~~~~~~~~~~~~~~~~~^^^
                File "/usr/local/lib/python3.14/site-packages/huggingface_hub/utils/_http.py", line 868, in hf_raise_for_status
                  raise _format(HfHubHTTPError, message, response) from e
              huggingface_hub.errors.HfHubHTTPError: (Request ID: Root=1-6a672ed9-55ba2a5f4eed19c24ba06a67;775e539c-1020-4309-ba6b-00477a92e6b8)
              
              429 Too Many Requests: you have reached your 'api' rate limit.
              Retry after 87 seconds (0/500 requests remaining in current 300s window).
              Url: https://huggingface.co/api/datasets/shazmate/lichess-chess-tokens/revision/cb90f1bb2eab0b905e84e14f2d1d24ec5f9d1d94.
              We had to rate limit your IP (52.1.96.215). To continue using our service, create a HF account or login to your existing account, and make sure you pass a HF_TOKEN if you're using the API.

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.

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Chess annotation tokeniser pipeline

Turns Lichess/standard-chess-games (Hugging Face) into a tokenised training dataset using the scheme:

[accuracy][mate/check][capture][promotion][base-move]
exf8=Q+??  ->  [??] [+] [x] [=Q] [ef8]
Nc6        ->  [Nc6]

Accuracy tokens ([?!] [?] [??]) come either from the glyphs Lichess embeds inline in analyzed games (--accuracy-source glyph, default) or are recomputed from the [%eval] comments via Lichess's win%-drop formula (--accuracy-source computed). Both are cross-checked; per-game disagreement counts are stored in the output.

The pipeline

Two stages. Stage 1 (build_dataset.py) turns raw movetext into an intermediate parquet of per-game annotated token strings + per-ply evals — human-readable, re-labellable, and independent of any model. Stage 2 (pack.py) frames those games with game/Elo tokens, maps every token to its frozen id from ../js/vocab-data.js, and streams the result into nanoGPT-style train.bin / val.bin.

HF Lichess parquet
      │  build_dataset.py   (filter [%eval] + Elo · parse · tokenise · per-ply cp)
      ▼
  tokenised/*.parquet       tokens="[Nf3] [x] [Bb5] [??] [e5] …"  + cp[] + metadata
      │  pack.py            (frame · map to frozen ids · time-split · uint16)
      ▼
  data/chess/{train.bin, val.bin, meta.pkl}   →  nanoGPT

Each game is framed with the vocab-v2 structural tokens:

<bos> <elo-W> <elo-B>   [move tokens…]   <eos>

<bos>/<eos> are the start/end-game tokens that separate games in the packed stream; the two <elo-*> buckets condition the model on each player's strength. These live at the end of ../js/vocab-data.js (ids 5252–5266), appended after the nerf tokens without disturbing any pre-existing id.

The training vocabulary is ../js/vocab-data.js (5,267 tokens), not build_dataset's vocab.json. That vocab.json is a frequency report over one run; the frozen dictionary is the geometry-derived superset of all legal SAN that the JS harness, the packed data, and the trained model all share. pack.py verifies coverage and drops (with a logged count) any game containing a token outside it — ~0 on real data.

Files

  • tokeniser.py — movetext parser, eval maths, classifier, tokeniser
  • build_dataset.py — Stage 1 CLI: streams HF parquet (or local files), filters to eval-annotated games, tokenises in parallel, writes zstd parquet + vocab
  • vocab.py — loads the frozen dictionary from ../js/vocab-data.js; owns the bracket→id translation, Elo bucketing, and <bos>/<eos> game framing
  • pack.py — Stage 2 CLI: frames + maps + time-splits into train.bin/ val.bin/meta.pkl
  • test_tokeniser.py, test_pack.py — unit tests (incl. a verbatim real game; the frozen vocab is checked for full coverage and JS↔Python parity)
  • gen_synthetic.py — offline validation corpus generator

Run

pip install duckdb pyarrow numpy
python test_tokeniser.py && python test_pack.py      # sanity check

# --- Stage 1: tokenise (needs internet access to huggingface.co) ---
# validation slice: ~200k games from one month (minutes)
python build_dataset.py --months 2025-05 --limit 200000 --out ./tok_slice

# real run: ~2 months ≈ 10-12M annotated games before filters
python build_dataset.py --months 2025-05 2025-06 --out ./tokenised \
    --min-elo 1600 --min-plies 20 --accuracy-source glyph

# --- Stage 2: pack for training (offline, local) ---
# hold out a whole month as validation (recommended — no leakage, tracks reality)
python pack.py --in ./tokenised --out ./data/chess --val-months 2025-06
# or a deterministic per-game fraction when everything is one month:
python pack.py --in ./tok_slice --out ./data/chess --val-frac 0.05

meta.pkl carries vocab_size, stoi, itos, and the <bos>/<eos> ids so nanoGPT's sample.py can print readable token streams.

To push the Stage 1 intermediate to your HF dataset repo:

pip install huggingface_hub && hf auth login
hf upload-large-folder <you>/lichess-annotated-tokenised --repo-type dataset ./tokenised

Output schema

column type notes
site string lichess game URL (id)
utc_date, time_control, result, eco string metadata for filtering
white_elo, black_elo int16
n_plies int16
tokens large_string space-joined token stream
cp list eval after each ply, White POV; mate → ±(30000−n); 30001 = missing
n_disagreements int16 plies where inline glyph ≠ computed label

Keeping cp per ply means you can re-derive labels under different thresholds later without re-pulling anything.

Measured performance (validation run)

100k synthetic games in the exact dump format, full pipeline, 2-core box: ~2,700 games/s (≈1,400/s/core), 0 SAN parse errors, output ≈ 276 bytes/game (zstd parquet). Extrapolation: 5M games ≈ 10 min of tokenisation on 8 cores; wall-clock is dominated by scanning the source parquet over the network (the contains(movetext, '[%eval') filter runs inside DuckDB, so only matching rows are materialised). Expect ~1.5 GB output per 5M games.

Downloads last month
93

Models trained or fine-tuned on shazmate/lichess-chess-tokens

Space using shazmate/lichess-chess-tokens 1