Instructions to use ankanmbz/chess-tok with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ankanmbz/chess-tok with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ankanmbz/chess-tok", device_map="auto") - Notebooks
- Google Colab
- Kaggle
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
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support