MushroomBody_Chess / README.md
phclab's picture
MushroomBody_Chess v2
dc35150 verified
|
Raw History Blame Contribute Delete
5.87 kB
---
license: cc-by-nc-4.0
tags:
- chess
- spiking-neural-network
- connectome
- drosophila
- rsnn
---
# MushroomBody_Chess v2
Synaptic weights for **[BeatTheFly](https://phclab.github.io/BeatTheFly/)** -- *A Smart Fruit Fly is playing chess against you*: a spiking network
wired as the real *Drosophila* mushroom-body connectome that plays chess.
**The anatomical connectome gives you wiring, not synaptic strengths. Ours are trained.**
Synaptic weights trained with PHCSSM parallel-scan mode, deployment in sequential RSNN mode ([PHCSSM](https://arxiv.org/abs/2604.01295)).
made by Po-Han Chiang @ NYCU
## Architecture
* **Wiring:** MaleCNS v1.0 mushroom body -- 4,510 neurons (4,064 Kenyon cells, 97 MBONs,
340 DANs, 2 APL, 2 DPM, 5 MB-C1) and 1,027,152 neuron-to-neuron connections. The
connectivity mask is fixed to the connectome; 828,479 connections carry a nonzero weight and
0 weights lie off the connectome.
* **Dale's law:** one sign per presynaptic neuron from neurotransmitter annotations (excitatory
4,114, inhibitory 52, modulatory 344); 0 weights violate it.
* **Inputs:** each ply provides the move token (one of 1,970 UCI moves) and the board after it
(789 binary features: piece per square, castling rights, en-passant file, 50-move-clock buckets,
seen from the side to move). Two linear encoders with their own LayerNorm drive the Kenyon cells; the
move token also drives the dopaminergic neurons.
* **Neurons:** leaky integrate-and-fire with per-neuron leak, threshold and reset; synaptic delay of one step.
* **Fast weight:** dopamine-gated associative memory on the Kenyon-cell -> MBON synapses, read back into
the MBON voltages.
* **Readout:** linear map from the membrane voltage of all neurons to the move vocabulary.
* **Deployment:** sequential RSNN mode, one timestep per ply, with the neuron state and fast weight
carried across the whole game.
## Data sources
Data sources: human games from the [Lichess open database](https://database.lichess.org/) (lichess.org, CC0); move labels from the [Stockfish](https://stockfishchess.org/) chess engine.
The previous version remains in this repository's history.
## Evaluation
4,000 held-out Lichess games between players rated 2200+, legal moves only:
| | overall | opening | early middlegame | middlegame | endgame |
|---|---|---|---|---|---|
| agrees with Stockfish's best move | 44.7% | 92.8% | 60.2% | 38.2% | 31.4% |
Human move-match on the same games: 39.1%; on held-out Lichess blitz games (1500–1800): 36.4%.
**Strength:** ≈1110 Elo (95% CI ±39) vs Stockfish UCI_Elo anchors, CCRL Blitz scale, 800 games, argmax play. +139 Elo over v1 on the same openings (95% CI +75 to +211).
## Files
* `manifest.json` -- every tensor (file, dtype, shape, bytes), the model scalars and a connectome audit.
* `info.json` -- neuron metadata used by the page (cell classes, hemispheres, soma coordinates).
* `selfcheck_<precision>.json` -- reference moves and logits that the page replays when it loads.
* `chess_uci_vocab.json` -- the move vocabulary.
* `fp16/`, `fp32/` -- raw little-endian arrays.
Two precisions are listed in the manifest: `fp16w32` (default, 49.5 MB: float16 for the
four large dense matrices, float32 for the recurrent weights and all small tensors) and
`fp16` (47.8 MB, recurrent weights in float16 as well).
The recurrent weight matrix W[dst, src] is stored in CSC order by source neuron (`W_colptr`,
`W_rowidx`, `W_vals`): each step multiplies W by a sparse binary spike vector, so the engine visits only
the columns of the neurons that spiked. Dense matrices are stored in the orientation they are read:
`enc_tok_T` [vocab, H] (a move token selects one row), `enc_brd_T` [789, H] (sum of the active rows),
`dec_w` [vocab, H] and `v2d_T` [vocab, n_dan].
| name | file | dtype | shape |
|---|---|---|---|
| `enc_tok_T` | `fp16/enc_tok_T.bin` | float16 | 1970x4510 |
| `enc_tok_b` | `fp32/enc_tok_b.bin` | float32 | 4510 |
| `ln_tok_w` | `fp32/ln_tok_w.bin` | float32 | 4510 |
| `ln_tok_b` | `fp32/ln_tok_b.bin` | float32 | 4510 |
| `enc_brd_T` | `fp16/enc_brd_T.bin` | float16 | 789x4510 |
| `enc_brd_b` | `fp32/enc_brd_b.bin` | float32 | 4510 |
| `ln_brd_w` | `fp32/ln_brd_w.bin` | float32 | 4510 |
| `ln_brd_b` | `fp32/ln_brd_b.bin` | float32 | 4510 |
| `v2d_T` | `fp16/v2d_T.bin` | float16 | 1970x340 |
| `v2d_b` | `fp32/v2d_b.bin` | float32 | 340 |
| `dec_w` | `fp16/dec_w.bin` | float16 | 1970x4510 |
| `dec_b` | `fp32/dec_b.bin` | float32 | 1970 |
| `Wg` | `fp32/Wg.bin` | float32 | 97x340 |
| `W_dan_val` | `fp32/W_dan_val.bin` | float32 | 97x340 |
| `alpha_exc` | `fp32/alpha_exc.bin` | float32 | 4510 |
| `alpha_inh` | `fp32/alpha_inh.bin` | float32 | 4510 |
| `v_th` | `fp32/v_th.bin` | float32 | 4510 |
| `reset_weight` | `fp32/reset_weight.bin` | float32 | 4510 |
| `kc_idx` | `fp32/kc_idx.bin` | int32 | 4064 |
| `mbon_idx` | `fp32/mbon_idx.bin` | int32 | 97 |
| `dan_idx` | `fp32/dan_idx.bin` | int32 | 340 |
| `W_colptr` | `fp32/W_colptr.bin` | uint32 | 4511 |
| `W_rowidx` | `fp32/W_rowidx.bin` | uint16 | 828479 |
| `W_vals` | `fp32/W_vals.bin` | float32 | 828479 |
**Numerical check:** legal top-1 1968/1973 vs the fp32 reference (24 held-out games); 0 of 8,925,290 spike bits differ from the reference on the same weights.
## Limitations
There is no search and no evaluation function: each move is a single timestep of the network. It is
weakest in the endgame (31.4% agreement with Stockfish's best move).
## License and attribution
Weights: [CC-BY-NC-4.0](https://creativecommons.org/licenses/by-nc/4.0/). They are derived from the MaleCNS v1.0 connectome (Janelia FlyEM and
collaborators, https://male-cns.janelia.org/, [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/)) and trained with PHCSSM (https://arxiv.org/abs/2604.01295);
please credit both.
## Citation
PHCSSM: https://arxiv.org/abs/2604.01295