File size: 12,809 Bytes
d9a5549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30442a0
d9a5549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30442a0
d9a5549
 
30442a0
d9a5549
30442a0
d9a5549
 
30442a0
 
d9a5549
 
 
 
 
 
30442a0
d9a5549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30442a0
d9a5549
 
 
 
 
 
 
 
 
 
30442a0
d9a5549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30442a0
d9a5549
 
 
 
 
30442a0
 
d9a5549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30442a0
d9a5549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30442a0
d9a5549
 
 
 
 
 
d36f1b5
 
d9a5549
 
 
30442a0
d9a5549
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
---
license: apache-2.0
library_name: flax
pipeline_tag: other
tags:
  - chess
  - human-ai-alignment
  - behavioral-cloning
  - cognitive-effort
  - jax
  - flax-nnx
  - maia
  - chessformer
  - uci-engine
model-index:
  - name: chessforge-5m
    results:
      - task:
          type: move-prediction
          name: Human Move Prediction (Titled Online)
        dataset:
          name: Eval-Titled-Online (Aug 2025 Post-Cutoff)
          type: eval_titled_antisf
        metrics:
          - type: accuracy
            value: 60.55
            name: Move Accuracy (%)
          - type: top_3_accuracy
            value: 87.37
            name: Top-3 Move Accuracy (%)
          - type: perplexity
            value: 3.143
            name: Move Perplexity
          - type: accuracy
            value: 61.54
            name: WDL Value Accuracy (%)
      - task:
          type: move-prediction
          name: Human Move Prediction (FIDE Classical OTB)
        dataset:
          name: Eval-FIDE-OTB (Aug-Sep 2025 Post-Cutoff)
          type: eval_fide_otb_antisf
        metrics:
          - type: accuracy
            value: 54.87
            name: Move Accuracy (%)
          - type: top_3_accuracy
            value: 83.69
            name: Top-3 Move Accuracy (%)
          - type: perplexity
            value: 3.721
            name: Move Perplexity
          - type: accuracy
            value: 62.21
            name: WDL Value Accuracy (%)
---

# chessforge-5m (5.12M Parameters)

