Train lightweight chess personas from PGN files.
Project description
persona-chess
persona-chess is a Python library for training lightweight chess personas from PGN
files. The goal is not to find the strongest move. The goal is to predict how a
specific player is likely to move.
The current foundation includes PGN ingestion, player filtering, versioned move datasets, game-level train/test splits, profile reports, baseline persona models, JSON artifacts, and a CLI. The model layer is intentionally modular so a chess-native Transformer + LoRA backend can be added without changing the product surface.
Install
After the first PyPI release:
pip install persona-chess
pip install "persona-chess[ml]"
Until then, install directly from GitHub:
pip install git+https://github.com/brutalstein/persona-chess.git
pip install "persona-chess[ml] @ git+https://github.com/brutalstein/persona-chess.git"
For local development:
pip install -e ".[dev]"
Python API
from persona_chess import PersonaChess
persona = PersonaChess().fit_pgn("games.pgn", player="Target Player")
persona.save("target-player.persona.json")
prediction = persona.predict("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
print(prediction[0].san)
CLI
persona-chess profile games.pgn "Target Player"
persona-chess train games.pgn "Target Player" --model-type blend --out target-player.persona.json
persona-chess move target-player.persona.json --fen "startpos"
persona-chess export-training games.pgn "Target Player" --out target-player.train.jsonl
persona-chess split games.pgn "Target Player" --train-out train.jsonl --test-out test.jsonl
persona-chess benchmark games.pgn "Target Player" --model-type blend --out benchmark.json
persona-chess prepare-neural games.pgn "Target Player" --manifest-out adapter.manifest.json --move-vocab-out moves.vocab.json --position-vocab-out positions.vocab.json
persona-chess validate-neural adapter.manifest.json moves.vocab.json positions.vocab.json
persona-chess train-neural games.pgn "Target Player" --checkpoint-dir checkpoints/player --use-lora
persona-chess neural-move checkpoints/player --fen "startpos"
Built-in model backends:
blend: weighted baseline combining exact position memory, opening book, and phase priors.frequency: exact position memory with global legal fallback.opening_book: early-game repertoire memory.phase: game-phase move prior for opening, middlegame, and endgame positions.
Project Direction
The planned model path is:
- A clean PGN-to-position dataset pipeline.
- Deterministic train/test splitting at game level.
- Strong baseline models for honest comparison.
- A chess-native base Transformer trained on large public PGN data.
- A training JSONL schema with legal move masks and target move indexes.
- Per-player LoRA adapters trained from personal PGNs.
- Legal move masking through
python-chess. - Evaluation by move-match accuracy and style similarity metrics.
The neural command currently prepares versioned adapter manifests, move
vocabularies, and position vocabularies. The package also includes an optional
PyTorch Transformer policy skeleton behind the ml extra, with PEFT-powered LoRA,
legal-masked policy batches, checkpoint helpers, and checkpoint inference. It is not
enabled for standard installs.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file persona_chess-0.1.0.tar.gz.
File metadata
- Download URL: persona_chess-0.1.0.tar.gz
- Upload date:
- Size: 34.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
626004d4b2752a0dcc71c49b514c79e396afa6109b9df08e4746169b416959c9
|
|
| MD5 |
63d3e1ab687b267524fea3ffae6d2a7e
|
|
| BLAKE2b-256 |
39dff6fdc4b99ca28a75c651aec0b401b0770c906a675978cf012f206fb21f23
|
Provenance
The following attestation bundles were made for persona_chess-0.1.0.tar.gz:
Publisher:
publish.yml on brutalstein/persona-chess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
persona_chess-0.1.0.tar.gz -
Subject digest:
626004d4b2752a0dcc71c49b514c79e396afa6109b9df08e4746169b416959c9 - Sigstore transparency entry: 1681555524
- Sigstore integration time:
-
Permalink:
brutalstein/persona-chess@775d1996714219d3afb7a4407401c9fed056614a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/brutalstein
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@775d1996714219d3afb7a4407401c9fed056614a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file persona_chess-0.1.0-py3-none-any.whl.
File metadata
- Download URL: persona_chess-0.1.0-py3-none-any.whl
- Upload date:
- Size: 47.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f43b5baf8a5562b689074c957780acfc9dbcde20483674c1993498bc07fd50c
|
|
| MD5 |
3aca346c5a43b150ff7d0e06c8f086b1
|
|
| BLAKE2b-256 |
6c66b6582673fa3e59b5c77cf98221c932636b3d03619b9973fa5be8679f14d3
|
Provenance
The following attestation bundles were made for persona_chess-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on brutalstein/persona-chess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
persona_chess-0.1.0-py3-none-any.whl -
Subject digest:
0f43b5baf8a5562b689074c957780acfc9dbcde20483674c1993498bc07fd50c - Sigstore transparency entry: 1681556054
- Sigstore integration time:
-
Permalink:
brutalstein/persona-chess@775d1996714219d3afb7a4407401c9fed056614a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/brutalstein
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@775d1996714219d3afb7a4407401c9fed056614a -
Trigger Event:
workflow_dispatch
-
Statement type: