βοΈ ChessMate AI - CNN Evaluation Model
π Model Description
This is a Convolutional Neural Network (CNN) trained to evaluate chess positions. It takes a board state as input and outputs a scalar evaluation score between -1 (Black winning) and +1 (White winning).
It is the core "brain" of the ChessMate AI project, designed to run efficiently in web browsers using onnxruntime-web.
- Architecture: 3-Layer CNN with Batch Normalization and ReLU activation.
- Framework: Trained in PyTorch, exported to ONNX (Opset 14).
- Size: ~7.5 MB (Highly optimized for web loading).
- Training Data: 100,000+ Master-level games from Lichess (Standard Rated > 2000 ELO).
π οΈ Technical Specifications
Input Shape
The model expects a Tensor of shape (1, 12, 8, 8) representing the board state using One-Hot Encoding.
- Channels (12):
- 0-5: White Pieces (Pawn, Knight, Bishop, Rook, Queen, King)
- 6-11: Black Pieces (Pawn, Knight, Bishop, Rook, Queen, King)
- Dimensions (8x8): The chess board squares.
Output
- Shape:
(1, 1) - Value: Float between
-1.0and1.0.> 0: Advantage White< 0: Advantage Black~ 0: Equal/Draw
π» Usage (JavaScript / ONNX.js)
This model is designed to be used directly in the browser via onnxruntime-web.
import * as ort from 'onnxruntime-web';
// 1. Load the session
const session = await ort.InferenceSession.create('./chess_model.onnx');
// 2. Prepare Input (Float32Array of size 12*8*8)
// Convert FEN string to 12x8x8 one-hot encoded array
const inputData = new Float32Array(768).fill(0);
// ... (Fill array based on piece positions) ...
const tensor = new ort.Tensor('float32', inputData, [1, 12, 8, 8]);
// 3. Run Inference
const results = await session.run({ board_state: tensor });
const evaluation = results.evaluation.data[0];
console.log(`Position Score: ${evaluation}`);
π§ Training Details
- Loss Function: Mean Squared Error (MSE)
- Optimizer: Adam (lr=0.001)
- Epochs: 50 (with Early Stopping)
- Target Label: Normalized Stockfish Evaluation / Game Result (Win/Loss/Draw).
β οΈ License & Limitations
This model is licensed under CC BY-NC 4.0 (Attribution-NonCommercial 4.0 International).
You are free to:
- Use this model for research, education, and personal projects.
- Modify and adapt the model.
You may NOT:
- Sell this model or use it in a commercial product without permission.
Curated by GambitFlow