File size: 14,157 Bytes
0a2b10c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8bfeaa
0a2b10c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8bfeaa
0a2b10c
 
e8bfeaa
0a2b10c
e8bfeaa
0a2b10c
 
 
 
 
 
 
 
 
 
 
 
 
e8bfeaa
0a2b10c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8bfeaa
0a2b10c
 
 
 
 
 
 
 
 
e8bfeaa
 
0a2b10c
 
 
 
 
 
e8bfeaa
0a2b10c
 
 
 
 
 
 
 
 
 
 
e8bfeaa
0a2b10c
 
 
 
 
 
 
 
 
 
 
 
 
 
e8bfeaa
0a2b10c
 
 
 
 
e8bfeaa
 
0a2b10c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8bfeaa
0a2b10c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a45ff91
 
0a2b10c
 
 
e8bfeaa
0a2b10c
 
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
229
230
231
---
license: apache-2.0
library_name: flax
pipeline_tag: other
tags:
  - chess
  - human-ai-alignment
  - behavioral-cloning
  - direct-preference-optimization
  - cognitive-effort
  - jax
  - flax-nnx
  - maia
  - chessformer
  - uci-engine
model-index:
  - name: chessforge-35m
    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: 62.98
            name: Move Accuracy (%)
          - type: top_3_accuracy
            value: 88.87
            name: Top-3 Move Accuracy (%)
          - type: perplexity
            value: 2.894
            name: Move Perplexity
          - type: accuracy
            value: 62.12
            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: 58.50
            name: Move Accuracy (%)
          - type: top_3_accuracy
            value: 86.37
            name: Top-3 Move Accuracy (%)
          - type: perplexity
            value: 3.300
            name: Move Perplexity
          - type: accuracy
            value: 63.89
            name: WDL Value Accuracy (%)
---

# chessforge-35m (35.24M 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) | **Compact 5M Sibling:** [`chessforge/chessforge-5m`](https://huggingface.co/chessforge/chessforge-5m)

**chessforge-35m** is our flagship **35,241,837-parameter** searchless human chess behavioral & cognitive-effort foundation model built in **JAX / Flax NNX**. Using **2.24× fewer parameters and 8× fewer training examples** (`512M` vs. `4.10B`) than `MAIA-3-79M` (`78.90M`), it **surpasses `MAIA-3-79M` across every single evaluation metric on both Titled Online and FIDE Classical Over-The-Board (OTB) chess**, while jointly modeling **System-1 (fast intuition) vs. System-2 (deep calculation)** move distributions $p_\theta(a, u \mid s)$.

This repository also includes the **Stage-3 KL-Anchored, Value-Frozen Anti-Engine DPO** weights (`dpo_c1p5/model.msgpack`), which explicitly suppress computer-like Stockfish #1 choices on sound human–engine disagreements while still statistically outperforming `MAIA-3-79M` on overall move accuracy.

