--- license: apache-2.0 base_model: convaiinnovations/laya tags: [chess, laya, decision-model] --- # LayaChess: Laya fine-tuned for chess [Laya](https://huggingface.co/convaiinnovations/laya) (Convai Innovations, ModernBERT-large, 421M) is a System 1 decision model that had never seen a chessboard. This checkpoint fine-tunes it on 2 million Stockfish-rated moves from DeepMind's [ChessBench](https://github.com/google-deepmind/searchless_chess). For each legal move, a Laya `score` question predicts the win chance of the side to move over 10 levels. The [LayaChess engine](https://github.com/devroopsaha744/LayaChess) wraps it in a Monte Carlo tree search. - **Play it online:** [huggingface.co/spaces/datafreak/laya-chess](https://huggingface.co/spaces/datafreak/laya-chess) - **Write-up:** [LayaChess: teaching a System 1 decision model to play chess](https://devroopsaha744.github.io/portfolio/blog/laya-chess/) - **Demo video:** [youtube.com/watch?v=bPpAlWArs7E](https://www.youtube.com/watch?v=bPpAlWArs7E) - **Code:** [github.com/devroopsaha744/LayaChess](https://github.com/devroopsaha744/LayaChess) ## Results | | Base Laya | This checkpoint | |---|---|---| | Picks Stockfish's best move (300 held-out positions) | 6% | **27%** | | Win-chance error (percentage points) | 28.6 | **8.2** | Checkpoint `final`: step 32,000, 2,048,000 training examples. Encoding, levels and the question template are in `chess_meta.json`. `train_state.pt` is the optimizer state for resuming training; inference doesn't need it. ## Run it on your own machine ```bash git clone https://github.com/devroopsaha744/LayaChess.git cd LayaChess/engine python3 -m venv .venv && source .venv/bin/activate pip install -r requirements.txt python -m laya_chess.play # browser board at http://localhost:8000 ``` The engine downloads this checkpoint on first start. Optional: install Stockfish (`brew install stockfish` or `sudo apt install stockfish`) to see its preferred move next to Laya's. Full steps are in the [GitHub README](https://github.com/devroopsaha744/LayaChess#run-it-on-your-own-machine). ## Use it from Python ```python import chess from laya_chess import LayaChessModel model = LayaChessModel("datafreak/laya-chess") for move, win in model.score_moves(chess.Board())[:5]: print(move, f"{win:.0%}") ``` ## Credits [Laya](https://github.com/NandhaKishorM/laya) by Convai Innovations (Apache 2.0) · [ChessBench](https://github.com/google-deepmind/searchless_chess) by Google DeepMind · [Stockfish](https://stockfishchess.org) · [python-chess](https://python-chess.readthedocs.io)