Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: cc-by-nc-4.0
|
| 4 |
+
tags:
|
| 5 |
+
- chess
|
| 6 |
+
- chess-engine
|
| 7 |
+
- transformer
|
| 8 |
+
- from-scratch
|
| 9 |
+
- small-model
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Parallax-Chess-Preview
|
| 13 |
+
|
| 14 |
+
A chess move prediction engine trained from scratch on a single laptop GPU. Predicts the best move given a board position using a custom chess tokenizer and a 4.4M parameter transformer.
|
| 15 |
+
|
| 16 |
+
## How It Works
|
| 17 |
+
|
| 18 |
+
Unlike traditional chess engines (Stockfish, Leela), Parallax-Chess-Preview uses **pure neural network evaluation** — no hand-crafted rules, no opening books, no endgame tables. It learned chess purely from 50,000 Lichess puzzles.
|
| 19 |
+
|
| 20 |
+
- **Custom chess tokenizer**: Board positions encoded as 66 tokens (64 squares + side-to-move + separator), moves encoded as (from-square, to-square) pairs. Total vocab: 402 tokens.
|
| 21 |
+
- **Architecture**: Transformer decoder (6 layers, 256 dim, 4 heads, GQA 4:2)
|
| 22 |
+
- **Training**: 100K steps on 50K Lichess puzzles, final loss 0.088
|
| 23 |
+
|
| 24 |
+
## Benchmarks
|
| 25 |
+
|
| 26 |
+
| Metric | Value |
|
| 27 |
+
|--------|-------|
|
| 28 |
+
| Legal move rate | 100% |
|
| 29 |
+
| Speed | 6 moves/sec (CPU) |
|
| 30 |
+
| Estimated ELO | ~700 |
|
| 31 |
+
| vs Stockfish (max) | 0-1 (W), 1-0 (B, blunder) |
|
| 32 |
+
| Training data | 50K Lichess puzzles |
|
| 33 |
+
| Training time | ~1 hour on RTX 5060 |
|
| 34 |
+
|
| 35 |
+
## Quick Start
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
import chess
|
| 39 |
+
from vela_chess_engine import VelaChessV2
|
| 40 |
+
|
| 41 |
+
engine = VelaChessV2("model.safetensors", "chess_encoding.py")
|
| 42 |
+
board = chess.Board()
|
| 43 |
+
move = engine.choose_move(board)
|
| 44 |
+
print(move.uci()) # e.g. "g1f3"
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
## Interactive Play
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
python play.py
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
Then type moves in UCI format (e.g. `e2e4`).
|
| 54 |
+
|
| 55 |
+
## Architecture Details
|
| 56 |
+
|
| 57 |
+
```
|
| 58 |
+
SmallLMConfig(
|
| 59 |
+
vocab_size=402, # Custom chess vocabulary
|
| 60 |
+
d_model=256, # Embedding dimension
|
| 61 |
+
n_heads=4, # Attention heads
|
| 62 |
+
n_kv_heads=2, # GQA grouped query attention
|
| 63 |
+
n_layers=6, # Transformer layers
|
| 64 |
+
intermediate_size=1024,
|
| 65 |
+
max_seq_len=128,
|
| 66 |
+
norm_type='rms',
|
| 67 |
+
rope_theta=10000.0,
|
| 68 |
+
)
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
## Training Data
|
| 72 |
+
|
| 73 |
+
50,000 chess puzzles from the [Lichess puzzle database](https://database.lichess.org/#puzzles), filtered to ratings 800-2500 with 2-6 move solutions.
|
| 74 |
+
|
| 75 |
+
## Limitations
|
| 76 |
+
|
| 77 |
+
- **~700 ELO** — plays at beginner level
|
| 78 |
+
- No search tree — purely neural move prediction
|
| 79 |
+
- Trained on puzzle data only (not full games)
|
| 80 |
+
- Cannot play from arbitrary positions outside training distribution
|
| 81 |
+
|
| 82 |
+
## What This Proves
|
| 83 |
+
|
| 84 |
+
Even a tiny 4.4M parameter model can:
|
| 85 |
+
- Learn legal chess move patterns from data alone
|
| 86 |
+
- Achieve 100% legal move rate
|
| 87 |
+
- Make occasionally reasonable opening choices (Nf3, Nc3)
|
| 88 |
+
- Be trained from scratch in 1 hour on a laptop GPU
|
| 89 |
+
|
| 90 |
+
## Hardware
|
| 91 |
+
|
| 92 |
+
- **Training**: Single RTX 5060 Laptop GPU (8GB VRAM)
|
| 93 |
+
- **Inference**: CPU-only, ~6 moves/sec
|
| 94 |
+
|
| 95 |
+
## License
|
| 96 |
+
|
| 97 |
+
CC BY-NC 4.0 (weights), AGPL-3.0 (code)
|