Minimal research code and data for the chess experiments in Learning to Imitate with Less: Efficient Individual Behavior Modeling in Chess (TMLR 2026).
This release evaluates Maia2, Maia2-Strength, Maia4All-Strength, and Maia4All-Prototype on the same 110 unseen players. Prototype achieves 54.43% accuracy / 4.0577 perplexity overall, exceeding the paper's Prototype accuracy and perplexity in every Table 1 column and Table 2 overall. It includes two explicitly documented extensions; the Master subgroup (under the paper's body Elo thresholds) and overall gain over Strength remain slightly below the paper. See RESULTS.md for the full comparison.
Requires Python 3.10–3.13 and PyTorch with CUDA. Run all commands from the repository root.
pip install -r requirements.txt
pip install -e .Checkpoints, fitted embeddings, and datasets are hosted on Hugging Face at
lilvjosephtang/maia4all.
To evaluate or refit personal embeddings on the 110 unseen players (downloads
checkpoints, pre-fitted embeddings, and unseen.tar.zst, skipping the 1.84 GB
prototype training cohort):
pip install huggingface_hub
hf download lilvjosephtang/maia4all --repo-type dataset \
--include "checkpoints/*" "results/*" "data/unseen.tar.zst" \
--local-dir .
mkdir -p data/unseen
tar --zstd -xf data/unseen.tar.zst -C data/unseenTo also rebuild enrichment and PMN from the 1,100-player prototype cohort, see TRAINING.md.
Evaluate the released checkpoints and embeddings (~2 minutes on one GPU):
python scripts/reproduce.py evaluate --device cuda:0
python scripts/reproduce.py tablesRefit all 15 personal embedding banks from scratch (3 adapted methods × 5 history lengths):
python scripts/prepare_data.py data/unseen data/unseen_train_cache --workers 8
python scripts/reproduce.py all --gpus 0 1 --jobs-per-gpu 2 --overwriteFor a single GPU, pass --gpus 0 --jobs-per-gpu 1. To run a new experiment
without overwriting results/, copy configs/paper.json,
change output_dir, and pass --config your_config.json.
| Method | Backbone | Personal embedding initialization |
|---|---|---|
| Maia2 | Original Maia2 | Population Elo lookup (no adaptation) |
| Maia2-Strength | Original Maia2 | Original Maia2 Elo embedding |
| Maia4All-Strength | Enriched Maia2 | Original Maia2 Elo embedding (Eq. 9) |
| Maia4All-Prototype | Enriched Maia2 | PMN-weighted top-10 prototype embeddings |
- Enrichment jointly trains a shared Maia2 policy backbone and 1,100 prototype embeddings.
- Prototype Matching Network (PMN) classifies prototype identity from
400-position before/after move histories using per-history normalization
(
HistoryNorm). At inference, logits are averaged across complete 400-position windows, and the top-10 softmax weights interpolate the corresponding prototype embeddings. - Adaptation freezes the backbone and optimizes a single 128-dimensional embedding per unseen player (applied to both player conditioning slots).
The released Maia4All-Prototype configuration includes two explicit extensions
selected on training-prefix holdout validation (no test-split tuning):
- Initialization anchor: adds
λ ||e − e_init||²to each player's mean training cross-entropy, withλ = 0.01atM ∈ {800, 2000}and0otherwise. - Population mixture: at inference mixes personal and frozen Maia2 move
probabilities as
(1 − α) p_personal + α p_Maia2before legal-move masking, withα = 0.5atM = 800andα = 0.25otherwise.
All adaptation runs use Adam, weight_decay = 0, and seed = 42
(configs/paper.json):
| M | 800 | 2,000 | 8,000 | 20,000 | 100,000 |
|---|---|---|---|---|---|
| Maia2-Strength updates | 60 | 100 | 100 | 100 | 100 |
| Maia4All-Strength updates | 10 | 40 | 100 | 100 | 100 |
| Maia4All-Prototype updates | 40 | 200 | 200 | 200 | 400 |
| Maia4All-Prototype lr | 0.003 | 0.003 | 0.01 | 0.01 | 0.01 |
Strength methods use lr = 0.01 across all M. Validation holds out the final
400 positions of each player's capped training prefix from both fitting and PMN
matching; final fitting uses the full capped prefix.
configs/
paper.json # Experiment configuration for Tables 1 and 2
scripts/
prepare_data.py # Build fast binary board cache from Parquet shards
train_enrichment.py # Refine the prototype-enriched backbone
train_pmn.py # Train the Prototype Matching Network
make_prototype_init.py # Compute top-10 PMN initializations for unseen players
reproduce.py # Adapt embeddings, evaluate, and render Tables 1 & 2
src/maia4all/
model.py # Self-contained Maia2 CNN + transformer backbone
personalization.py # Strength/prototype initialization and personal policy
enrichment.py # Prototype enrichment refinement loop
matching.py # PMN architecture, training, validation, and matching
adapt.py # Per-player embedding adaptation
evaluate.py # Unseen test-split evaluation
tables.py # Table 1 and Table 2 aggregation and Markdown rendering
dataset.py # Parquet reader and memory-mapped packed cache
chess_utils.py # Board encoding, Elo bins, and 1,880-move vocabulary
checkpoints.py # Checkpoint loading and saving
tests/ # Unit tests (pytest)
Downloaded assets populate checkpoints/, data/, and results/ (all
gitignored). See DATA_CARD.md for cohort splits and
preprocessing, and TRAINING.md for rebuilding the model stages.
This codebase uses a self-contained Maia2 implementation without depending on
external Maia2 packages. The released maia2.pt (2022-10) backbone has 5 CNN
residual blocks (~23.3M parameters); the paper's original 2021-05 checkpoint is
unavailable and Appendix Table 6 lists 12 blocks. Together with the two
extensions above, this release is a clean, reproducible extension rather than an
exact replay of the original training run.
@article{tang2026learning,
title={Learning to Imitate with Less: Efficient Individual Behavior Modeling in Chess},
author={Zhenwei Tang and Difan Jiao and Eric Xue and Reid McIlroy-Young and Jon Kleinberg and Siddhartha Sen and Ashton Anderson},
journal={Transactions on Machine Learning Research},
issn={2835-8856},
year={2026},
url={https://openreview.net/forum?id=iw4kjcw319}
}This project is licensed under the GNU General Public License v3.0 — see LICENSE.