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 (default: Qwen/Qwen3.5-0.8B) on 2-player Heads-Up and 3-player Spin & Go No-Limit Texas Hold'em on a single consumer or Colab GPU.

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 --mc-samples 64 --workers 4
llm-holdem-34j generate --output data/train_grpo.jsonl --num-decisions 1500 --seed 100 --mc-samples 64 --min-ev-spread 0.5 --workers 4
llm-holdem-34j generate --output data/test.jsonl --num-decisions 500 --seed 999 --mc-samples 64 --workers 4

# 2. Stage 1: LoRA SFT (default: Qwen/Qwen3.5-0.8B, all-linear LoRA)
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 monotonic EV-advantage poker rewards
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

Benchmark Results (Google Colab Tesla T4 15 GB, Qwen/Qwen3.5-0.8B)

Trained Qwen/Qwen3.5-0.8B (FP16, all-linear LoRA r=16, alpha=32) on 4k high-precision (mc_samples=64) SFT decisions (120 steps, 6m 21s) + 40 GRPO steps on high-EV-spread (min_ev_spread=0.5) spots (1m 21s):

Model Exact Acc Illegal Rate EV Regret (BB) Live vs calling_station (100 hands, seed 7)
Zero-shot Qwen/Qwen3.5-0.8B 0.0% 100.0% 11.449 —
Stage 1 SFT (runs/sft) 74.3% 0.0% 0.614 -18.0 ± 32.9 BB/100 (0.00% illegal)
Stage 2 GRPO (runs/grpo) 73.7% 0.0% 0.601 +27.0 ± 31.7 BB/100 (0.00% illegal)

Metadata

Release files for llm-holdem-34j 2.2.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.2.0
File Size Uploaded Provenance Actions
llm_holdem_34j-2.2.0.tar.gz 38.6 kB With provenance Details for llm_holdem_34j-2.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 75.4 kB

Release files / llm_holdem_34j-2.2.0.tar.gz

Download URL llm_holdem_34j-2.2.0.tar.gz
Size 38.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f3e8b3041636a72ae2c39d5e1e38266807672e31b1ff34a17bf5e5f8b9dcec18
BLAKE2b-256 checksum
How to use checksums
ca47c2439e5c03b8854a1c392f9bff3d2f0df5a164514739d64e69f693995fdd
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.2.0-py3-none-any.whl

Download URL llm_holdem_34j-2.2.0-py3-none-any.whl
Size 36.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dec2c9018c2229eb08fe28eeb754aa254856f929d83e506ab9b1f43fb6bd6a17
BLAKE2b-256 checksum
How to use checksums
66f8089874cac33d60ee3887231862acc48ba9e8a9e286736bdab42c141d38ea
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.2.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.2.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