rzhang-7 commited on
Commit
c5361c5
·
1 Parent(s): ce5ebae

Upload chess policy network model

Browse files
Files changed (3) hide show
  1. README.md +90 -0
  2. config.json +9 -0
  3. pytorch_model.bin +3 -0
README.md CHANGED
@@ -1,3 +1,93 @@
1
  ---
 
 
 
 
 
 
 
2
  license: mit
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ tags:
3
+ - chess
4
+ - reinforcement-learning
5
+ - pytorch
6
+ - neural-network
7
+ language:
8
+ - en
9
  license: mit
10
  ---
11
+
12
+ # Chess Policy Network
13
+
14
+ A neural network-based chess engine that uses a policy network to predict the best moves.
15
+
16
+ ## Model Details
17
+
18
+ - **Architecture**: Convolutional ResNet with policy head
19
+ - **Input**: 12-channel board representation (piece positions for each color)
20
+ - **Output**: 4672 move logits
21
+ - **Total Parameters**: 5,827,456
22
+
23
+ ## Architecture Configuration
24
+
25
+ ```python
26
+ input_channels: 12
27
+ num_res_blocks: 8
28
+ filters: 128
29
+ policy_channels: 32
30
+ num_move_classes: 4672
31
+ dropout: 0.1
32
+ activation: relu
33
+ ```
34
+
35
+ ## Training Data
36
+
37
+ - Trained on high-ELO chess games (minimum rating: 2200+)
38
+ - Supervised learning on master games
39
+ - Cross-entropy loss with AdamW optimizer
40
+ - Cosine annealing learning rate schedule
41
+
42
+ ## Usage
43
+
44
+ ```python
45
+ import torch
46
+ from huggingface_hub import hf_hub_download
47
+ from training.models import PolicyNetwork
48
+ from training.utils import encode_board
49
+
50
+ # Load model
51
+ model_path = hf_hub_download("rzhang-7/chesshacks-model", "pytorch_model.bin")
52
+ model = PolicyNetwork.from_config(config)
53
+ model.load(model_path)
54
+ model.eval()
55
+
56
+ # Get move predictions for a position
57
+ board_tensor = encode_board(board)
58
+ with torch.no_grad():
59
+ logits = model(board_tensor.unsqueeze(0))
60
+
61
+ # Convert to legal moves
62
+ move_probs = filter_policy_to_legal(logits[0].numpy(), board)
63
+ ```
64
+
65
+ ## Performance
66
+
67
+ Evaluate with:
68
+ ```bash
69
+ python training/scripts/evaluate.py --model-path path/to/model.pt --data-dir training/data
70
+ ```
71
+
72
+ ## License
73
+
74
+ MIT
75
+
76
+ ## Citation
77
+
78
+ If you use this model, please cite:
79
+
80
+ ```bibtex
81
+ @model{chess_policy_net,
82
+ title={Chess Policy Network},
83
+ author={Chess Hacks},
84
+ year={2024},
85
+ url={https://huggingface.co/rzhang-7/chesshacks-model}
86
+ }
87
+ ```
88
+
89
+ ## Disclaimers
90
+
91
+ - This model is trained on historical chess games and may reflect biases in those games
92
+ - The model is provided as-is without guarantees
93
+ - For competitive chess, consider using dedicated engines like Stockfish or Leela Chess Zero
config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "input_channels": 12,
3
+ "num_res_blocks": 8,
4
+ "filters": 128,
5
+ "policy_channels": 32,
6
+ "num_move_classes": 4672,
7
+ "dropout": 0.1,
8
+ "activation": "relu"
9
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b583fa9cb5da9ac848f545e54c08962515e2d24856a07ff49d91a92abbab106a
3
+ size 23365825