### Key Highlights
* **Beats `MAIA-3-79M` on All 9 Titled Online Metrics at 2.24× Smaller Scale:** Achieves **`62.98%` Move Accuracy** (`+0.48%` paired $\Delta$ over `MAIA-3-79M`'s `62.52%`, McNemar $\chi^2 = 25.98, p = 3.46 \times 10^{-7}$), **`2.894` Perplexity**, **`62.12%` Value Accuracy** (`0.8194` NLL), and **`19.08%` Anti-SF Engine Pick Rate** (beating every `MAIA-3` model even prior to Stage-3 DPO).
* **Crushes `MAIA-3-79M` on FIDE Classical OTB:** Achieves **`58.50%` OTB Move Accuracy** (**`+2.71%`** over `MAIA-3-79M`'s `55.80%`, McNemar $\chi^2 = 883.65, p = 3.52 \times 10^{-194}$; rising to **`58.86%` Move Acc / `65.57%` Val Acc** when online title priors are masked via `--mask_titles`) and **`63.89%` WDL Value Accuracy (`0.7991` NLL)** vs. `MAIA-3-79M`'s `57.08%` (`1.0598` NLL) — remaining `+2.65%` ahead even after granting `MAIA-3-79M` 5-fold oracle OTB value recalibration (`61.24%`).
* **System-1 vs. System-2 Joint Move–Time Modeling:** Adding only `+12,608` parameters (`+0.036%`, rank-16 `EffortMoveResidual` over $K=16$ HL-Gauss cognitive effort buckets) yields **`0.6747` Effort Pearson $r$** (`0.0999` MAE, `2.0289` posterior effort NLL, `0.0265` nats mutual information) and captures sharp human policy shifts between fast impulse moves and deep calculation (JSD up to `0.305` nats in Grandmaster games).
* **Anti-Engine Alignment (`dpo_c1p5`):** Stage-3 KL-anchored (`kl_coef=0.75`), value-frozen DPO on `800k` Stockfish-annotated titled positions ($\Delta_{\text{cp}} \le 35$) drives Online Stockfish-pick rate down to **`18.10%`** (`69.84%` human pairwise preference) while retaining **`62.76%` Online Move Accuracy** (still statistically beating `MAIA-3-79M`, $p = 6.28 \times 10^{-3}$) and **`58.03%` OTB Move Accuracy** ($+2.24\%$ over `MAIA-3-79M`, $p = 3.64 \times 10^{-137}$).

---

## Architectural Specification

| Component | Specification (`chessforge-35m`) |
| :--- | :--- |
| **Backbone** | 16 Pre-RMSNorm blocks, $D = 384$, 12 QK-Norm heads (`head_dim = 32`), SwiGLU MLP (`mlp_ratio = 2.67`), `fp32` residual stream |
| **Hardware Tiling & Readout** | Strict $S = 64$ square-token trunk (`3,235.6 pos/s` on single TPU `v6e-1`) + post-trunk 2-query `CrossAttentionPool` (`[CLS_VALUE, CLS_PONDER]`) |
| **State Representation (`v3`)** | 8-ply relative piece history + 8-d Markov metadata (castling, EP, Zobrist reps) + spatial EP target (`40 + ep_file`) + 4-d board coords + 6-d masked log-clocks |
| **Context Conditioner** | 16-basis Gaussian RBF Elo ($\mu \in [800, 2900], \sigma = 160$) + rating gap + Official Human Title (`CM/NM..GM`) + Format (`Blitz/Rapid/OTB`) $\to$ 128-d Bottleneck AdaLN |
| **Zero-Copy Ray-GAB** | Spatial GAB ($d_1 = 24, d_2 = 128, d_3 = 96$) + 8-channel exact analytical ray masks (4 clear line-of-sight + 4 single-blocker pin/skewer/X-ray) + 12-class pairwise relation table |
| **Joint Move–Effort Head** | Bilinear From–To ($d_h = 384$) + source prior + last-2-layer attention residual + 16-bin HL-Gauss effort prior + rank-16 `EffortMoveResidual` (`+12,608` params) |

---

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

### 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-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 |
| `MAIA-3-23M` | 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` | 78.90M | 4.10B | 62.52 ± 0.29 | 88.66 | 2.932 | 60.64 | 0.8431 | 52.61 | 19.33 | 67.13 |
| **`chessforge-35m` (Ours)** | **35.24M** | **0.51B** | **62.98 ± 0.29** | **88.87** | **2.894** | **62.12** | **0.8194** | 53.23 | 19.08 | 67.55 |
| **`+ Anti-Engine DPO (c=1.5)` (`dpo_c1p5/`)** | **35.24M** | **+1.0M** | 62.76 ± 0.29 | 88.68 | 3.076 | 61.39 | 0.8308 | **53.43** | **18.10** | **69.84** |

### 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-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` | 22.94M | 4.10B | 54.57 ± 0.26 | 83.45 | 3.809 | 56.75 | 1.0712 | 41.09 | 20.14 | 62.36 |
| `MAIA-3-79M` | 78.90M | 4.10B | 55.80 ± 0.26 | 84.48 | 3.650 | 57.08 | 1.0598 | 42.50 | **20.00** | 62.96 |
| **`chessforge-35m` (Ours)** | **35.24M** | **0.51B** | 58.50 ± 0.25 | 86.37 | 3.300 | 63.89 | 0.7991 | 44.74 | 20.79 | 62.98 |
| **`chessforge-35m` (`--mask_titles`)** | **35.24M** | **0.51B** | **58.86 ± 0.25** | **86.66** | **3.248** | **65.57** | **0.7516** | **45.05** | 21.01 | 62.67 |
| **`+ Anti-Engine DPO (c=1.5)` (`dpo_c1p5/`)** | **35.24M** | **+1.0M** | 58.03 ± 0.25 | 85.92 | 3.617 | 63.49 | 0.8085 | 44.64 | 20.18 | **64.68** |

### 3. Cognitive Effort Calibration & System-1 vs. System-2 Example (`Eval-Titled-Online`)

| Variant | Marginal Effort NLL $H(U \mid S)$ ↓ | Posterior Effort NLL $H(U \mid S, A)$ ↓ | MI $I(A; U \mid S)$ (nats) ↑ | Joint NLL ↓ | Effort MAE ↓ | Effort Pearson $r$ ↑ |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: |
| **`chessforge-35m` (Main)** | **2.0554** | **2.0289** | 0.0265 | **3.0916** | 0.0999 | **0.6747** |
| **`+ Anti-Engine DPO (c=1.5)` (`dpo_c1p5/`)** | 2.0618 | 2.0341 | **0.0277** | 3.1578 | **0.0998** | 0.6724 |

* **Qualitative GM Example (`IM 2748` vs. `GM 2740`, Ply 51, Clock `76.0s`, FEN `2q3k1/1pp1rpp1/pnnr3p/2N1p3/3P4/2P3P1/PP3PBP/3RRQK1 b - - 0 1`):**
  * **Fast System-1 Effort Top-3:** `exd4` (`82.5%` — automatic recapture), `Nd7` (`4.4%`), `Qe8` (`3.9%`)
  * **Slow System-2 Effort Top-3:** `Nd7` (`18.1%` — prophylactic knight reroute), `exd4` (`12.4%`), `Kf8` (`9.9%`)
  * **Observed Human Action:** Played `Nd7` after `14.0s` deep think ($\text{JSD} = 0.2887\text{ nats}$).

---

## Repository Contents

* `model.msgpack` (`~141.0 MB`) — Primary Stage-2 `chessforge-35m` pure `float32` Flax NNX weights.
* `checkpoints/250000/` — Native Orbax `TrainState` checkpoint for out-of-the-box use with `chessforge.cli.uci` and `chessforge.cli.eval`.
* `dpo_c1p5/model.msgpack` (`~141.0 MB`) — Stage-3 KL-Anchored, Value-Frozen Anti-Engine DPO (`dpo_coef = 1.5`, step `1000`) pure `float32` Flax NNX weights + evaluation JSONs.
* `config.yaml`, `model_config.json`, `train_config.json`, and `eval_results/` — Ready-to-run configs and full evaluation JSONs (including Elo-stratified curves).

---

## 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-35m', local_dir='./chessforge-35m')"
```

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

### 3. Standalone JAX / Flax NNX Inference (Main Joint Flagship or Anti-Engine DPO `dpo_c1p5`)
```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-35m")
meta = json.loads((ckpt_dir / "model_config.json").read_text())
model_cfg = ModelConfig(**meta["model_config"])

# Choose either "model.msgpack" (Stage-2 Joint SFT) or "dpo_c1p5/model.msgpack" (Stage-3 Anti-Engine DPO)
weights_path = ckpt_dir / "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, weights_path.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)

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([2650.0]),
    "oppo_elo": jnp.array([2650.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; `3,235.6 pos/s` sustained on a single Google Cloud TPU `v6e-1` without activation rematerialization) using an exact 1-pass streaming shard iterator (`0%` within-epoch duplicates) and Warmup–Stable–Decay (`WSD`, `lr = 2.5e-4 -> 2.0e-6`, `grad_clip_norm = 2.0`, `label_smoothing = 0.0`). Stage 1 (`200k` steps) trained on **Pool B** (`703.6M` unique positions); Stage 2 (`50k` steps) cosine-annealed onto **Pool C** (`310.6M` unique positions: `88.26%` Pure Titled Online + `11.74%` FIDE OTB Classical). Stage-3 Anti-Engine DPO (`dpo_c1p5/`) trained for `1,000` steps (`BS = 1024`, `kl_coef = 0.75`, `dpo_coef = 1.5`, `dpo_beta = 0.25`, `freeze_value_head = true`) on `800,000` Stockfish-annotated titled positions.
* **Limitations:** Because ~88% of titled training games are online Blitz/Rapid, title embeddings absorb a slight online prior; passing `--mask_titles` during inference on FIDE OTB games boosts OTB Move Accuracy from `58.50%` to `58.86%` and OTB Value Accuracy from `63.89%` to `65.57%`.

---

## 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-35m}}
}
```