ChessBot / README.md
Maxlegrec's picture
Update README.md
5bb6e18 verified
|
raw
history blame
2.01 kB
metadata
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

import torch
from transformers import AutoModel

model = AutoModel.from_pretrained("Maxlegrec/ChessBot", trust_remote_code=True)
device = "cuda" if torch.cuda.is_available() else "cpu"
model = model.to(device)

# Example usage
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

# Get the best move
move = model.get_move_from_fen_no_thinking(fen, T=0.1, device=device)
print(f"Policy-based move: {move}")

# Get the best move using value analysis
value_move = model.get_best_move_value(fen, T=0, device=device)
print(f"Value-based move: {value_move}")

# Get position evaluation
position_value = model.get_position_value(fen, device=device)
print(f"Position value [black_win, draw, white_win]: {position_value}")

# Get move probabilities
probs = model.get_move_from_fen_no_thinking(fen, T=1, device=device, return_probs=True)
top_moves = sorted(probs.items(), key=lambda x: x[1], reverse=True)[:5]
print("Top 5 moves:")
for move, prob in top_moves:
    print(f"  {move}: {prob:.4f}")

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