|
|
--- |
|
|
license: mit |
|
|
tags: |
|
|
- chess |
|
|
- reinforcement-learning |
|
|
- game-ai |
|
|
- pytorch |
|
|
library_name: transformers |
|
|
--- |
|
|
|
|
|
# ChessBot Chess Model |
|
|
|
|
|
This is a ChessBot model for chess move prediction and position evaluation. |
|
|
|
|
|
## Model Description |
|
|
|
|
|
The ChessBot model is a transformer-based architecture designed for chess gameplay. It can: |
|
|
- Predict the next best move given a chess position (FEN) |
|
|
- Evaluate chess positions |
|
|
- Generate move probabilities |
|
|
|
|
|
## Usage |
|
|
|
|
|
```python |
|
|
import torch |
|
|
from huggingface_hub import snapshot_download |
|
|
|
|
|
# Download the model files |
|
|
model_path = snapshot_download(repo_id="Maxlegrec/ChessBot") |
|
|
|
|
|
# Add to path and import |
|
|
import sys |
|
|
sys.path.append(model_path) |
|
|
from modeling_chessbot import ChessBotModel, ChessBotConfig |
|
|
|
|
|
# Load the model |
|
|
config = ChessBotConfig() |
|
|
model = ChessBotModel.from_pretrained(model_path) |
|
|
|
|
|
# Example usage |
|
|
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" |
|
|
device = "cuda" if torch.cuda.is_available() else "cpu" |
|
|
model = model.to(device) |
|
|
|
|
|
# Get the best move |
|
|
move = model.get_move_from_fen_no_thinking(fen, T=0.1, device=device) |
|
|
print(f"Predicted move: {move}") |
|
|
``` |
|
|
|
|
|
## Requirements |
|
|
|
|
|
- torch>=2.0.0 |
|
|
- transformers>=4.30.0 |
|
|
- python-chess>=1.10.0 |
|
|
- numpy>=1.21.0 |
|
|
|
|
|
## Model Architecture |
|
|
|
|
|
- **Transformer layers**: 10 |
|
|
- **Hidden size**: 512 |
|
|
- **Feed-forward size**: 736 |
|
|
- **Attention heads**: 8 |
|
|
- **Vocabulary size**: 1929 (chess moves) |
|
|
|
|
|
## Training Data |
|
|
|
|
|
This model was trained on chess game data to learn optimal move selection and position evaluation. |
|
|
|
|
|
## Limitations |
|
|
|
|
|
- The model works best with standard chess positions |
|
|
- Performance may vary with unusual or rare positions |
|
|
- Requires GPU for optimal inference speed |
|
|
|