--- license: mit library_name: chessnet tags: - chess - game-playing - alphazero - mcts - pytorch - onnx datasets: - nikaata007/chessnet-lichess-2000plus --- # chessnet-base The policy-value network of [chessnet](https://github.com/NikaAtanelishvili/chess-ai), an AlphaZero-style chess engine. Unlike AlphaZero, it learned by supervised learning from 77,107,653 positions of 979,935 Lichess games between players rated 2000 or more, not by self-play. Weights `chessnet-base-e1-20261126` (`e1` is input encoding version 1, not an epoch: the checkpoint is from epoch 5 of 5), released with chessnet 1.0.0 (tag `v1.0.0` here and on GitHub). Tag `v1.1.0` holds the same weights and adds the browser app's fp16 export. Given a position, the network returns a probability for each of its 4,672 move slots (the policy) and the chances of a win, a draw and a loss for the side to move (the value). Monte Carlo tree search (PUCT) uses both: the policy steers which moves the search explores, and the value scores the positions it reaches, in place of playing games out. The network alone predicts the move a 2000+ player made 54.7% of the time; with 800 playouts of search per move it rates 2557 on Stockfish's limited-strength UCI_Elo scale, which is not a human rating (see the caveat below). | File | Contents | |------|----------| | `model.safetensors` | the weights (a PyTorch state dict), loadable without pickle | | `config.json` | the architecture, input and output sizes, encoding version and provenance | | `model.onnx` | the ONNX export (dynamic batch size), the same file as the GitHub release's `base-best.onnx` | | `manifest.json` | the training dataset's manifest | | `model.fp16.onnx` | the same network in half precision (7.3 MB), the browser app's model, added in tag `v1.1.0`: its best move equals fp32's for 99.94% of the validation positions tested, and its value differs by 0.0006 on average ([docs/WEB_PERF.md](https://github.com/NikaAtanelishvili/chess-ai/blob/main/docs/WEB_PERF.md)) | | `SHA256SUMS` | the SHA-256 of the five files above | [chessnet-wide](https://huggingface.co/nikaata007/chessnet-wide) is a wider network trained on the same data for equal compute; its card compares the two. ## Architecture | | | |---|---| | Type | SE-ResNet policy-value network (a Leela Chess Zero-style residual tower) | | Trunk | 3x3 convolution of the 19 input planes to 128 channels, then 10 residual blocks of 128 filters (conv-BN-ReLU-conv-BN, squeeze-excitation, skip connection, ReLU) | | Squeeze-excitation | ratio 4: global average pooling, 128 → 32 (ReLU) → 256, one half a sigmoid scale per channel and the other a bias | | Policy head | 3x3 convolution (128 → 128), BN, ReLU, 1x1 convolution (128 → 73): 73 x 8 x 8 = 4,672 move logits | | Value head | 1x1 convolution (128 → 32), BN, ReLU, fully connected 2,048 → 128, ReLU, 128 → 3 logits: win, draw and loss for the side to move | | Parameters | 3,526,092 | | Input | 19 x 8 x 8 planes from the side to move's perspective, encoding version 1 (below) | ### Input and output encoding When Black is to move, the board is mirrored first (`board.mirror()` in python-chess: ranks flipped, colours, castling rights and the en-passant square swapped), so the side to move always looks like White. The planes are indexed `[plane, rank, file]` from that view, so `planes[:, 0, 0]` is a1: | Planes | Content | |--------|---------| | 0-5 | the mover's pawns, knights, bishops, rooks, queens, king (1 on each square holding one) | | 6-11 | the opponent's pieces, in the same order | | 12-15 | castling rights, each a constant plane: mover O-O, mover O-O-O, opponent O-O, opponent O-O-O | | 16 | the en-passant target square, only when an en-passant capture is legal | | 17 | the halfmove clock / 100, clipped to 1 (constant plane) | | 18 | all ones | The policy's 4,672 logits are AlphaZero's 73 move types on each of the 64 from-squares, flattened plane-major: index = plane x 64 + from-square, with square = 8 x rank + file in the mover's view. Planes 0-55 are queen-like moves (8 directions x 1 to 7 squares), 56-63 the 8 knight jumps, and 64-72 the 9 underpromotions (3 directions x knight, bishop, rook); a queen promotion is the queen-like move. For Black to move, mirror the decoded squares back (`chess.square_mirror`). The value logits are win, draw and loss for the side to move; the engine uses v = P(win) - P(loss). The reference implementation, which the engine and the training data use, is [`chessnet/encoding/`](https://github.com/NikaAtanelishvili/chess-ai/tree/main/src/chessnet/encoding): `board.py` for the planes and `moves.py` for the move index. ## Training Supervised learning on human games: the policy learns the move played (cross-entropy with label smoothing) and the value the game's result for the side to move (win/draw/loss cross-entropy). The loss is policy cross-entropy + 0.5 x value cross-entropy, with no legal-move mask. It was trained with `chessnet train` (chessnet 0.2.0.dev0, commit `fd50dcf`) on Kaggle. | Hyperparameter | Value | |----------------|-------| | Optimizer | AdamW, β1 = 0.9, β2 = 0.999, ε = 1e-08 | | Learning rate | 0.001 (peak) | | Weight decay | 0.0001 on convolution and linear weights; none on biases and batch-norm parameters | | Schedule | linear warmup over 2,000 steps, then cosine decay to 0.01 x the peak at step 187,860 | | Batch size | 2,048 positions | | Epochs | 5, 187,860 steps (completed) | | Checkpoint | step 182,500 (epoch 5), the lowest validation loss | | Label smoothing | 0.05 (policy) | | Value-loss weight | 0.5 | | Gradient clipping | global norm 5 | | Precision | fp16 autocast (AMP) with a GradScaler | | torch.compile | yes | | Seed | 0 | | Hardware | one T4 GPU (GPU 0 of Kaggle's T4 x2 machine) | | Wall time | 10.08 h | | GPU hours | 10.1 | ## Data [nikaata007/chessnet-lichess-2000plus](https://huggingface.co/datasets/nikaata007/chessnet-lichess-2000plus) (CC0-1.0): positions from the [Lichess open database](https://database.lichess.org/) dump of standard rated games of October 2026 (`lichess_db_standard_rated_2026-10.pgn.zst`), built by chessnet 0.1.0 (commit `873a1af`). The checkpoint records the manifest's SHA-256 (`88d5cdddfdd8708a9f8bc7c6371b8ef823472ad2f3ac3304b73ebf01cd6793ea`). A game was kept if both players were rated 2000 or more, its base time was at least 180 s (no bullet), it ended by `Normal` or `Time forfeit`, it lasted at least 20 plies and started from the standard position. The source is a dump of rated games only. Of 15,800,813 games scanned, 1,000,000 were kept, and split by game (a hash of the game's URL), so no game is in two splits: | Split | Games | Positions | |-------|------:|----------:| | train | 979,935 | 77,107,653 | | validation | 9,983 | 785,383 | | test | 10,082 | 799,013 | Each position is labelled with the move played from it and the game's result for the side to move. ## Results ### Prediction On 51,200 positions from held-out games (the validation subset, at the checkpoint's step): | Metric | Value | |--------|------:| | Top-1 / top-3 / top-5 move accuracy | 54.73% / 82.92% / 91.58% | | Top-1, White / Black to move | 54.28% / 55.18% (gap 0.90 points) | | Top-1, opening / middlegame / endgame | 54.76% / 53.44% / 56.73% | | WDL accuracy | 57.69% | | Value loss (WDL cross-entropy) | 0.848 | | Policy loss (cross-entropy with label smoothing) | 1.910 | ### Playing strength Measured with `chessnet eval` and `chessnet ladder`; every game is in [eval/results/](https://github.com/NikaAtanelishvili/chess-ai/tree/main/eval/results). Ratings on Stockfish 16's limited-strength UCI_Elo scale (maximum-likelihood fits to each ladder): - MCTS 800: **2557 (95% CI 2493 to 2622)** (280 games against UCI_Elo 1500 to 2700) - MCTS 1600: **2688 (95% CI 2617 to 2762)** (160 games against UCI_Elo 2100 to 2700) - 800 to 1,600 playouts: **+131 Elo** (95% CI +35 to +229), fitted to both ladders together - Strength against playouts, 50 to 1,600 against UCI_Elo 2300: **+94 Elo per doubling** (95% CI +62 to +129); a curve adds nothing significant (p = 0.21) **These ratings are not human ratings.** They are on Stockfish's limited-strength UCI_Elo scale, which is not comparable with FIDE or Lichess ratings. Limited-strength Stockfish weakens itself by injecting mistakes, which a search engine exploits in its own way, and its levels disagree: for MCTS 800, UCI_Elo 1900 and 2100 imply about 2340 and 2400, while the levels from 2300 to 2700 imply 2560 to 2630. A rating earned by a Lichess bot account would be the real-world check. ![Rating against playouts on Stockfish's scale](images/scaling.svg) ### Full tables Generated from the results files by the code that writes the repository's [docs/MODEL_CARD.md](https://github.com/NikaAtanelishvili/chess-ai/blob/main/docs/MODEL_CARD.md), where `base-best.pt` is this network's training checkpoint. #### base-best.pt, full suite 2026-11-27, 2 x Tesla T4 (cuda, 4 worker(s)), chessnet 0.2.0.dev0. 50 balanced openings, each played with both colours. | Match | Games | W / D / L | Score | Elo (95% CI) | Target | |-------|------:|-----------|------:|--------------|--------| | policy vs random (see the note below) | 100 | 95 / 5 / 0 | 97.5% | +636 (+525 to +975) | score >= 98% | | policy-safe vs random | 100 | 100 / 0 / 0 | 100.0% | ≥ +566 (perfect score, upper bound undefined) | score >= 98% | | MCTS 400 vs policy | 100 | 100 / 0 / 0 | 100.0% | ≥ +566 (perfect score, upper bound undefined) | score > 55% | | MCTS 800 vs Stockfish UCI_Elo 1320 | 50 | 50 / 0 / 0 | 100.0% | ≥ +446 (perfect score, upper bound undefined) | non-zero score | | MCTS 800 vs Stockfish Skill Level 0 | 50 | 50 / 0 / 0 | 100.0% | ≥ +446 (perfect score, upper bound undefined) | - | | wide-best vs base, 800 playouts each | 50 | 12 / 25 / 13 | 49.0% | -7 (-76 to +62) | - | | wide-best vs base, 1 s per move each | 50 | 13 / 29 / 8 | 55.0% | +35 (-27 to +99) | - | | wide-best vs base, 1 s per move each (laptop CPU) | 20 | 0 / 2 / 18 | 5.0% | -512 (≤ -353, lower bound undefined) | - | Puzzles, first move: 2000 sampled from lichess_db_puzzle.csv.zst (seed 0). | Player | <=1000 | 1001-1500 | 1501-2000 | >2000 | All | |--------|---:|---:|---:|---:|---:| | policy | 82.8% | 69.2% | 55.6% | 49.2% | 64.2% | | mcts-800 | 99.4% | 98.0% | 92.2% | 84.6% | 93.5% | The Kaggle run hung after MCTS 800 vs Stockfish UCI_Elo 1320 (fixed since). That match's results were recovered from the kernel log; its PGN was lost. **Against a random mover** (target: a 98% score) the raw policy scores 97.5%: 95 wins, 5 draws (4 stalemates, 1 threefold repetition) and no losses. Policy-safe, the policy mode the engine ships (UCI `Mode policy`, `chessnet play --mode policy`), wins all 100 games. **Decision (owner, 2026-11-28):** the 1.0.0 release counts policy-safe for this target, because it is what the engine plays in policy mode; the raw network's 97.5% is reported next to it so that the baseline stays visible. policy-safe vs random was played on 11th Gen Intel(R) Core(TM) i3-1115G4 @ 3.00GHz (cpu), 1 game at a time. wide-best vs base, 1 s per move each was played 2 games at a time. wide-best vs base, 1 s per move each (laptop CPU) was played on 11th Gen Intel(R) Core(TM) i3-1115G4 @ 3.00GHz (cpu), 1 game at a time. #### base-best.pt, Stockfish ladder, MCTS 800 and playout scaling 2026-11-27, 2 x Tesla T4 (cuda, 4 worker(s)), chessnet 0.2.0.dev0. MCTS 800 against Stockfish 16 with `UCI_LimitStrength`, 1 s per Stockfish move; 50 balanced openings, each played with both colours. Ratings are on Stockfish 16's UCI_Elo scale, which it anchors to CCRL engine ratings (goldfish 1.13 = 2000, games at 60 s + 0.6 s): an engine rating, not a FIDE or Lichess one. | Stockfish UCI_Elo (skill level) | Games | W / D / L | Score | Elo difference (95% CI) | |---------------------------------|------:|-----------|------:|-------------------------| | 1500 (1.5) | 40 | 40 / 0 / 0 | 100.0% | ≥ +407 (perfect score, upper bound undefined) | | 1700 (2.8) | 40 | 40 / 0 / 0 | 100.0% | ≥ +407 (perfect score, upper bound undefined) | | 1900 (3.8) | 40 | 35 / 4 / 1 | 92.5% | +436 (+315 to +803) | | 2100 (4.6) | 40 | 33 / 2 / 5 | 85.0% | +301 (+186 to +531) | | 2300 (5.5) | 40 | 33 / 1 / 6 | 83.8% | +285 (+169 to +508) | | 2500 (6.8) | 40 | 20 / 7 / 13 | 58.8% | +61 (-35 to +169) | | 2700 (8.9) | 40 | 9 / 14 / 17 | 40.0% | -70 (-165 to +15) | **Rating of MCTS 800 on Stockfish's scale: 2557 (95% CI 2493 to 2622)**, the maximum-likelihood fit to all 280 ladder games. It scored 50% or more up to UCI_Elo 2500, and less from 2700. Strength against playouts, each budget against Stockfish at UCI_Elo 2300 (the level nearest 50% for MCTS 800 when the curve was played): | Playouts | Games | W / D / L | Score | Elo vs UCI_Elo 2300 | Stockfish scale (95% CI) | |---------:|------:|-----------|------:|---------------:|--------------------------| | 50 | 32 | 7 / 5 / 20 | 29.7% | -150 | 2150 (2010 to 2277) | | 100 | 32 | 11 / 7 / 14 | 45.3% | -33 | 2267 (2144 to 2388) | | 200 | 32 | 7 / 9 / 16 | 35.9% | -100 | 2200 (2068 to 2322) | | 400 | 32 | 15 / 7 / 10 | 57.8% | +55 | 2355 (2234 to 2480) | | 800 | 40 | 33 / 1 / 6 | 83.8% | +285 | 2585 (2450 to 2747) | | 1600 | 32 | 26 / 2 / 4 | 84.4% | +293 | 2593 (2442 to 2781) | A straight line in log2(playouts) describes the points (fit p = 0.20): **+94 Elo per doubling of the playouts (95% CI +62 to +129)**. A curve adds nothing significant (p = 0.21). The rating and the scaling points have likelihood-ratio intervals; the ladder table's intervals are the match tables' (normal approximation, Wilson for a sweep). The 800-playout point is the ladder's match at UCI_Elo 2300. Played in 2 runs: UCI_Elo 1500, 1700, 1900, 2100 and 2300 on 2026-11-27 (2 x Tesla T4, commit 9d55d22); UCI_Elo 2500 and 2700 on 2026-11-28 (2 x Tesla T4, commit 598b637). #### base-best.pt, Stockfish ladder, MCTS 1600 2026-11-28, 2 x Tesla T4 (cuda, 4 worker(s)), chessnet 0.2.0.dev0. MCTS 1600 against Stockfish 16 with `UCI_LimitStrength`, 1 s per Stockfish move; 50 balanced openings, each played with both colours. Ratings are on Stockfish 16's UCI_Elo scale, which it anchors to CCRL engine ratings (goldfish 1.13 = 2000, games at 60 s + 0.6 s): an engine rating, not a FIDE or Lichess one. | Stockfish UCI_Elo (skill level) | Games | W / D / L | Score | Elo difference (95% CI) | |---------------------------------|------:|-----------|------:|-------------------------| | 2100 (4.6) | 40 | 37 / 2 / 1 | 95.0% | +512 (≥ +367, upper bound undefined) | | 2300 (5.5) | 40 | 34 / 2 / 4 | 87.5% | +338 (+218 to +613) | | 2500 (6.8) | 40 | 29 / 6 / 5 | 80.0% | +241 (+140 to +399) | | 2700 (8.9) | 40 | 12 / 14 / 14 | 47.5% | -17 (-107 to +70) | **Rating of MCTS 1600 on Stockfish's scale: 2688 (95% CI 2617 to 2762)**, the maximum-likelihood fit to all 160 ladder games. It scored 50% or more up to UCI_Elo 2500, and less from 2700. ## How to use With [chessnet](https://github.com/NikaAtanelishvili/chess-ai), which needs [uv](https://docs.astral.sh/uv/). `download-weights --source hf` needs chessnet ≥ 1.1. Until v1.1.0 is released, install chessnet from `main`, as below (`git clone` checks out `main`). ```bash git clone https://github.com/NikaAtanelishvili/chess-ai && cd chess-ai uv sync uv run chessnet download-weights --source hf # nikaata007/chessnet-base at v1.0.0, SHA-256 checked uv run chessnet play # play it in the terminal ``` `download-weights --source hf` saves `model.safetensors` and `config.json` in `checkpoints/hf/chessnet-base/`, where the engine finds them. For a chess GUI, add the UCI engine `.venv/bin/chessnet-uci` (`realpath .venv/bin/chessnet-uci` prints its full path); the [README](https://github.com/NikaAtanelishvili/chess-ai#in-a-chess-gui-uci) shows how for En Croissant and Cute Chess. chessnet 1.0.0 gets the same weights from the GitHub release (`download-weights` without `--source`). In Python, `load_network` builds the network from `config.json` and loads `model.safetensors`: ```python from chessnet.model.checkpoint import load_network network = load_network("checkpoints/hf/chessnet-base/model.safetensors").eval() ``` ### ONNX `model.onnx` takes `planes`, float32 of shape (batch, 19, 8, 8), and returns `policy` (batch, 4672) and `value` (batch, 3) logits. With ONNX Runtime, using chessnet's encoder for the planes and the move index: ```python import chess import numpy as np import onnxruntime as ort from chessnet.encoding.board import encode_board # the reference encoder from chessnet.encoding.moves import index_to_move, legal_mask session = ort.InferenceSession("model.onnx") board = chess.Board() # any position; encode_board mirrors it when Black is to move planes = encode_board(board)[np.newaxis] # (1, 19, 8, 8) float32 policy, wdl = session.run(["policy", "value"], {"planes": planes}) logits = np.where(legal_mask(board), policy[0], -np.inf) # legal moves only move = index_to_move(int(np.argmax(logits)), board) # mirrored back for Black win, draw, loss = np.exp(wdl[0]) / np.exp(wdl[0]).sum() # for the side to move print(board.san(move), f"v = {win - loss:+.3f}") ``` Without chessnet, reproduce `encoding/board.py` and `encoding/moves.py` exactly; the layout is in the encoding section above. `model.fp16.onnx` (from tag `v1.1.0`) is used the same way: it also takes and returns float32, and holds the weights in half precision. ## Intended use and limitations Playing and analysis through chessnet's terminal game or any UCI chess GUI; research and teaching. - The network imitates players rated 2000 and up: the policy proposes human moves, and the value estimates how humans fare from a position, not a theoretical evaluation. - Tactics come from the search, which is written in Python: about 400 to 500 playouts per second on a laptop CPU, about 1,300 on a T4. Strength grows by roughly 94 Elo per doubling of the playouts. - No opening book, endgame tablebases or pondering; standard chess only (no Chess960). - Positions unlike human games, such as odd starting setups, are judged poorly. ## Links - Code, documentation and every evaluation game: - The chessnet 1.0.0 release (base's training checkpoint and ONNX export): - Training data: ## Citation ```bibtex @software{chessnet, author = {Nikoloz Atanelishvili}, title = {chessnet: an AlphaZero-style chess engine trained on Lichess games}, year = {2026}, version = {1.0.0}, url = {https://github.com/NikaAtanelishvili/chess-ai}, } ```