File size: 4,691 Bytes
cbae1dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e9362eb
 
 
cbae1dd
 
 
 
 
 
 
 
 
 
 
 
e9362eb
cbae1dd
e9362eb
cbae1dd
 
 
 
 
e9362eb
cbae1dd
e9362eb
cbae1dd
 
 
e9362eb
cbae1dd
e9362eb
cbae1dd
 
e9362eb
 
 
 
 
 
cbae1dd
 
 
e9362eb
cbae1dd
e9362eb
 
 
 
 
cbae1dd
 
e9362eb
 
 
cbae1dd
e9362eb
 
 
cbae1dd
e9362eb
cbae1dd
e9362eb
cbae1dd
 
 
 
e9362eb
cbae1dd
 
e9362eb
 
cbae1dd
e9362eb
cbae1dd
e9362eb
cbae1dd
e9362eb
cbae1dd
 
e9362eb
cbae1dd
e9362eb
cbae1dd
e9362eb
 
 
cbae1dd
 
0acaf85
e9362eb
0acaf85
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
---
license: cc-by-nc-4.0
library_name: onnx
tags:
- chess
- deep-learning
- pytorch
- onnx
- resnet
- strategy
- game-ai
- gambitflow
datasets:
- Rafs-an09002/gambitflow-elite-data
language:
- en
pipeline_tag: reinforcement-learning
metrics:
- mse
model-index:
- name: GambitFlow Nexus-core (CE)
  results: []
---

# โ™Ÿ๏ธ GambitFlow Nexus-core (CE)

<div align="center">

![GambitFlow Banner](https://capsule-render.vercel.app/api?type=waving&color=0:8e44ad,100:2c3e50&height=200&section=header&text=Nexus-core%20CE&fontSize=50&animation=fadeIn&fontAlignY=35&desc=Elite%20ResNet%20Chess%20Intelligence&descAlignY=60)

[![License: CC BY-NC 4.0](https://img.shields.io/badge/License-CC%20BY--NC%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc/4.0/)
![Architecture](https://img.shields.io/badge/Architecture-ResNet--10-orange)
![Parameters](https://img.shields.io/badge/Params-~3.5M-blue)
![Format](https://img.shields.io/badge/Format-ONNX%20(Opset%2017)-green)
![Type](https://img.shields.io/badge/Model--Type-Static--Evaluation-red)

[**Live Engine Demo**](https://chessmate-engine.onrender.com/) โ€ข [**Dataset Card**](https://huggingface.co/datasets/Rafs-an09002/gambitflow-elite-data)

</div>

## ๐Ÿ“– Model Overview

**Nexus-core CE** (Core Edition) is the primary engine of the **GambitFlow** project. It is a deep Residual Neural Network designed to evaluate chess positions with high-level human-like intuition. Unlike traditional engines that use manual "if-then" logic, Nexus-core learned chess strategy by analyzing over **5 million positions** played by elite grandmaster-level players.

It serves as the static evaluation function (the "Brain") for the GambitFlow search algorithm, providing a numeric advantage score for any given board state.

## ๐Ÿง  Technical Architecture

The model is built using a **Residual Neural Network (ResNet)** architecture, inspired by the AlphaZero research but highly optimized for efficient inference in web browsers and low-power devices.

### Specification Table
| Component | Specification | Description |
| :--- | :--- | :--- |
| **Input Layer** | `(1, 12, 8, 8)` | 12-channel bitboard representation (6 for White, 6 for Black pieces). |
| **Convolutional Stem** | 128 Filters, 3x3 | Initial spatial feature extraction from the 8x8 grid. |
| **Residual Tower** | **10 Blocks** | A stack of 10 ResBlocks using Skip-Connections to prevent gradient vanishing and capture deep strategy. |
| **Value Head** | Dense / Tanh | Compresses 8192 high-level features into a single scalar evaluation. |
| **Output Range** | `[-1.0, 1.0]` | Positive favors White, negative favors Black. |
| **Params** | **~3.5 Million** | Balanced for high depth-to-speed ratio. |

## ๐Ÿ“Š Training Methodology

Nexus-core was trained using a professional-grade pipeline designed for robustness and strategic depth.

### 1. The Elite Dataset
We utilized the `gambitflow-elite-data` corpus:
- **Filtering:** Only games where **both players had ELO > 2000**.
- **Stage:** Focused on the first 20 moves to master opening and middlegame transition.
- **Volume:** ~5,000,000 unique positions.

### 2. Training Protocol
- **Mixed Precision:** Trained using `torch.amp` (FP16) for 2x faster convergence and memory efficiency.
- **Optimizer:** AdamW with a weight decay of `1e-4` to prevent overfitting.
- **Loss:** MSE (Mean Squared Error) between the predicted value and the actual game result.

### 3. ONNX Optimization
- Exported with **Opset 17**.
- **Constant Folding** and Graph Optimization enabled to reduce latency during real-time play.

## ๐Ÿ’ป Implementation (JavaScript)

Designed for seamless integration with `onnxruntime-web`.

```javascript
import * as ort from 'onnxruntime-web';

// 1. Load the Brain
const session = await ort.InferenceSession.create('./chess_model_v2.onnx');

// 2. Prepare 12x8x8 Tensor (Encoded from FEN)
const inputTensor = new ort.Tensor('float32', boardData, [1, 12, 8, 8]);

// 3. Get Evaluation
const results = await session.run({ board_state: inputTensor });
const score = results.evaluation.data[0];

console.log("Nexus-core Evaluation:", score);
```

## ๐Ÿ›ก๏ธ License & Ethics

This model is shared under the **Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)** license.

- **Attribution:** You must give credit to the GambitFlow project.
- **Non-Commercial:** This model cannot be used for commercial purposes without an explicit agreement.
- **Innovation:** We encourage researchers to fork and improve this model for non-commercial game-AI research.

---
<div align="center">
  <p>Developed by <a href="https://huggingface.co/Rafs-an09002">Rafsan</a> @ GambitFlow Labs</p>
</div>