chess-Tok: Efficient Chess Move Tokenizer

This chess tokenizer uses a large vocabulary (~844 tokens) with semantically meaningful units like 'w.', 'b.', piece+square combinations ('β™™e4', 'β™žf6'), and complete suffixes ('..', '.x.', '.+').

This design reduces sequence length by ~60% compared to character-level tokenization, enabling faster training and better gradient flow in recurrent models.

Usage

from transformers import AutoTokenizer

# Load tokenizer directly from HuggingFace
tokenizer = AutoTokenizer.from_pretrained("ankanmbz/chess-tok", trust_remote_code=True)

# Tokenize chess moves
text = "w.β™™e2β™™e4.."
encoded = tokenizer(text, return_tensors="pt")
print(encoded)

# Decode
decoded = tokenizer.decode(encoded['input_ids'][0])
print(decoded)

# Batch processing
moves = ["w.β™™e2β™™e4..", "b.β™Ÿc7β™Ÿc5..", "w.β™˜g1β™˜f3.."]
batch = tokenizer(moves, padding=True, return_tensors="pt")
print(batch)

Features

  • βœ… Semantic units (not character-level)
  • βœ… 60% shorter sequences
  • βœ… Special tokens: <pad>, <sos>, <eos>, <unk>
  • βœ… Compatible with HuggingFace transformers
  • βœ… Batch processing with padding
  • βœ… Optimized for tiny recurrent models

Vocabulary Size

844 tokens

Token Categories

  • Move prefixes: w., b.
  • Piece+Square: β™™e2, β™žf6, etc.
  • Squares: a1, e4, h8, etc.
  • Suffixes: .., .x., .+, .+#, etc.

Example Tokenization

Input: "w.β™™e2β™™e4.." Tokens: ['w.', 'β™™e2', 'β™™e4', '..'] Token count: 4 (vs ~10 with character-level)

Training Details

  • Built from 1M chess games
  • Frequency-based vocabulary ordering
  • Covers all common chess move patterns

License

Apache 2.0

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support