Push model using huggingface_hub.
Browse files- README.md +9 -99
- config.json +1 -3
README.md
CHANGED
@@ -1,106 +1,16 @@
|
|
1 |
---
|
2 |
license: mit
|
|
|
3 |
tags:
|
|
|
4 |
- chess
|
|
|
|
|
5 |
- reinforcement-learning
|
6 |
-
-
|
7 |
-
- pytorch
|
8 |
-
library_name: transformers
|
9 |
-
model-index:
|
10 |
-
- name: ChessBot
|
11 |
-
results:
|
12 |
-
- task:
|
13 |
-
type: other
|
14 |
-
name: Chess Move Prediction
|
15 |
-
metrics:
|
16 |
-
- type: other
|
17 |
-
name: Parameters
|
18 |
-
value: 31.7M
|
19 |
-
base_model_revision: main
|
20 |
-
widget:
|
21 |
-
- text: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKQ w KQkq - 0 1"
|
22 |
-
example_title: "Starting Position"
|
23 |
-
- text: "r1bqkb1r/pppp1ppp/2n2n2/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4"
|
24 |
-
example_title: "Italian Game"
|
25 |
---
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
## Model Description
|
32 |
-
|
33 |
-
The ChessBot model is a transformer-based architecture designed for chess gameplay. It can:
|
34 |
-
- Predict the next best move given a chess position (FEN)
|
35 |
-
- Evaluate chess positions
|
36 |
-
- Generate move probabilities
|
37 |
-
|
38 |
-
## Usage
|
39 |
-
|
40 |
-
```python
|
41 |
-
import torch
|
42 |
-
from huggingface_hub import snapshot_download
|
43 |
-
|
44 |
-
# Download the model files
|
45 |
-
model_path = snapshot_download(repo_id="Maxlegrec/ChessBot")
|
46 |
-
|
47 |
-
# Add to path and import
|
48 |
-
import sys
|
49 |
-
sys.path.append(model_path)
|
50 |
-
from modeling_chessbot import ChessBotModel, ChessBotConfig
|
51 |
-
|
52 |
-
# Load the model
|
53 |
-
config = ChessBotConfig()
|
54 |
-
model = ChessBotModel.from_pretrained(model_path)
|
55 |
-
|
56 |
-
# Example usage
|
57 |
-
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
|
58 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
59 |
-
model = model.to(device)
|
60 |
-
|
61 |
-
# Get the best move
|
62 |
-
move = model.get_move_from_fen_no_thinking(fen, T=0.1, device=device)
|
63 |
-
print(f"Policy-based move: {move}")
|
64 |
-
|
65 |
-
# Get the best move using value analysis
|
66 |
-
value_move = model.get_best_move_value(fen, T=0, device=device)
|
67 |
-
print(f"Value-based move: {value_move}")
|
68 |
-
|
69 |
-
# Get position evaluation
|
70 |
-
position_value = model.get_position_value(fen, device=device)
|
71 |
-
print(f"Position value [black_win, draw, white_win]: {position_value}")
|
72 |
-
|
73 |
-
# Get move probabilities
|
74 |
-
probs = model.get_move_from_fen_no_thinking(fen, T=1, device=device, return_probs=True)
|
75 |
-
top_moves = sorted(probs.items(), key=lambda x: x[1], reverse=True)[:5]
|
76 |
-
print("Top 5 moves:")
|
77 |
-
for move, prob in top_moves:
|
78 |
-
print(f" {move}: {prob:.4f}")
|
79 |
-
```
|
80 |
-
|
81 |
-
## Requirements
|
82 |
-
|
83 |
-
- torch>=2.0.0
|
84 |
-
- transformers>=4.30.0
|
85 |
-
- python-chess>=1.10.0
|
86 |
-
- numpy>=1.21.0
|
87 |
-
|
88 |
-
## Model Architecture
|
89 |
-
|
90 |
-
- **Transformer layers**: 10
|
91 |
-
- **Hidden size**: 512
|
92 |
-
- **Feed-forward size**: 736
|
93 |
-
- **Attention heads**: 8
|
94 |
-
- **Vocabulary size**: 1929 (chess moves)
|
95 |
-
- **Total parameters**: 31,708,102 (~31.7M)
|
96 |
-
- **Model size**: ~127MB (safetensors)
|
97 |
-
|
98 |
-
## Training Data
|
99 |
-
|
100 |
-
This model was trained on chess game data to learn optimal move selection and position evaluation.
|
101 |
-
|
102 |
-
## Limitations
|
103 |
-
|
104 |
-
- The model works best with standard chess positions
|
105 |
-
- Performance may vary with unusual or rare positions
|
106 |
-
- Requires GPU for optimal inference speed
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
+
pipeline_tag: tabular-classification
|
4 |
tags:
|
5 |
+
- board-games
|
6 |
- chess
|
7 |
+
- model_hub_mixin
|
8 |
+
- pytorch_model_hub_mixin
|
9 |
- reinforcement-learning
|
10 |
+
- transformer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
---
|
12 |
|
13 |
+
This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
|
14 |
+
- Code: https://github.com/user/chessbot
|
15 |
+
- Paper: [More Information Needed]
|
16 |
+
- Docs: [More Information Needed]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
CHANGED
@@ -2,9 +2,7 @@
|
|
2 |
"d_ff": 736,
|
3 |
"d_model": 512,
|
4 |
"max_position_embeddings": 64,
|
5 |
-
"model_type": "chessbot",
|
6 |
"num_heads": 8,
|
7 |
"num_layers": 10,
|
8 |
-
"transformers_version": "4.53.1",
|
9 |
"vocab_size": 1929
|
10 |
-
}
|
|
|
2 |
"d_ff": 736,
|
3 |
"d_model": 512,
|
4 |
"max_position_embeddings": 64,
|
|
|
5 |
"num_heads": 8,
|
6 |
"num_layers": 10,
|
|
|
7 |
"vocab_size": 1929
|
8 |
+
}
|