Grandmaster-Level Chess Without Search
Paper โข 2402.04494 โข Published โข 69
Grandmaster-Level Chess Without Search โ A decoder-only transformer trained via behavioral cloning to predict chess moves directly from board state, with no search algorithm (no MCTS, no Alpha-Beta).
Based on the approach from arXiv:2402.04494.
| Variant | d_model | Layers | Heads | Parameters | Checkpoint |
|---|---|---|---|---|---|
| Small | 256 | 8 | 8 | ~19M | small/checkpoint.pt |
| Mid | 512 | 16 | 8 | ~100M | mid/checkpoint.pt |
| Large | 1024 | 40 | 32 | ~500M | large/checkpoint.pt |
import torch
from artoria import ChessTokenizer, GrandmasterChessModel, ChessModelConfig
import json
# Load config
with open("small/config.json") as f:
config = ChessModelConfig(**json.load(f))
tokenizer = ChessTokenizer()
config.num_classes = tokenizer.num_actions
model = GrandmasterChessModel(config)
checkpoint = torch.load("small/checkpoint.pt", map_location="cpu")
model.load_state_dict(checkpoint["model_state_dict"])
model.eval()
# Predict move from FEN
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
tokens = tokenizer.tokenize(fen).unsqueeze(0)
with torch.no_grad():
logits, value = model(tokens)
# Get best legal move
import chess
board = chess.Board(fen)
best_move, best_prob = None, -1
probs = torch.softmax(logits[0], dim=0)
for m in board.legal_moves:
idx = tokenizer.action_to_class(m.uci())
if idx != -1 and probs[idx].item() > best_prob:
best_move, best_prob = m.uci(), probs[idx].item()
print(f"Best move: {best_move} (confidence: {best_prob:.4f}, eval: {value.item():.4f})")
Trained on Lichess standard chess games via behavioral cloning (imitation learning). The model learns to predict the next move played by strong players given a board position.
MIT