**Authors:** [Rishiraj Acharya](https://profile.google.com/@rishirajacharya) *(Independent Researcher)* and **Soumik Rakshit** *(Principal Scientist, [eka.care](https://eka.care))*  
**Codebase:** [`chessforge`](https://github.com/soumik12345/chessforge) | **Organization:** [`chessforge`](https://huggingface.co/chessforge) | **Larger Flagship:** [`chessforge/chessforge-35m`](https://huggingface.co/chessforge/chessforge-35m)

**chessforge-5m** is a **5,123,809-parameter** searchless human chess behavioral & cognitive-effort foundation model built in **JAX / Flax NNX**. Strictly smaller than `MAIA-3-5M` (`5,230,084` parameters), it jointly models **human move selection and normalized thinking time** $p_\theta(a, u \mid s) = p_\theta(u \mid s)\,p_\theta(a \mid s, u)$ across both **Titled Online** (Blitz/Rapid) and **FIDE Over-The-Board (OTB) Classical** chess.

### Key Highlights
* **Strictly Parameter-Matched Small-Scale SOTA:** With fewer parameters than `MAIA-3-5M` (`5.12M` vs. `5.23M`), `chessforge-5m` outperforms `MAIA-3-5M` by **+1.55% Move Accuracy on Titled Online** (`60.55%` vs. `59.00%`, paired McNemar $\chi^2 = 211.11, p = 7.88 \times 10^{-48}$) and **+2.88% on FIDE OTB** (`54.87%` vs. `51.99%`, $\chi^2 = 892.78, p = 3.64 \times 10^{-196}$).
* **Surpasses `MAIA-3-23M` on Classical OTB & `MAIA-3-79M` on Outcome Calibration:** Despite having **4.5× fewer parameters and 8× fewer training examples** (`512M` vs. `4.10B`), `chessforge-5m` beats `MAIA-3-23M` on FIDE OTB move prediction (`54.87%` vs. `54.57%`, $p = 7.28 \times 10^{-4}$) and outperforms **`MAIA-3-79M` (`15.4×` larger)** on WDL game-outcome calibration across *both* domains (`61.54%` vs. `60.64%` Online; **`62.21%` vs. `57.08%`** OTB).
* **Joint Move & Cognitive-Effort Factorization:** Predicts a 16-bin HL-Gauss distribution over scale-invariant cognitive effort $u \in [0,1]$ (Pearson $r = 0.6559$, $\text{MAE} = 0.1024$) and conditions move logits on effort via a rank-16 bilinear `EffortMoveResidual` (`+6,464` parameters), capturing fast System-1 intuition vs. slow System-2 calculation ($I(A; U \mid S) = 0.0260\text{ nats}$).

---

## Architectural Innovations Over Vanilla Chessformer / MAIA-3

| Component | MAIA-3-5M (`5.23M`) | chessforge-5m (`5.12M`, Ours) |
| :--- | :--- | :--- |
| **Board State Markovity** | Non-Markov ($8\times 12$ piece planes only) | **Full Markov `v3`**: piece history + relative castling + side-to-move EP square + Zobrist repetitions |
| **Clock & Format Context** | Unconditioned (`Blitz` only) | 6-d masked bilateral log-clocks + `has_clock` gate + `Blitz / Rapid / OTB-Classical` embedding |
| **Skill & Title Conditioning** | Collinear 2-vector Elo line at input | 16-RBF Elo + rating-asymmetry $\tanh$ + **Official Human Title (`CM/NM`, `FM`, `IM`, `GM`)** via 128-d Bottleneck AdaLN |
| **Transformer Trunk ($L=8$)** | Post-RMSNorm + MHA + GELU ($2\times$) | **Pre-RMSNorm + QK-Norm MHA + SwiGLU** ($2.25\times$, $D=192$, 6 heads, `fp32` residual stream) |
| **Geometric Attention Bias** | Global mean-pooled GAB ($d_1 = 0$) | **Spatial GAB ($d_1 = 8$) + Zero-Copy Ray-GAB** (analytical 0-blocker line-of-sight & 1-blocker pin/skewer/X-ray masks) |
| **Global Readout** | Global mean pool over 64 squares | **Post-trunk `CrossAttentionPool`** (`[CLS_VALUE, CLS_PONDER]`, strictly preserving $S=64$ hardware tiling) |
| **Policy & Cognitive Heads** | Bilinear From–To + unused scalar MSE ponder | Source-Prior + Last-2-Layer Attn Residual + **HL-Gauss Effort Prior + Rank-16 `EffortMoveResidual`** + 2-Ply Reply Aux |

---

## Benchmark Results (Strictly Post-Cutoff Aug–Sep 2025)

All training shards strictly terminate on or before **July 2025**. Models are evaluated zero-shot on held-out post-cutoff benchmarks annotated with Stockfish 16 (`5,000` nodes/move; `AntiSF` denotes sound human–engine disagreements where $a_{\text{hum}} \neq a_{\text{SF}}$ and $\Delta_{\text{cp}} \le 35$).

### 1. `Eval-Titled-Online` (`105,593` positions; `32,043` Anti-SF positions)

| Model | Params | Train Pos | Move Acc (%) ↑ | Top-3 (%) ↑ | PPL ↓ | Val Acc (%) ↑ | Val NLL ↓ | AntiSF Hum (%) ↑ | AntiSF Eng ↓ | AntiSF Pref (%) ↑ |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| `MAIA-3-3M` | 3.15M | 0.51B–1.02B | 57.59 ± 0.30 | 85.05 | 3.497 | 59.53 | 0.8571 | 47.69 | 19.14 | 65.14 |
| `MAIA-3-5M` | 5.23M | 0.51B–1.02B | 59.00 ± 0.30 | 86.15 | 3.330 | 59.77 | 0.8553 | 49.51 | 19.16 | 65.69 |
| **`chessforge-5m` (Ours)** | **5.12M** | **0.51B** | **60.55 ± 0.29** | **87.37** | **3.143** | **61.54** | **0.8258** | **50.63** | **19.12** | **66.44** |
| `MAIA-3-23M` *(4.5× larger)* | 22.94M | 4.10B | 61.33 ± 0.29 | 87.84 | 3.047 | 60.34 | 0.8464 | 51.64 | 19.33 | 66.65 |
| `MAIA-3-79M` *(15.4× larger)* | 78.90M | 4.10B | 62.52 ± 0.29 | 88.66 | 2.932 | 60.64 | 0.8431 | 52.61 | 19.33 | 67.13 |

### 2. `Eval-FIDE-OTB` (`144,559` positions; `46,888` Anti-SF positions)

| Model | Params | Train Pos | Move Acc (%) ↑ | Top-3 (%) ↑ | PPL ↓ | Val Acc (%) ↑ | Val NLL ↓ | AntiSF Hum (%) ↑ | AntiSF Eng ↓ | AntiSF Pref (%) ↑ |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| `MAIA-3-3M` | 3.15M | 0.51B–1.02B | 50.75 ± 0.26 | 79.82 | 4.401 | 55.60 | 1.1035 | 38.02 | 19.89 | 60.62 |
| `MAIA-3-5M` | 5.23M | 0.51B–1.02B | 51.99 ± 0.26 | 81.15 | 4.198 | 55.86 | 1.0988 | 38.90 | 19.88 | 61.22 |
| `MAIA-3-23M` *(4.5× larger)* | 22.94M | 4.10B | 54.57 ± 0.26 | 83.45 | 3.809 | 56.75 | 1.0712 | 41.09 | 20.14 | 62.36 |
| **`chessforge-5m` (Ours)** | **5.12M** | **0.51B** | **54.87 ± 0.26** | **83.69** | **3.721** | **62.21** | **0.8273** | **41.63** | 20.81 | **61.80** |
| `MAIA-3-79M` *(15.4× larger)* | 78.90M | 4.10B | 55.80 ± 0.26 | 84.48 | 3.650 | 57.08 | 1.0598 | 42.50 | 20.00 | 62.96 |

### 3. Cognitive Effort Prediction & Joint Move–Time Calibration (`Eval-Titled-Online`)

| Metric | Value |
| :--- | :---: |
| Marginal Effort NLL $H(U \mid S)$ ↓ | `2.0767` |
| Posterior Effort NLL $H(U \mid S, A)$ ↓ | `2.0507` |
| Move–Time Mutual Information $I(A; U \mid S)$ (nats) ↑ | `0.0260` |
| Joint Move–Time NLL ↓ | `3.1959` |
| Normalized Effort MAE ↓ | `0.1024` |
| Normalized Effort Pearson $r$ ↑ | `0.6559` |

---

## Repository Contents

* `model.msgpack` (`~20.5 MB`) — Pure `float32` Flax NNX weights (no optimizer state) for fast standalone Python/JAX loading.
* `checkpoints/250000/` — Native Orbax `TrainState` checkpoint for out-of-the-box use with `chessforge.cli.uci` and `chessforge.cli.eval`.
* `config.yaml` — Ready-to-run `chessforge` configuration file.
* `model_config.json` & `train_config.json` — Exact architecture & training metadata.
* `eval_results/` — Full evaluation JSONs (including Elo-stratified curves) on `Eval-Titled-Online` and `Eval-FIDE-OTB`.

---

## Quickstart Usage

### 1. Install `chessforge` & Download Checkpoint
```bash
git clone https://github.com/soumik12345/chessforge.git
cd chessforge
pip install -e ".[cpu]"   # or ".[cuda12]" / ".[tpu]"

python -c "from huggingface_hub import snapshot_download; snapshot_download('chessforge/chessforge-5m', local_dir='./chessforge-5m')"
```

### 2. Play as a Human-Like UCI Engine (Nibbler / CuteChess / En Croissant / Lichess-Bot)
```bash
python -m chessforge.cli.uci \
  --config ./chessforge-5m/config.yaml \
  --set workdir=./chessforge-5m \
  --step 250000 --title GM --elo 2550 --format otb
```

### 3. Standalone JAX / Flax NNX Inference & Joint `(Move, Thinking-Time)` Sampling
```python
import json
from pathlib import Path
import chess
import jax
import jax.numpy as jnp
import numpy as np
from flax import nnx, serialization

from chessforge import chess_utils as cu
from chessforge.config import ModelConfig
from chessforge.models import build_model, forward_model
from chessforge.models.joint_time import sample_joint_move_time

ckpt_dir = Path("./chessforge-5m")
meta = json.loads((ckpt_dir / "model_config.json").read_text())
model_cfg = ModelConfig(**meta["model_config"])

# Build model & load pure fp32 weights from model.msgpack
model = build_model(model_cfg, rngs=0)
graphdef, state = nnx.split(model)
template = jax.tree.map(np.asarray, nnx.to_pure_dict(state))
pure_params = serialization.from_bytes(template, (ckpt_dir / "model.msgpack").read_bytes())
pure_params = jax.tree.map(jnp.asarray, pure_params)
if hasattr(nnx, "replace_by_pure_dict"):
    nnx.replace_by_pure_dict(state, pure_params)
else:
    state.replace_by_pure_dict(pure_params)
model = nnx.merge(graphdef, state)

# Run inference on starting position (GM 2550, 180s remaining clock)
board = chess.Board()
legal = np.zeros((1, cu.VOCAB_SIZE), dtype=bool)
legal[0, cu.legal_move_indices(board)] = True
batch = {
    "board": jnp.asarray(np.tile(cu.board_codes(board), (1, model_cfg.history, 1))),
    "self_elo": jnp.array([2550.0]),
    "oppo_elo": jnp.array([2550.0]),
    "self_title": jnp.array([cu.TITLE_GRANDMASTER]),
    "oppo_title": jnp.array([cu.TITLE_GRANDMASTER]),
    "game_format": jnp.array([cu.FORMAT_BLITZ]),
    "clk_left": jnp.array([180.0]),
    "has_clock": jnp.array([1.0]),
    "legal": jnp.asarray(legal),
}

logits_move, logits_value, ponder_sec, aux = forward_model(model, batch, deterministic=True, return_aux=True)
sample = sample_joint_move_time(
    jax.random.PRNGKey(0), aux["ponder_logits"], aux["conditional_move_logits"], batch["clk_left"], batch["legal"]
)
print("Top marginal move:", cu.index_to_uci(int(jnp.argmax(logits_move[0]))))
print("Sampled (move, think_sec):", cu.index_to_uci(int(sample["move"][0])), round(float(sample["ponder_sec"][0]), 2))
print("WDL probs [loss, draw, win]:", jax.nn.softmax(logits_value[0]).tolist())
```

---

## Training Provenance & Limitations

* **Training Corpus (Strictly Pre-Cutoff `<= 2025-07`):** Trained for `250,000` steps at `global_batch_size = 2048` (`512M` positions) on a single Google Cloud TPU `v6e-1` using an exact 1-pass streaming shard iterator (`0%` within-epoch duplicates) and Warmup–Stable–Decay (`WSD`, `lr = 4.0e-4 -> 2.0e-6`, `grad_clip_norm = 2.0`). The first 80% (`200k` steps) trained on **Pool B** (`703.6M` unique positions: Lichess Blitz + Rapid $\ge 1800$ Elo with official title purity enforced $\ge 2350$ Elo + uncapped titled games + FIDE OTB), followed by 20% cosine annealing (`50k` steps) on **Pool C** (`310.6M` unique positions: `88.26%` Pure Titled Online + `11.74%` FIDE OTB Classical).
* **Limitations:** Because ~88% of titled training examples carry online game priors, passing `--mask_titles` during inference on classical OTB games can slightly improve pure classical calibration. This 5.12M checkpoint is Stage-2 WSD-trained (without Stage-3 Anti-Engine DPO); for anti-engine preference-aligned weights, see [`chessforge/chessforge-35m`](https://huggingface.co/chessforge/chessforge-35m).

---

## Citation

```bibtex
@misc{acharya2026chessforge,
  title         = {ChessForge: Joint Move--Effort Modeling, Domain-Aligned Scaling, and Anti-Engine Alignment for Master and Over-the-Board Human Chess},
  author        = {Acharya, Rishiraj and Rakshit, Soumik},
  year          = {2026},
  publisher     = {Hugging Face},
  howpublished  = {\url{https://huggingface.co/chessforge/chessforge-5m}}
}
```