Update README.md
Browse files
README.md
CHANGED
|
@@ -15,3 +15,77 @@ configs:
|
|
| 15 |
- split: train
|
| 16 |
path: data/train-*
|
| 17 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
- split: train
|
| 16 |
path: data/train-*
|
| 17 |
---
|
| 18 |
+
|
| 19 |
+
This dataset was created using the [lichess elite database](https://database.nikonoel.fr/).
|
| 20 |
+
The it includes the all games up to December 2024.
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
After downloading the zip files, the dataset was processed using the following fish script.
|
| 25 |
+
The goal was to create three UCI-encoded datasets from the lichess elite datset, where all games are deduplicated across all three datasets:
|
| 26 |
+
1. has_promote: includes non-checkmate games that include pawn promotions
|
| 27 |
+
1. no_promote: includes non-checkmate games without pawn promotions
|
| 28 |
+
1. checkmates: includes games that end in checkmate
|
| 29 |
+
```sh
|
| 30 |
+
#!/usr/bin/env fish
|
| 31 |
+
|
| 32 |
+
# Deduplicate all Lichess elite database files
|
| 33 |
+
pgn-extract --notags --nocomments --nonags --novars -w10000 --noduplicates -o all_deduplicated.san -f lichess_file_list.txt 2>dedupe_output.txt
|
| 34 |
+
|
| 35 |
+
echo "Deduplication complete. Output saved to all_deduplicated.san."
|
| 36 |
+
|
| 37 |
+
# Partition games into checkmates and non-checkmates
|
| 38 |
+
pgn-extract --notags --nocomments --nonags --novars -w100000 --checkmate -o checkmates.san -n others.san all_deduplicated.san 2>/dev/null
|
| 39 |
+
|
| 40 |
+
echo "Games partitioned: checkmates.san and others.san created."
|
| 41 |
+
|
| 42 |
+
# Further partition non-checkmate games based on pawn promotions
|
| 43 |
+
grep -B1 "=" others.san > has_promote.san
|
| 44 |
+
grep -B1 -v "=" others.san > no_promote.san
|
| 45 |
+
|
| 46 |
+
echo "Non-checkmate games split into has_promote.san and no_promote.san."
|
| 47 |
+
|
| 48 |
+
# Convert each SAN file to UCI format
|
| 49 |
+
pgn-extract -Wlalg --noresults --nochecks --nomovenumbers --notags --nocomments --nonags --novars -w100000 -o has_promote.uci has_promote.san 2>/dev/null
|
| 50 |
+
pgn-extract -Wlalg --noresults --nochecks --nomovenumbers --notags --nocomments --nonags --novars -w100000 -o no_promote.uci no_promote.san 2>/dev/null
|
| 51 |
+
pgn-extract -Wlalg --noresults --nochecks --nomovenumbers --notags --nocomments --nonags --novars -w100000 -o checkmates.uci checkmates.san 2>/dev/null
|
| 52 |
+
|
| 53 |
+
echo "SAN files converted to UCI format."
|
| 54 |
+
|
| 55 |
+
# Add "#" to the end of each move sequence in checkmates.uc
|
| 56 |
+
sed -i '/./s/$/#/' checkmates.uci
|
| 57 |
+
|
| 58 |
+
echo "Checkmate sequences updated with '#' as EOS token."
|
| 59 |
+
|
| 60 |
+
# Remove all blank lines
|
| 61 |
+
sed -i '/^$/d' has_promote.uci
|
| 62 |
+
sed -i '/^$/d' no_promote.uci
|
| 63 |
+
sed -i '/^$/d' checkmates.uci
|
| 64 |
+
|
| 65 |
+
echo "Blank lines removed. Finished."
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
Once the raw files were processed, the UCI-encoded files contained the following number of games:
|
| 69 |
+
|
| 70 |
+
- checkmates.uci: 3,708,644 games that end in checkmate
|
| 71 |
+
- no_promote.uci: 23,201,987 games that do not end in checkmate and have no pawn promotions
|
| 72 |
+
- has_promote.uci: 361,652 games that do not end in checkmate and have at least one pawn promotion
|
| 73 |
+
|
| 74 |
+
I wanted to balance the number of games from each category with a bias toward games that end in checkmate (so the LLM learns to finish the game rather than simply carry-on playing without a goal).
|
| 75 |
+
To accomplish this, I selected all games from `checkmates.uci` and `has_promote.uci`, and selected games from the `no_promote.uci` at a 5:1 ratio to the number of games in `has_promote.uci`, i.e., 1,808,260 games.
|
| 76 |
+
A simple python script for this is:
|
| 77 |
+
|
| 78 |
+
```python
|
| 79 |
+
from datasets import load_dataset, concatenate_datasets
|
| 80 |
+
|
| 81 |
+
checkmates = load_dataset("text", data_files="lichess-elite/checkmates.uci")["train"]
|
| 82 |
+
no_promote = load_dataset("text", data_files="lichess-elite/no_promote.uci")["train"]
|
| 83 |
+
has_promote = load_dataset("text", data_files="lichess-elite/has_promote.uci")["train"]
|
| 84 |
+
|
| 85 |
+
# shuffle to ensure we're selecting across the entire dataset
|
| 86 |
+
no_promote_subset = no_promote.shuffle(seed=42).select(range(5 * len(has_promote)))
|
| 87 |
+
|
| 88 |
+
# shuffle entire dataset
|
| 89 |
+
ds = concatenate_datasets([checkmates, has_promote, no_promote_subset]).shuffle(seed=42)
|
| 90 |
+
```
|
| 91 |
+
|