Skip to main content

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:

  1. A clean PGN-to-position dataset pipeline.
  2. Deterministic train/test splitting at game level.
  3. Strong baseline models for honest comparison.
  4. A chess-native base Transformer trained on large public PGN data.
  5. A training JSONL schema with legal move masks and target move indexes.
  6. Per-player LoRA adapters trained from personal PGNs.
  7. Legal move masking through python-chess.
  8. 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

persona_chess-0.1.0.tar.gz (34.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

persona_chess-0.1.0-py3-none-any.whl (47.6 kB view details)

Uploaded Python 3

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

Hashes for persona_chess-0.1.0.tar.gz
Algorithm Hash digest
SHA256 626004d4b2752a0dcc71c49b514c79e396afa6109b9df08e4746169b416959c9
MD5 63d3e1ab687b267524fea3ffae6d2a7e
BLAKE2b-256 39dff6fdc4b99ca28a75c651aec0b401b0770c906a675978cf012f206fb21f23

See more details on using hashes here.

Provenance

The following attestation bundles were made for persona_chess-0.1.0.tar.gz:

Publisher: publish.yml on brutalstein/persona-chess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for persona_chess-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f43b5baf8a5562b689074c957780acfc9dbcde20483674c1993498bc07fd50c
MD5 3aca346c5a43b150ff7d0e06c8f086b1
BLAKE2b-256 6c66b6582673fa3e59b5c77cf98221c932636b3d03619b9973fa5be8679f14d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for persona_chess-0.1.0-py3-none-any.whl:

Publisher: publish.yml on brutalstein/persona-chess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page