Instructions to use datafreak/laya-chess with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Laya
How to use datafreak/laya-chess with Laya:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Model card: links, results, local setup
Browse files
README.md
CHANGED
|
@@ -3,13 +3,51 @@ license: apache-2.0
|
|
| 3 |
base_model: convaiinnovations/laya
|
| 4 |
tags: [chess, laya, decision-model]
|
| 5 |
---
|
| 6 |
-
# Laya fine-tuned for chess
|
| 7 |
|
| 8 |
-
[Laya](https://huggingface.co/convaiinnovations/laya)
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
-
-
|
| 15 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
base_model: convaiinnovations/laya
|
| 4 |
tags: [chess, laya, decision-model]
|
| 5 |
---
|
| 6 |
+
# LayaChess: Laya fine-tuned for chess
|
| 7 |
|
| 8 |
+
[Laya](https://huggingface.co/convaiinnovations/laya) (Convai Innovations, ModernBERT-large, 421M) is a System 1
|
| 9 |
+
decision model that had never seen a chessboard. This checkpoint fine-tunes it on 2 million Stockfish-rated moves from
|
| 10 |
+
DeepMind's [ChessBench](https://github.com/google-deepmind/searchless_chess). For each legal move, a Laya `score`
|
| 11 |
+
question predicts the win chance of the side to move over 10 levels. The
|
| 12 |
+
[LayaChess engine](https://github.com/devroopsaha744/LayaChess) wraps it in a Monte Carlo tree search.
|
| 13 |
|
| 14 |
+
- **Play it online:** [huggingface.co/spaces/datafreak/laya-chess](https://huggingface.co/spaces/datafreak/laya-chess)
|
| 15 |
+
- **Write-up:** [LayaChess: teaching a System 1 decision model to play chess](https://devroopsaha744.github.io/portfolio/blog/laya-chess/)
|
| 16 |
+
- **Demo video:** [youtube.com/watch?v=bPpAlWArs7E](https://www.youtube.com/watch?v=bPpAlWArs7E)
|
| 17 |
+
- **Code:** [github.com/devroopsaha744/LayaChess](https://github.com/devroopsaha744/LayaChess)
|
| 18 |
+
|
| 19 |
+
## Results
|
| 20 |
+
| | Base Laya | This checkpoint |
|
| 21 |
+
|---|---|---|
|
| 22 |
+
| Picks Stockfish's best move (300 held-out positions) | 6% | **27%** |
|
| 23 |
+
| Win-chance error (percentage points) | 28.6 | **8.2** |
|
| 24 |
+
|
| 25 |
+
Checkpoint `final`: step 32,000, 2,048,000 training examples. Encoding, levels and the question template are in
|
| 26 |
+
`chess_meta.json`. `train_state.pt` is the optimizer state for resuming training; inference doesn't need it.
|
| 27 |
+
|
| 28 |
+
## Run it on your own machine
|
| 29 |
+
```bash
|
| 30 |
+
git clone https://github.com/devroopsaha744/LayaChess.git
|
| 31 |
+
cd LayaChess/engine
|
| 32 |
+
python3 -m venv .venv && source .venv/bin/activate
|
| 33 |
+
pip install -r requirements.txt
|
| 34 |
+
python -m laya_chess.play # browser board at http://localhost:8000
|
| 35 |
+
```
|
| 36 |
+
The engine downloads this checkpoint on first start. Optional: install Stockfish (`brew install stockfish` or
|
| 37 |
+
`sudo apt install stockfish`) to see its preferred move next to Laya's. Full steps are in the
|
| 38 |
+
[GitHub README](https://github.com/devroopsaha744/LayaChess#run-it-on-your-own-machine).
|
| 39 |
+
|
| 40 |
+
## Use it from Python
|
| 41 |
+
```python
|
| 42 |
+
import chess
|
| 43 |
+
from laya_chess import LayaChessModel
|
| 44 |
+
|
| 45 |
+
model = LayaChessModel("datafreak/laya-chess")
|
| 46 |
+
for move, win in model.score_moves(chess.Board())[:5]:
|
| 47 |
+
print(move, f"{win:.0%}")
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
## Credits
|
| 51 |
+
[Laya](https://github.com/NandhaKishorM/laya) by Convai Innovations (Apache 2.0) 路
|
| 52 |
+
[ChessBench](https://github.com/google-deepmind/searchless_chess) by Google DeepMind 路
|
| 53 |
+
[Stockfish](https://stockfishchess.org) 路 [python-chess](https://python-chess.readthedocs.io)
|