--- license: mit tags: - chess - game-ai - pytorch - safetensors library_name: transformers --- # ChessLC0 Chess Model This is BT4, the model behind LeelaChessZero Engine, one of the best Neural Network based engine available. This model is way worse than stockfish but constitute one of the best 0 search heuristics out there. For stronger play, reducing temperature T (lower is stronger) is suggested. ## Model Description The ChessLC0 model is a transformer-based architecture designed for chess gameplay. It can: - Predict the next best move given a move history (requires 7 prior boards) - Evaluate chess positions - Generate move probabilities **Important**: This model requires move history (7 prior boards) to work properly. You must provide a list of UCI moves representing the game history. ## Please Like if this model is useful to you :) A like goes a long way ! ## Usage ```python import torch from transformers import AutoModel model = AutoModel.from_pretrained("Maxlegrec/ChessLC0", trust_remote_code=True) device = "cuda" if torch.cuda.is_available() else "cpu" model = model.to(device) # Example usage with move history (model requires 7 prior boards) # This sequence provides enough history for the model move_history = [ "e2e4", "e7e5", "g1f3", "b8c6", "f1b5", "a7a6", "b5a4", "g8f6", "e1g1", "f8e7", "f1e1", "b7b5", "a4b3", "d7d6" ] # Sample move from policy move = model.get_move_from_history(move_history, T=0.1, device=device) print(f"Policy-based move: {move}") # Get the best move using value analysis value_move, value = model.get_best_move_value(move_history, T=0, device=device) print(f"Value-based move: {value_move}") print(f"Position value [black_win, draw, white_win]: {value}") # Get position evaluation position_value = model.get_position_value(move_history, device=device) print(f"Position value [current_side_win, draw, opposite_side_win]: {position_value}") # Get move probabilities probs = model.get_move_from_history(move_history, 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 python-version >=3.13 cuda-version < 13.0 - torch>=2.0.0 - transformers>=4.48.1 - bulletchess>=0.4.0 - numpy>=1.21.0 ## Model Architecture - **Transformer layers**: 15 - **Hidden size**: 1024 - **Feed-forward size**: 1536 - **Attention heads**: 32 - **Vocabulary size**: 1858 (chess moves)