TristanoBer commited on
Commit
e6b49da
·
verified ·
1 Parent(s): 69e2215

Chess Challenge submission by TristanoBer

Browse files
Files changed (7) hide show
  1. README.md +26 -0
  2. config.json +22 -0
  3. model.safetensors +3 -0
  4. special_tokens_map.json +6 -0
  5. tokenizer.py +462 -0
  6. tokenizer_config.json +53 -0
  7. vocab.json +155 -0
README.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags:
4
+ - chess
5
+ - llm-course
6
+ - chess-challenge
7
+ license: mit
8
+ ---
9
+
10
+ # TristanB_3
11
+
12
+ Chess model submitted to the LLM Course Chess Challenge.
13
+
14
+ ## Submission Info
15
+
16
+ - **Submitted by**: [TristanoBer](https://huggingface.co/TristanoBer)
17
+ - **Parameters**: 948,784
18
+ - **Organization**: LLM-course
19
+
20
+ ## Model Details
21
+
22
+ - **Architecture**: Chess Transformer (GPT-style)
23
+ - **Vocab size**: 153
24
+ - **Embedding dim**: 152
25
+ - **Layers**: 4
26
+ - **Heads**: 4
config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ChessForCausalLM"
4
+ ],
5
+ "bos_token_id": 1,
6
+ "dropout": 0.1,
7
+ "dtype": "float32",
8
+ "eos_token_id": 2,
9
+ "model_type": "chess_transformer",
10
+ "n_ctx": 768,
11
+ "n_embd": 152,
12
+ "n_head": 4,
13
+ "n_inner": 304,
14
+ "n_layer": 4,
15
+ "norm_epsilon": 1e-06,
16
+ "pad_token_id": 0,
17
+ "rope_theta": 10000.0,
18
+ "tie_weights": true,
19
+ "transformers_version": "4.57.2",
20
+ "use_rmsnorm": true,
21
+ "vocab_size": 153
22
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2201ceba8b3f7b6f2d11ab40f4d0570ce2f879fd3735384db70c8fa49a0f028
3
+ size 3797720
special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "[BOS]",
3
+ "eos_token": "[EOS]",
4
+ "pad_token": "[PAD]",
5
+ "unk_token": "[UNK]"
6
+ }
tokenizer.py ADDED
@@ -0,0 +1,462 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Custom Chess Tokenizer for the Chess Challenge.
3
+
4
+ This tokenizer treats each move as a single token using the extended UCI notation
5
+ from the Lichess dataset (e.g., WPe2e4, BNg8f6).
6
+
7
+ The dataset format uses:
8
+ - W/B prefix for White/Black
9
+ - Piece letter: P=Pawn, N=Knight, B=Bishop, R=Rook, Q=Queen, K=King
10
+ - Source and destination squares (e.g., e2e4)
11
+ - Special suffixes: (x)=capture, (+)=check, (+*)=checkmate, (o)/(O)=castling
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import os
18
+ from pathlib import Path
19
+ from typing import Dict, List, Optional
20
+
21
+ from transformers import PreTrainedTokenizer
22
+
23
+ import re
24
+
25
+
26
+
27
+
28
+ class prev_ChessTokenizer(PreTrainedTokenizer):
29
+ """
30
+ A custom tokenizer for chess moves using extended UCI notation.
31
+
32
+ This tokenizer maps each possible chess move to a unique token ID.
33
+ The vocabulary is built from the training dataset to ensure all moves
34
+ encountered during training have a corresponding token.
35
+
36
+ Example:
37
+ >>> tokenizer = ChessTokenizer()
38
+ >>> tokenizer.encode("WPe2e4 BPe7e5")
39
+ [1, 42, 87, 2] # [BOS, e2e4, e7e5, EOS]
40
+ """
41
+
42
+ model_input_names = ["input_ids", "attention_mask"]
43
+ vocab_files_names = {"vocab_file": "vocab.json"}
44
+
45
+ # Special tokens
46
+ PAD_TOKEN = "[PAD]"
47
+ BOS_TOKEN = "[BOS]"
48
+ EOS_TOKEN = "[EOS]"
49
+ UNK_TOKEN = "[UNK]"
50
+
51
+ def __init__(
52
+ self,
53
+ vocab_file: Optional[str] = None,
54
+ vocab: Optional[Dict[str, int]] = None,
55
+ **kwargs,
56
+ ):
57
+ """
58
+ Initialize the chess tokenizer.
59
+
60
+ Args:
61
+ vocab_file: Path to a JSON file containing the vocabulary mapping.
62
+ vocab: Dictionary mapping tokens to IDs (alternative to vocab_file).
63
+ **kwargs: Additional arguments passed to PreTrainedTokenizer.
64
+ """
65
+ # Initialize special tokens
66
+ self._pad_token = self.PAD_TOKEN
67
+ self._bos_token = self.BOS_TOKEN
68
+ self._eos_token = self.EOS_TOKEN
69
+ self._unk_token = self.UNK_TOKEN
70
+
71
+ # Remove any duplicate special-token entries passed through kwargs
72
+ # to avoid "multiple values for keyword" errors when loading from disk.
73
+ kwargs.pop("pad_token", None)
74
+ kwargs.pop("bos_token", None)
75
+ kwargs.pop("eos_token", None)
76
+ kwargs.pop("unk_token", None)
77
+
78
+ # Load or create vocabulary
79
+ if vocab is not None:
80
+ self._vocab = vocab
81
+ elif vocab_file is not None and os.path.exists(vocab_file):
82
+ with open(vocab_file, "r", encoding="utf-8") as f:
83
+ self._vocab = json.load(f)
84
+ else:
85
+ # Create a minimal vocabulary with just special tokens
86
+ # The full vocabulary should be built from the dataset
87
+ self._vocab = self._create_default_vocab()
88
+
89
+ # Create reverse mapping
90
+ self._ids_to_tokens = {v: k for k, v in self._vocab.items()}
91
+
92
+ # Call parent init AFTER setting up vocab
93
+ super().__init__(
94
+ pad_token=self._pad_token,
95
+ bos_token=self._bos_token,
96
+ eos_token=self._eos_token,
97
+ unk_token=self._unk_token,
98
+ **kwargs,
99
+ )
100
+
101
+ def _create_default_vocab(self) -> Dict[str, int]:
102
+ """
103
+ Create a minimal default vocabulary with just special tokens.
104
+
105
+ For the full vocabulary, use `build_vocab_from_dataset()`.
106
+ This minimal vocab is just a placeholder - you should build from data.
107
+ """
108
+ special_tokens = [self.PAD_TOKEN, self.BOS_TOKEN, self.EOS_TOKEN, self.UNK_TOKEN]
109
+ vocab = {token: idx for idx, token in enumerate(special_tokens)}
110
+ return vocab
111
+
112
+ @classmethod
113
+ def build_vocab_from_iterator(
114
+ cls,
115
+ iterator,
116
+ min_frequency: int = 1,
117
+ ) -> "ChessTokenizer":
118
+ """
119
+ Build a tokenizer vocabulary from an iterator of game strings.
120
+
121
+ Args:
122
+ iterator: An iterator yielding game strings (space-separated moves).
123
+ min_frequency: Minimum frequency for a token to be included.
124
+
125
+ Returns:
126
+ A ChessTokenizer with the built vocabulary.
127
+ """
128
+ from collections import Counter
129
+
130
+ token_counts = Counter()
131
+
132
+ for game in iterator:
133
+ moves = game.strip().split()
134
+ token_counts.update(moves)
135
+
136
+ # Filter by frequency
137
+ tokens = [
138
+ token for token, count in token_counts.items()
139
+ if count >= min_frequency
140
+ ]
141
+
142
+ # Sort for reproducibility
143
+ tokens = sorted(tokens)
144
+
145
+ # Build vocabulary
146
+ special_tokens = [cls.PAD_TOKEN, cls.BOS_TOKEN, cls.EOS_TOKEN, cls.UNK_TOKEN]
147
+ vocab = {token: idx for idx, token in enumerate(special_tokens + tokens)}
148
+
149
+ return cls(vocab=vocab)
150
+
151
+ @classmethod
152
+ def build_vocab_from_dataset(
153
+ cls,
154
+ dataset_name: str = "dlouapre/lichess_2025-01_1M",
155
+ split: str = "train",
156
+ column: str = "text",
157
+ min_frequency: int = 500,
158
+ max_samples: Optional[int] = 100000,
159
+ ) -> "ChessTokenizer":
160
+ """
161
+ Build a tokenizer vocabulary from a Hugging Face dataset.
162
+
163
+ Args:
164
+ dataset_name: Name of the dataset on Hugging Face Hub.
165
+ split: Dataset split to use.
166
+ column: Column containing the game strings.
167
+ min_frequency: Minimum frequency for a token to be included (default: 500).
168
+ max_samples: Maximum number of samples to process (default: 100k).
169
+
170
+ Returns:
171
+ A ChessTokenizer with the built vocabulary.
172
+ """
173
+ from datasets import load_dataset
174
+
175
+ dataset = load_dataset(dataset_name, split=split)
176
+
177
+ if max_samples is not None:
178
+ dataset = dataset.select(range(min(max_samples, len(dataset))))
179
+
180
+ def game_iterator():
181
+ for example in dataset:
182
+ yield example[column]
183
+
184
+ return cls.build_vocab_from_iterator(game_iterator(), min_frequency=min_frequency)
185
+
186
+ @property
187
+ def vocab_size(self) -> int:
188
+ """Return the size of the vocabulary."""
189
+ return len(self._vocab)
190
+
191
+ def get_vocab(self) -> Dict[str, int]:
192
+ """Return the vocabulary as a dictionary."""
193
+ return dict(self._vocab)
194
+
195
+ def _tokenize(self, text: str) -> List[str]:
196
+ """
197
+ Tokenize a string of moves into a list of tokens.
198
+
199
+ Args:
200
+ text: A string of space-separated moves.
201
+
202
+ Returns:
203
+ List of move tokens.
204
+ """
205
+ return text.strip().split()
206
+
207
+ def _convert_token_to_id(self, token: str) -> int:
208
+ """Convert a token to its ID."""
209
+ return self._vocab.get(token, self._vocab.get(self.UNK_TOKEN, 0))
210
+
211
+ def _convert_id_to_token(self, index: int) -> str:
212
+ """Convert an ID to its token."""
213
+ return self._ids_to_tokens.get(index, self.UNK_TOKEN)
214
+
215
+ def convert_tokens_to_string(self, tokens: List[str]) -> str:
216
+ """Convert a list of tokens back to a string."""
217
+ # Filter out special tokens for cleaner output
218
+ special = {self.PAD_TOKEN, self.BOS_TOKEN, self.EOS_TOKEN, self.UNK_TOKEN}
219
+ return " ".join(t for t in tokens if t not in special)
220
+
221
+ def save_vocabulary(
222
+ self,
223
+ save_directory: str,
224
+ filename_prefix: Optional[str] = None,
225
+ ) -> tuple:
226
+ """
227
+ Save the vocabulary to a JSON file.
228
+
229
+ Args:
230
+ save_directory: Directory to save the vocabulary.
231
+ filename_prefix: Optional prefix for the filename.
232
+
233
+ Returns:
234
+ Tuple containing the path to the saved vocabulary file.
235
+ """
236
+ if not os.path.isdir(save_directory):
237
+ os.makedirs(save_directory, exist_ok=True)
238
+
239
+ vocab_file = os.path.join(
240
+ save_directory,
241
+ (filename_prefix + "-" if filename_prefix else "") + "vocab.json",
242
+ )
243
+
244
+ with open(vocab_file, "w", encoding="utf-8") as f:
245
+ json.dump(self._vocab, f, ensure_ascii=False, indent=2)
246
+
247
+ return (vocab_file,)
248
+
249
+
250
+
251
+
252
+ class ChessTokenizer(PreTrainedTokenizer):
253
+ """
254
+ Semi-factorized chess tokenizer.
255
+
256
+ Each move is encoded as:
257
+ - PATTERN token: W_P, B_N, ...
258
+ - FROM_square token: FROM_e2
259
+ - TO_square token: TO_e4
260
+ - Optional suffix: CAPTURE, PROMO_Q, ...
261
+
262
+ Castling is encoded as a single token: W_OO, W_OOO, B_OO, B_OOO
263
+ """
264
+
265
+ model_input_names = ["input_ids", "attention_mask"]
266
+ vocab_files_names = {"vocab_file": "vocab.json"}
267
+
268
+ PAD_TOKEN = "[PAD]"
269
+ BOS_TOKEN = "[BOS]"
270
+ EOS_TOKEN = "[EOS]"
271
+ UNK_TOKEN = "[UNK]"
272
+
273
+ def __init__(
274
+ self,
275
+ vocab: Optional[Dict[str, int]] = None,
276
+ vocab_file: Optional[str] = None,
277
+ **kwargs,
278
+ ):
279
+ self._pad_token = self.PAD_TOKEN
280
+ self._bos_token = self.BOS_TOKEN
281
+ self._eos_token = self.EOS_TOKEN
282
+ self._unk_token = self.UNK_TOKEN
283
+
284
+ kwargs.pop("pad_token", None)
285
+ kwargs.pop("bos_token", None)
286
+ kwargs.pop("eos_token", None)
287
+ kwargs.pop("unk_token", None)
288
+
289
+ if vocab is not None:
290
+ self._vocab = vocab
291
+ elif vocab_file and os.path.exists(vocab_file):
292
+ with open(vocab_file, "r", encoding="utf-8") as f:
293
+ self._vocab = json.load(f)
294
+ else:
295
+ self._vocab = self._build_base_vocab()
296
+
297
+ self._ids_to_tokens = {v: k for k, v in self._vocab.items()}
298
+
299
+ super().__init__(
300
+ pad_token=self._pad_token,
301
+ bos_token=self._bos_token,
302
+ eos_token=self._eos_token,
303
+ unk_token=self._unk_token,
304
+ **kwargs,
305
+ )
306
+
307
+ # ------------------------------------------------------------------
308
+ # Vocabulary
309
+ # ------------------------------------------------------------------
310
+
311
+ def _build_base_vocab(self) -> Dict[str, int]:
312
+ vocab = {}
313
+
314
+ def add(tok):
315
+ vocab[tok] = len(vocab)
316
+
317
+ # Special tokens
318
+ for tok in [self.PAD_TOKEN, self.BOS_TOKEN, self.EOS_TOKEN, self.UNK_TOKEN]:
319
+ add(tok)
320
+
321
+ # Patterns: W_P, B_N, ...
322
+ for color in ["W", "B"]:
323
+ for piece in ["P", "N", "B", "R", "Q", "K"]:
324
+ add(f"{color}_{piece}")
325
+
326
+ # Castling
327
+ for tok in ["W_OO", "W_OOO", "B_OO", "B_OOO"]:
328
+ add(tok)
329
+
330
+ # Squares
331
+ files = "abcdefgh"
332
+ ranks = "12345678"
333
+ for f in files:
334
+ for r in ranks:
335
+ add(f"FROM_{f}{r}")
336
+ add(f"TO_{f}{r}")
337
+
338
+ # Suffixes
339
+ add("CAPTURE")
340
+ for p in ["Q", "R", "B", "N"]:
341
+ add(f"PROMO_{p}")
342
+
343
+ return vocab
344
+
345
+ # ------------------------------------------------------------------
346
+ # Tokenization
347
+ # ------------------------------------------------------------------
348
+
349
+ MOVE_RE = re.compile(
350
+ r"(?P<color>[WB])"
351
+ r"(?P<piece>[PNBRQK])"
352
+ r"(?P<from>[a-h][1-8])"
353
+ r"(?P<to>[a-h][1-8])"
354
+ r"(?P<suffix>.*)?"
355
+ )
356
+
357
+ def _tokenize(self, text: str) -> List[str]:
358
+ tokens = []
359
+ moves = text.strip().split()
360
+
361
+ for move in moves:
362
+ # Castling
363
+ if "(O)" in move or "(o)" in move:
364
+ if move.startswith("W"):
365
+ tokens.append("W_OO")
366
+ else:
367
+ tokens.append("B_OO")
368
+ continue
369
+
370
+ if "(OO)" in move or "(OOO)" in move:
371
+ tokens.append("W_OOO" if move.startswith("W") else "B_OOO")
372
+ continue
373
+
374
+ m = self.MOVE_RE.match(move)
375
+ if not m:
376
+ tokens.append(self.UNK_TOKEN)
377
+ continue
378
+
379
+ color = m["color"]
380
+ piece = m["piece"]
381
+ from_sq = m["from"]
382
+ to_sq = m["to"]
383
+ suffix = m["suffix"] or ""
384
+
385
+ tokens.append(f"{color}_{piece}")
386
+ tokens.append(f"FROM_{from_sq}")
387
+ tokens.append(f"TO_{to_sq}")
388
+
389
+ if "(x)" in suffix:
390
+ tokens.append("CAPTURE")
391
+
392
+ if "=" in suffix:
393
+ promo = suffix[-1]
394
+ tokens.append(f"PROMO_{promo}")
395
+
396
+ return tokens
397
+
398
+ def get_vocab(self) -> Dict[str, int]:
399
+ return dict(self._vocab)
400
+
401
+ # ------------------------------------------------------------------
402
+ # Conversions
403
+ # ------------------------------------------------------------------
404
+
405
+ def _convert_token_to_id(self, token: str) -> int:
406
+ return self._vocab.get(token, self._vocab[self.UNK_TOKEN])
407
+
408
+ def _convert_id_to_token(self, index: int) -> str:
409
+ return self._ids_to_tokens.get(index, self.UNK_TOKEN)
410
+
411
+ def convert_tokens_to_string(self, tokens: List[str]) -> str:
412
+ # For evaluation, we usually decode move-by-move elsewhere
413
+ return " ".join(tokens)
414
+
415
+ def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = None):
416
+ os.makedirs(save_directory, exist_ok=True)
417
+ path = os.path.join(
418
+ save_directory,
419
+ (filename_prefix + "-" if filename_prefix else "") + "vocab.json",
420
+ )
421
+ with open(path, "w", encoding="utf-8") as f:
422
+ json.dump(self._vocab, f, indent=2)
423
+ return (path,)
424
+
425
+ @property
426
+ def vocab_size(self) -> int:
427
+ return len(self._vocab)
428
+
429
+
430
+ def count_vocab_from_dataset(
431
+ dataset_name: str = "dlouapre/lichess_2025-01_1M",
432
+ split: str = "train",
433
+ column: str = "text",
434
+ max_samples: Optional[int] = 10000,
435
+ ) -> Dict[str, int]:
436
+ """
437
+ Count token frequencies in a dataset (useful for vocabulary analysis).
438
+
439
+ Args:
440
+ dataset_name: Name of the dataset on Hugging Face Hub.
441
+ split: Dataset split to use.
442
+ column: Column containing the game strings.
443
+ max_samples: Maximum number of samples to process.
444
+
445
+ Returns:
446
+ Dictionary mapping tokens to their frequencies.
447
+ """
448
+ from collections import Counter
449
+ from datasets import load_dataset
450
+
451
+ dataset = load_dataset(dataset_name, split=split)
452
+
453
+ if max_samples is not None:
454
+ dataset = dataset.select(range(min(max_samples, len(dataset))))
455
+
456
+ token_counts = Counter()
457
+
458
+ for example in dataset:
459
+ moves = example[column].strip().split()
460
+ token_counts.update(moves)
461
+
462
+ return dict(token_counts)
tokenizer_config.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[BOS]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[EOS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ }
35
+ },
36
+ "auto_map": {
37
+ "AutoTokenizer": [
38
+ "tokenizer.ChessTokenizer",
39
+ null
40
+ ]
41
+ },
42
+ "bos_token": "[BOS]",
43
+ "clean_up_tokenization_spaces": false,
44
+ "dataset_name": "dlouapre/lichess_2025-01_1M",
45
+ "eos_token": "[EOS]",
46
+ "extra_special_tokens": {},
47
+ "max_samples": 100000,
48
+ "min_frequency": 500,
49
+ "model_max_length": 1000000000000000019884624838656,
50
+ "pad_token": "[PAD]",
51
+ "tokenizer_class": "ChessTokenizer",
52
+ "unk_token": "[UNK]"
53
+ }
vocab.json ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "[PAD]": 0,
3
+ "[BOS]": 1,
4
+ "[EOS]": 2,
5
+ "[UNK]": 3,
6
+ "W_P": 4,
7
+ "W_N": 5,
8
+ "W_B": 6,
9
+ "W_R": 7,
10
+ "W_Q": 8,
11
+ "W_K": 9,
12
+ "B_P": 10,
13
+ "B_N": 11,
14
+ "B_B": 12,
15
+ "B_R": 13,
16
+ "B_Q": 14,
17
+ "B_K": 15,
18
+ "W_OO": 16,
19
+ "W_OOO": 17,
20
+ "B_OO": 18,
21
+ "B_OOO": 19,
22
+ "FROM_a1": 20,
23
+ "TO_a1": 21,
24
+ "FROM_a2": 22,
25
+ "TO_a2": 23,
26
+ "FROM_a3": 24,
27
+ "TO_a3": 25,
28
+ "FROM_a4": 26,
29
+ "TO_a4": 27,
30
+ "FROM_a5": 28,
31
+ "TO_a5": 29,
32
+ "FROM_a6": 30,
33
+ "TO_a6": 31,
34
+ "FROM_a7": 32,
35
+ "TO_a7": 33,
36
+ "FROM_a8": 34,
37
+ "TO_a8": 35,
38
+ "FROM_b1": 36,
39
+ "TO_b1": 37,
40
+ "FROM_b2": 38,
41
+ "TO_b2": 39,
42
+ "FROM_b3": 40,
43
+ "TO_b3": 41,
44
+ "FROM_b4": 42,
45
+ "TO_b4": 43,
46
+ "FROM_b5": 44,
47
+ "TO_b5": 45,
48
+ "FROM_b6": 46,
49
+ "TO_b6": 47,
50
+ "FROM_b7": 48,
51
+ "TO_b7": 49,
52
+ "FROM_b8": 50,
53
+ "TO_b8": 51,
54
+ "FROM_c1": 52,
55
+ "TO_c1": 53,
56
+ "FROM_c2": 54,
57
+ "TO_c2": 55,
58
+ "FROM_c3": 56,
59
+ "TO_c3": 57,
60
+ "FROM_c4": 58,
61
+ "TO_c4": 59,
62
+ "FROM_c5": 60,
63
+ "TO_c5": 61,
64
+ "FROM_c6": 62,
65
+ "TO_c6": 63,
66
+ "FROM_c7": 64,
67
+ "TO_c7": 65,
68
+ "FROM_c8": 66,
69
+ "TO_c8": 67,
70
+ "FROM_d1": 68,
71
+ "TO_d1": 69,
72
+ "FROM_d2": 70,
73
+ "TO_d2": 71,
74
+ "FROM_d3": 72,
75
+ "TO_d3": 73,
76
+ "FROM_d4": 74,
77
+ "TO_d4": 75,
78
+ "FROM_d5": 76,
79
+ "TO_d5": 77,
80
+ "FROM_d6": 78,
81
+ "TO_d6": 79,
82
+ "FROM_d7": 80,
83
+ "TO_d7": 81,
84
+ "FROM_d8": 82,
85
+ "TO_d8": 83,
86
+ "FROM_e1": 84,
87
+ "TO_e1": 85,
88
+ "FROM_e2": 86,
89
+ "TO_e2": 87,
90
+ "FROM_e3": 88,
91
+ "TO_e3": 89,
92
+ "FROM_e4": 90,
93
+ "TO_e4": 91,
94
+ "FROM_e5": 92,
95
+ "TO_e5": 93,
96
+ "FROM_e6": 94,
97
+ "TO_e6": 95,
98
+ "FROM_e7": 96,
99
+ "TO_e7": 97,
100
+ "FROM_e8": 98,
101
+ "TO_e8": 99,
102
+ "FROM_f1": 100,
103
+ "TO_f1": 101,
104
+ "FROM_f2": 102,
105
+ "TO_f2": 103,
106
+ "FROM_f3": 104,
107
+ "TO_f3": 105,
108
+ "FROM_f4": 106,
109
+ "TO_f4": 107,
110
+ "FROM_f5": 108,
111
+ "TO_f5": 109,
112
+ "FROM_f6": 110,
113
+ "TO_f6": 111,
114
+ "FROM_f7": 112,
115
+ "TO_f7": 113,
116
+ "FROM_f8": 114,
117
+ "TO_f8": 115,
118
+ "FROM_g1": 116,
119
+ "TO_g1": 117,
120
+ "FROM_g2": 118,
121
+ "TO_g2": 119,
122
+ "FROM_g3": 120,
123
+ "TO_g3": 121,
124
+ "FROM_g4": 122,
125
+ "TO_g4": 123,
126
+ "FROM_g5": 124,
127
+ "TO_g5": 125,
128
+ "FROM_g6": 126,
129
+ "TO_g6": 127,
130
+ "FROM_g7": 128,
131
+ "TO_g7": 129,
132
+ "FROM_g8": 130,
133
+ "TO_g8": 131,
134
+ "FROM_h1": 132,
135
+ "TO_h1": 133,
136
+ "FROM_h2": 134,
137
+ "TO_h2": 135,
138
+ "FROM_h3": 136,
139
+ "TO_h3": 137,
140
+ "FROM_h4": 138,
141
+ "TO_h4": 139,
142
+ "FROM_h5": 140,
143
+ "TO_h5": 141,
144
+ "FROM_h6": 142,
145
+ "TO_h6": 143,
146
+ "FROM_h7": 144,
147
+ "TO_h7": 145,
148
+ "FROM_h8": 146,
149
+ "TO_h8": 147,
150
+ "CAPTURE": 148,
151
+ "PROMO_Q": 149,
152
+ "PROMO_R": 150,
153
+ "PROMO_B": 151,
154
+ "PROMO_N": 152
155
+ }