etiennemaugars commited on
Commit
bd06f1d
·
verified ·
1 Parent(s): 38e2f43

Chess Challenge submission by etiennemaugars

Browse files
Files changed (7) hide show
  1. README.md +26 -0
  2. config.json +20 -0
  3. model.safetensors +3 -0
  4. special_tokens_map.json +6 -0
  5. tokenizer.py +446 -0
  6. tokenizer_config.json +50 -0
  7. vocab.json +150 -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
+ # emaugars_chess_dmd
11
+
12
+ Chess model submitted to the LLM Course Chess Challenge.
13
+
14
+ ## Submission Info
15
+
16
+ - **Submitted by**: [etiennemaugars](https://huggingface.co/etiennemaugars)
17
+ - **Parameters**: 953,728
18
+ - **Organization**: LLM-course
19
+
20
+ ## Model Details
21
+
22
+ - **Architecture**: Chess Transformer (GPT-style)
23
+ - **Vocab size**: 148
24
+ - **Embedding dim**: 128
25
+ - **Layers**: 6
26
+ - **Heads**: 4
config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ChessForCausalLM"
4
+ ],
5
+ "bos_token_id": 1,
6
+ "dropout": 0.1,
7
+ "dtype": "float32",
8
+ "eos_token_id": 2,
9
+ "layer_norm_epsilon": 1e-05,
10
+ "model_type": "chess_transformer",
11
+ "n_ctx": 320,
12
+ "n_embd": 128,
13
+ "n_head": 4,
14
+ "n_inner": 320,
15
+ "n_layer": 6,
16
+ "pad_token_id": 0,
17
+ "tie_weights": true,
18
+ "transformers_version": "4.57.6",
19
+ "vocab_size": 148
20
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f898a29640d37703dfc7c4555d8e8c54001efdde85c4847fc07e2259a2314d4
3
+ size 3821360
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,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
24
+ class ChessTokenizer(PreTrainedTokenizer):
25
+ """
26
+ A custom tokenizer for chess moves using extended UCI notation.
27
+
28
+ This tokenizer maps each possible chess move to a unique token ID.
29
+ The vocabulary is built from the training dataset to ensure all moves
30
+ encountered during training have a corresponding token.
31
+
32
+ Example:
33
+ >>> tokenizer = ChessTokenizer()
34
+ >>> tokenizer.encode("WPe2e4 BPe7e5")
35
+ [1, 42, 87, 2] # [BOS, e2e4, e7e5, EOS]
36
+ """
37
+
38
+ model_input_names = ["input_ids", "attention_mask"]
39
+ vocab_files_names = {"vocab_file": "vocab.json"}
40
+
41
+ # Special tokens
42
+ PAD_TOKEN = "[PAD]"
43
+ BOS_TOKEN = "[BOS]"
44
+ EOS_TOKEN = "[EOS]"
45
+ UNK_TOKEN = "[UNK]"
46
+
47
+ def __init__(
48
+ self,
49
+ vocab_file: Optional[str] = None,
50
+ vocab: Optional[Dict[str, int]] = None,
51
+ **kwargs,
52
+ ):
53
+ """
54
+ Initialize the chess tokenizer.
55
+
56
+ Args:
57
+ vocab_file: Path to a JSON file containing the vocabulary mapping.
58
+ vocab: Dictionary mapping tokens to IDs (alternative to vocab_file).
59
+ **kwargs: Additional arguments passed to PreTrainedTokenizer.
60
+ """
61
+ # Initialize special tokens
62
+ self._pad_token = self.PAD_TOKEN
63
+ self._bos_token = self.BOS_TOKEN
64
+ self._eos_token = self.EOS_TOKEN
65
+ self._unk_token = self.UNK_TOKEN
66
+
67
+ # Remove any duplicate special-token entries passed through kwargs
68
+ # to avoid "multiple values for keyword" errors when loading from disk.
69
+ kwargs.pop("pad_token", None)
70
+ kwargs.pop("bos_token", None)
71
+ kwargs.pop("eos_token", None)
72
+ kwargs.pop("unk_token", None)
73
+
74
+ # Load or create vocabulary
75
+ if vocab is not None:
76
+ self._vocab = vocab
77
+ elif vocab_file is not None and os.path.exists(vocab_file):
78
+ with open(vocab_file, "r", encoding="utf-8") as f:
79
+ self._vocab = json.load(f)
80
+ else:
81
+ # Create a minimal vocabulary with just special tokens
82
+ # The full vocabulary should be built from the dataset
83
+ self._vocab = self._create_default_vocab()
84
+
85
+ # Create reverse mapping
86
+ self._ids_to_tokens = {v: k for k, v in self._vocab.items()}
87
+
88
+ # Call parent init AFTER setting up vocab
89
+ super().__init__(
90
+ pad_token=self._pad_token,
91
+ bos_token=self._bos_token,
92
+ eos_token=self._eos_token,
93
+ unk_token=self._unk_token,
94
+ **kwargs,
95
+ )
96
+
97
+ def _create_default_vocab(self) -> Dict[str, int]:
98
+ """
99
+ Create a minimal default vocabulary with just special tokens.
100
+
101
+ For the full vocabulary, use `build_vocab_from_dataset()`.
102
+ This minimal vocab is just a placeholder - you should build from data.
103
+ """
104
+ special_tokens = [self.PAD_TOKEN, self.BOS_TOKEN, self.EOS_TOKEN, self.UNK_TOKEN]
105
+ vocab = {token: idx for idx, token in enumerate(special_tokens)}
106
+ return vocab
107
+
108
+ @classmethod
109
+ def build_vocab_from_iterator(
110
+ cls,
111
+ iterator,
112
+ min_frequency: int = 1,
113
+ ) -> "ChessTokenizer":
114
+ """
115
+ Build a tokenizer vocabulary from an iterator of game strings.
116
+
117
+ Args:
118
+ iterator: An iterator yielding game strings (space-separated moves).
119
+ min_frequency: Minimum frequency for a token to be included.
120
+
121
+ Returns:
122
+ A ChessTokenizer with the built vocabulary.
123
+ """
124
+ from collections import Counter
125
+
126
+ token_counts = Counter()
127
+
128
+ for game in iterator:
129
+ moves = game.strip().split()
130
+ token_counts.update(moves)
131
+
132
+ # Filter by frequency
133
+ tokens = [token for token, count in token_counts.items() if count >= min_frequency]
134
+
135
+ # Sort for reproducibility
136
+ tokens = sorted(tokens)
137
+
138
+ # Build vocabulary
139
+ special_tokens = [cls.PAD_TOKEN, cls.BOS_TOKEN, cls.EOS_TOKEN, cls.UNK_TOKEN]
140
+ vocab = {token: idx for idx, token in enumerate(special_tokens + tokens)}
141
+
142
+ return cls(vocab=vocab)
143
+
144
+ @classmethod
145
+ def build_vocab_from_dataset(
146
+ cls,
147
+ dataset_name: str = "dlouapre/lichess_2025-01_1M",
148
+ split: str = "train",
149
+ column: str = "text",
150
+ min_frequency: int = 500,
151
+ max_samples: Optional[int] = 100000,
152
+ ) -> "ChessTokenizer":
153
+ """
154
+ Build a tokenizer vocabulary from a Hugging Face dataset.
155
+
156
+ Args:
157
+ dataset_name: Name of the dataset on Hugging Face Hub.
158
+ split: Dataset split to use.
159
+ column: Column containing the game strings.
160
+ min_frequency: Minimum frequency for a token to be included (default: 500).
161
+ max_samples: Maximum number of samples to process (default: 100k).
162
+
163
+ Returns:
164
+ A ChessTokenizer with the built vocabulary.
165
+ """
166
+ from datasets import load_dataset
167
+
168
+ dataset = load_dataset(dataset_name, split=split)
169
+
170
+ if max_samples is not None:
171
+ dataset = dataset.select(range(min(max_samples, len(dataset))))
172
+
173
+ def game_iterator():
174
+ for example in dataset:
175
+ yield example[column]
176
+
177
+ return cls.build_vocab_from_iterator(game_iterator(), min_frequency=min_frequency)
178
+
179
+ @property
180
+ def vocab_size(self) -> int:
181
+ """Return the size of the vocabulary."""
182
+ return len(self._vocab)
183
+
184
+ def get_vocab(self) -> Dict[str, int]:
185
+ """Return the vocabulary as a dictionary."""
186
+ return dict(self._vocab)
187
+
188
+ def _tokenize(self, text: str) -> List[str]:
189
+ """
190
+ Tokenize a string of moves into a list of tokens.
191
+
192
+ Args:
193
+ text: A string of space-separated moves.
194
+
195
+ Returns:
196
+ List of move tokens.
197
+ """
198
+ return text.strip().split()
199
+
200
+ def _convert_token_to_id(self, token: str) -> int:
201
+ """Convert a token to its ID."""
202
+ return self._vocab.get(token, self._vocab.get(self.UNK_TOKEN, 0))
203
+
204
+ def _convert_id_to_token(self, index: int) -> str:
205
+ """Convert an ID to its token."""
206
+ return self._ids_to_tokens.get(index, self.UNK_TOKEN)
207
+
208
+ def convert_tokens_to_string(self, tokens: List[str]) -> str:
209
+ """Convert a list of tokens back to a string."""
210
+ # Filter out special tokens for cleaner output
211
+ special = {self.PAD_TOKEN, self.BOS_TOKEN, self.EOS_TOKEN, self.UNK_TOKEN}
212
+ return " ".join(t for t in tokens if t not in special)
213
+
214
+ def save_vocabulary(
215
+ self,
216
+ save_directory: str,
217
+ filename_prefix: Optional[str] = None,
218
+ ) -> tuple:
219
+ """
220
+ Save the vocabulary to a JSON file.
221
+
222
+ Args:
223
+ save_directory: Directory to save the vocabulary.
224
+ filename_prefix: Optional prefix for the filename.
225
+
226
+ Returns:
227
+ Tuple containing the path to the saved vocabulary file.
228
+ """
229
+ if not os.path.isdir(save_directory):
230
+ os.makedirs(save_directory, exist_ok=True)
231
+
232
+ vocab_file = os.path.join(
233
+ save_directory,
234
+ (filename_prefix + "-" if filename_prefix else "") + "vocab.json",
235
+ )
236
+
237
+ with open(vocab_file, "w", encoding="utf-8") as f:
238
+ json.dump(self._vocab, f, ensure_ascii=False, indent=2)
239
+
240
+ return (vocab_file,)
241
+
242
+
243
+ class DecomposedChessTokenizer(PreTrainedTokenizer):
244
+ """
245
+ Tokenizer that decomposes moves into: [Piece] [FromSquare] [ToSquare] [Promotion?]
246
+ """
247
+
248
+ # Special tokens
249
+ PAD_TOKEN = "[PAD]"
250
+ BOS_TOKEN = "[BOS]"
251
+ EOS_TOKEN = "[EOS]"
252
+ UNK_TOKEN = "[UNK]"
253
+
254
+ def __init__(self, **kwargs):
255
+ self._pad_token = self.PAD_TOKEN
256
+ self._bos_token = self.BOS_TOKEN
257
+ self._eos_token = self.EOS_TOKEN
258
+ self._unk_token = self.UNK_TOKEN
259
+
260
+ kwargs.pop("pad_token", None)
261
+ kwargs.pop("bos_token", None)
262
+ kwargs.pop("eos_token", None)
263
+ kwargs.pop("unk_token", None)
264
+
265
+ # Build vocabulary
266
+ self._vocab = self._build_decomposed_vocab()
267
+ self._ids_to_tokens = {v: k for k, v in self._vocab.items()}
268
+
269
+ super().__init__(
270
+ pad_token=self._pad_token,
271
+ bos_token=self._bos_token,
272
+ eos_token=self._eos_token,
273
+ unk_token=self._unk_token,
274
+ **kwargs,
275
+ )
276
+
277
+ def _build_decomposed_vocab(self) -> Dict[str, int]:
278
+ vocab = {}
279
+ idx = 0
280
+
281
+ # Special tokens
282
+ for token in [self.PAD_TOKEN, self.BOS_TOKEN, self.EOS_TOKEN, self.UNK_TOKEN]:
283
+ vocab[token] = idx
284
+ idx += 1
285
+
286
+ # Piece tokens: WP, WN, WB, WR, WQ, WK, BP, BN, BB, BR, BQ, BK
287
+ for color in ["W", "B"]:
288
+ for piece in ["P", "N", "B", "R", "Q", "K"]:
289
+ vocab[f"{color}{piece}"] = idx
290
+ idx += 1
291
+
292
+ # Square tokens with suffixes
293
+ files = "abcdefgh"
294
+ ranks = "12345678"
295
+ for file in files:
296
+ for rank in ranks:
297
+ # From square suffix
298
+ vocab[f"{file}{rank}_f"] = idx
299
+ idx += 1
300
+ # To square suffix
301
+ vocab[f"{file}{rank}_t"] = idx
302
+ idx += 1
303
+
304
+ # Promotion tokens
305
+ for piece in ["Q", "R", "B", "N"]:
306
+ vocab[f"={piece}"] = idx
307
+ idx += 1
308
+
309
+ return vocab
310
+
311
+ def _tokenize(self, text: str) -> List[str]:
312
+ """
313
+ Tokenize moves in format: "WPe2e4 BNg8f6"
314
+ Output: ["WP", "e2_f", "e4_t", "BN", "g8_f", "f6_t"]
315
+ """
316
+ tokens = []
317
+ moves = text.strip().split()
318
+
319
+ for move in moves:
320
+ if move in [self.PAD_TOKEN, self.BOS_TOKEN, self.EOS_TOKEN, self.UNK_TOKEN]:
321
+ tokens.append(move)
322
+ continue
323
+
324
+ # Parse extended UCI format: [W|B][Piece][from][to][annotations]
325
+ if len(move) < 6:
326
+ tokens.append(self.UNK_TOKEN)
327
+ continue
328
+
329
+ color_piece = move[:2] # e.g., "WP"
330
+ from_sq = move[2:4] # e.g., "e2"
331
+ to_sq = move[4:6] # e.g., "e4"
332
+
333
+ tokens.append(color_piece)
334
+ tokens.append(f"{from_sq}_f")
335
+ tokens.append(f"{to_sq}_t")
336
+
337
+ # Check for promotion
338
+ if "=" in move:
339
+ promo_idx = move.index("=")
340
+ if promo_idx + 1 < len(move):
341
+ promo_piece = move[promo_idx + 1]
342
+ if promo_piece in "QRBN":
343
+ tokens.append(f"={promo_piece}")
344
+
345
+ return tokens
346
+
347
+ def convert_tokens_to_string(self, tokens: List[str]) -> str:
348
+ """Convert decomposed tokens back to move string for display."""
349
+ result = []
350
+ i = 0
351
+ while i < len(tokens):
352
+ token = tokens[i]
353
+
354
+ # Skip special tokens
355
+ if token in [self.PAD_TOKEN, self.BOS_TOKEN, self.EOS_TOKEN, self.UNK_TOKEN]:
356
+ i += 1
357
+ continue
358
+
359
+ # Check if this starts a move (piece token)
360
+ if len(token) == 2 and token[0] in "WB" and token[1] in "PNBRQK":
361
+ move_parts = [token]
362
+ # Expect from_sq, to_sq, optional promotion
363
+ for j in range(1, 4):
364
+ if i + j < len(tokens):
365
+ next_token = tokens[i + j]
366
+ if next_token.endswith("_f") or next_token.endswith("_t"):
367
+ move_parts.append(next_token.replace("_f", "").replace("_t", ""))
368
+ elif next_token.startswith("="):
369
+ move_parts.append(next_token)
370
+ else:
371
+ break
372
+ else:
373
+ break
374
+
375
+ # Format: WP + e2 + e4 -> WPe2e4
376
+ if len(move_parts) >= 3:
377
+ result.append("".join(move_parts))
378
+ i += len(move_parts)
379
+ else:
380
+ i += 1
381
+ else:
382
+ i += 1
383
+
384
+ return " ".join(result)
385
+
386
+ @property
387
+ def vocab_size(self) -> int:
388
+ return len(self._vocab)
389
+
390
+ def get_vocab(self) -> Dict[str, int]:
391
+ return dict(self._vocab)
392
+
393
+ def _convert_token_to_id(self, token: str) -> int:
394
+ return self._vocab.get(token, self._vocab.get(self.UNK_TOKEN, 0))
395
+
396
+ def _convert_id_to_token(self, index: int) -> str:
397
+ return self._ids_to_tokens.get(index, self.UNK_TOKEN)
398
+
399
+ def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = None) -> tuple:
400
+ if not os.path.isdir(save_directory):
401
+ os.makedirs(save_directory, exist_ok=True)
402
+
403
+ vocab_file = os.path.join(
404
+ save_directory,
405
+ (filename_prefix + "-" if filename_prefix else "") + "vocab.json",
406
+ )
407
+
408
+ with open(vocab_file, "w", encoding="utf-8") as f:
409
+ json.dump(self._vocab, f, ensure_ascii=False, indent=2)
410
+
411
+ return (vocab_file,)
412
+
413
+
414
+ def count_vocab_from_dataset(
415
+ dataset_name: str = "dlouapre/lichess_2025-01_1M",
416
+ split: str = "train",
417
+ column: str = "text",
418
+ max_samples: Optional[int] = 10000,
419
+ ) -> Dict[str, int]:
420
+ """
421
+ Count token frequencies in a dataset (useful for vocabulary analysis).
422
+
423
+ Args:
424
+ dataset_name: Name of the dataset on Hugging Face Hub.
425
+ split: Dataset split to use.
426
+ column: Column containing the game strings.
427
+ max_samples: Maximum number of samples to process.
428
+
429
+ Returns:
430
+ Dictionary mapping tokens to their frequencies.
431
+ """
432
+ from collections import Counter
433
+ from datasets import load_dataset
434
+
435
+ dataset = load_dataset(dataset_name, split=split)
436
+
437
+ if max_samples is not None:
438
+ dataset = dataset.select(range(min(max_samples, len(dataset))))
439
+
440
+ token_counts = Counter()
441
+
442
+ for example in dataset:
443
+ moves = example[column].strip().split()
444
+ token_counts.update(moves)
445
+
446
+ return dict(token_counts)
tokenizer_config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "eos_token": "[EOS]",
45
+ "extra_special_tokens": {},
46
+ "model_max_length": 1000000000000000019884624838656,
47
+ "pad_token": "[PAD]",
48
+ "tokenizer_class": "ChessTokenizer",
49
+ "unk_token": "[UNK]"
50
+ }
vocab.json ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "[PAD]": 0,
3
+ "[BOS]": 1,
4
+ "[EOS]": 2,
5
+ "[UNK]": 3,
6
+ "WP": 4,
7
+ "WN": 5,
8
+ "WB": 6,
9
+ "WR": 7,
10
+ "WQ": 8,
11
+ "WK": 9,
12
+ "BP": 10,
13
+ "BN": 11,
14
+ "BB": 12,
15
+ "BR": 13,
16
+ "BQ": 14,
17
+ "BK": 15,
18
+ "a1_f": 16,
19
+ "a1_t": 17,
20
+ "a2_f": 18,
21
+ "a2_t": 19,
22
+ "a3_f": 20,
23
+ "a3_t": 21,
24
+ "a4_f": 22,
25
+ "a4_t": 23,
26
+ "a5_f": 24,
27
+ "a5_t": 25,
28
+ "a6_f": 26,
29
+ "a6_t": 27,
30
+ "a7_f": 28,
31
+ "a7_t": 29,
32
+ "a8_f": 30,
33
+ "a8_t": 31,
34
+ "b1_f": 32,
35
+ "b1_t": 33,
36
+ "b2_f": 34,
37
+ "b2_t": 35,
38
+ "b3_f": 36,
39
+ "b3_t": 37,
40
+ "b4_f": 38,
41
+ "b4_t": 39,
42
+ "b5_f": 40,
43
+ "b5_t": 41,
44
+ "b6_f": 42,
45
+ "b6_t": 43,
46
+ "b7_f": 44,
47
+ "b7_t": 45,
48
+ "b8_f": 46,
49
+ "b8_t": 47,
50
+ "c1_f": 48,
51
+ "c1_t": 49,
52
+ "c2_f": 50,
53
+ "c2_t": 51,
54
+ "c3_f": 52,
55
+ "c3_t": 53,
56
+ "c4_f": 54,
57
+ "c4_t": 55,
58
+ "c5_f": 56,
59
+ "c5_t": 57,
60
+ "c6_f": 58,
61
+ "c6_t": 59,
62
+ "c7_f": 60,
63
+ "c7_t": 61,
64
+ "c8_f": 62,
65
+ "c8_t": 63,
66
+ "d1_f": 64,
67
+ "d1_t": 65,
68
+ "d2_f": 66,
69
+ "d2_t": 67,
70
+ "d3_f": 68,
71
+ "d3_t": 69,
72
+ "d4_f": 70,
73
+ "d4_t": 71,
74
+ "d5_f": 72,
75
+ "d5_t": 73,
76
+ "d6_f": 74,
77
+ "d6_t": 75,
78
+ "d7_f": 76,
79
+ "d7_t": 77,
80
+ "d8_f": 78,
81
+ "d8_t": 79,
82
+ "e1_f": 80,
83
+ "e1_t": 81,
84
+ "e2_f": 82,
85
+ "e2_t": 83,
86
+ "e3_f": 84,
87
+ "e3_t": 85,
88
+ "e4_f": 86,
89
+ "e4_t": 87,
90
+ "e5_f": 88,
91
+ "e5_t": 89,
92
+ "e6_f": 90,
93
+ "e6_t": 91,
94
+ "e7_f": 92,
95
+ "e7_t": 93,
96
+ "e8_f": 94,
97
+ "e8_t": 95,
98
+ "f1_f": 96,
99
+ "f1_t": 97,
100
+ "f2_f": 98,
101
+ "f2_t": 99,
102
+ "f3_f": 100,
103
+ "f3_t": 101,
104
+ "f4_f": 102,
105
+ "f4_t": 103,
106
+ "f5_f": 104,
107
+ "f5_t": 105,
108
+ "f6_f": 106,
109
+ "f6_t": 107,
110
+ "f7_f": 108,
111
+ "f7_t": 109,
112
+ "f8_f": 110,
113
+ "f8_t": 111,
114
+ "g1_f": 112,
115
+ "g1_t": 113,
116
+ "g2_f": 114,
117
+ "g2_t": 115,
118
+ "g3_f": 116,
119
+ "g3_t": 117,
120
+ "g4_f": 118,
121
+ "g4_t": 119,
122
+ "g5_f": 120,
123
+ "g5_t": 121,
124
+ "g6_f": 122,
125
+ "g6_t": 123,
126
+ "g7_f": 124,
127
+ "g7_t": 125,
128
+ "g8_f": 126,
129
+ "g8_t": 127,
130
+ "h1_f": 128,
131
+ "h1_t": 129,
132
+ "h2_f": 130,
133
+ "h2_t": 131,
134
+ "h3_f": 132,
135
+ "h3_t": 133,
136
+ "h4_f": 134,
137
+ "h4_t": 135,
138
+ "h5_f": 136,
139
+ "h5_t": 137,
140
+ "h6_f": 138,
141
+ "h6_t": 139,
142
+ "h7_f": 140,
143
+ "h7_t": 141,
144
+ "h8_f": 142,
145
+ "h8_t": 143,
146
+ "=Q": 144,
147
+ "=R": 145,
148
+ "=B": 146,
149
+ "=N": 147
150
+ }