Skip to main content

LLM Hold 'em 34j

CI Status Documentation Status

Test coverage percentage uv Ruff prek

PyPI Version Supported Python versions License


Documentation: https://llm-holdem-34j.readthedocs.io

Source Code: https://github.com/34j/llm-holdem-34j


Let LLMs play Texas hold 'em — a lightweight, SpinGPT-inspired toolkit for training small open-weight LLMs (e.g., Qwen/Qwen3-0.6B) on 2-player Heads-Up and 3-player Spin & Go No-Limit Texas Hold'em on a single consumer GPU (12 GB VRAM).

Highlights

  • Exact Poker Engine: Built on PokerKit (NoLimitTexasHoldem) with exact hand evaluation, side pots, 2-to-6 player tables, and SpinGPT-style compact text prompts (pos:H=BTN stacks:... hand:TsQs | pre:... | flop:... H: -> f/x/c/a/b{amt}/r{amt}).
  • Two-Stage Modern Training Stack: Powered by Hugging Face TRL (SFTTrainer + GRPOTrainer), PEFT (LoRA), and Liger-Kernel fused Triton kernels.
    1. Stage 1 (SFT): Completion-only LoRA fine-tuning on decisions generated by EquityGTOBot (position/stack-depth preflop ranges + PokerKit Monte-Carlo equity & EV estimation).
    2. Stage 2 (GRPO): Online Group Relative Policy Optimization with verifiable poker rewards (strict legality, continuous EV regret, and bet-sizing calibration).
  • SpinGPT Metrics & Live Evaluation: Exact accuracy, tolerant accuracy (±0.5 BB), macro F1, MAE, MAPE, illegal-move rate, EV regret, and live BB/100 ± 95% CI head-to-head / 3-handed matches.

Installation

Core package (PokerKit engine, bots, dataset generator, metrics, CLI):

pip install llm-holdem-34j

With GPU training & LLM inference dependencies (torch, transformers, trl, peft, liger-kernel, datasets, accelerate):

pip install "llm-holdem-34j[train]"

Quickstart

# 1. Generate SpinGPT-formatted datasets with per-action EV annotations
llm-holdem-34j generate --output data/train_sft.jsonl --num-decisions 10000 --seed 42
llm-holdem-34j generate --output data/train_grpo.jsonl --num-decisions 1500 --seed 100
llm-holdem-34j generate --output data/test.jsonl --num-decisions 500 --seed 999

# 2. Stage 1: LoRA SFT (~7 min on RTX 4070 SUPER with Qwen/Qwen3-0.6B + Liger-Kernel)
llm-holdem-34j train-sft --train-path data/train_sft.jsonl --eval-path data/test.jsonl --output-dir runs/sft

# 3. Stage 2: Online GRPO with verifiable poker rewards (~1.5 min for 80 steps)
llm-holdem-34j train-grpo --train-path data/train_grpo.jsonl --sft-adapter-dir runs/sft --output-dir runs/grpo --max-steps 80

# 4. Evaluate offline metrics and live PokerKit gameplay
llm-holdem-34j eval-offline runs/sft --test-path data/test.jsonl
llm-holdem-34j eval-play --hero runs/sft --opponents calling_station --num-hands 200

# 5. Play interactively in the terminal
llm-holdem-34j play --opponent runs/sft --hands 5

Benchmark Results (RTX 4070 SUPER 12 GB, < 10 min total)

Trained Qwen/Qwen3-0.6B (BF16, LoRA r=16, alpha=32, Liger-Kernel) on 10k SFT decisions (2 epochs, 6m 46s) + 80 GRPO steps (1m 15s):

Offline Metrics (500 held-out decisions)

Model Exact Acc Tolerant Acc (±0.5 BB) Macro F1 MAE (BB) MAPE Illegal Rate EV Regret (BB)
Zero-shot Qwen/Qwen3-0.6B 1.6% 1.6% 1.5% 0.00 0.0% 97.0% 10.763
Stage 1 SFT (runs/sft) 80.2% 80.8% 61.6% 0.06 2.8% 0.0% 0.471
Stage 2 GRPO (runs/grpo) 77.6% 78.4% 57.1% 0.09 3.9% 0.0% 0.501

Live PokerKit Gameplay (200 hands each, 0.00% illegal moves)

Matchup Format runs/sft (BB/100) runs/grpo (BB/100)
vs random 2p HU +122.6 ± 180.2 -7.4 ± 200.7
vs calling_station 2p HU +125.2 ± 97.4 +82.2 ± 76.6
vs lag 2p HU +56.6 ± 159.7 -37.2 ± 177.5
vs random + lag 3p Spin & Go +176.5 ± 239.3 +168.8 ± 233.2

Metadata

Release files for llm-holdem-34j 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-holdem-34j 2.0.0
File Size Uploaded Provenance Actions
llm_holdem_34j-2.0.0.tar.gz 28.0 kB With provenance Details for llm_holdem_34j-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llm-holdem-34j 2.0.0
File Interpreter ABI Platform Actions
llm_holdem_34j-2.0.0-py3-none-any.whl Python 3 none any Details for llm_holdem_34j-2.0.0-py3-none-any.whl

Total release size: 54.9 kB

Release files / llm_holdem_34j-2.0.0.tar.gz

Download URL llm_holdem_34j-2.0.0.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
15192ecb8dc409acf0ee3f404e5748ad34fc5b266aa49bb8f78fac39958d6836
BLAKE2b-256 checksum
How to use checksums
c5ec3643490b1de4e0ee70de1ae4b5575f400c1ad7c346bf930e272d68d4b42f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / llm_holdem_34j-2.0.0-py3-none-any.whl

Download URL llm_holdem_34j-2.0.0-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12e49ecfbd322bf7eee0d50dde01fadfc86c61a25b9835ee4172659742bcb12d
BLAKE2b-256 checksum
How to use checksums
8956a679fc73936334961878eda4432368ab44775569c37ba19acb62d66953c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for llm-holdem-34j 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for llm_holdem_34j-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page