praisonai-train PyPI package (import: praisonai_train) is Tier 2c — it sits on top of praisonaiagents and gives you the train CLI group and a standalone praisonai-train console script.
Quick Start
1
Agent Training
Improve an agent iteratively — no ML dependencies required.
2
LLM Fine-tuning
Add the
[llm] extra to pull the modern Unsloth/torch stack (unsloth>=2025.9.1, trl>=0.18.2, transformers>=4.51.3, torch>=2.6.0). The trainer uses each model’s own chat template, so chat_template is optional.- Llama
- Gemma
- Qwen
The base install now uses the modern TRL API (
SFTConfig + SFTTrainer) and pulls the current Unsloth / TRL / torch 2.6+ stack. On old pins, upgrade with pip install -U "praisonai-train[llm]".3
Serve a trained model
Serve a fine-tuned GGUF over an OpenAI-compatible endpoint — Gemma-4 auto-fetches its MTP drafter for lossless fast inference.See Serve & MTP Fast-Inference for the full walkthrough.
Beginner-safe defaults
A minimal fine-tuning config trains locally and pushes nowhere unless you opt in.- A minimal config trains locally — publishing to Hugging Face or Ollama is opt-in (set the flag and its target).
assistant_only_loss: autonever crashes on a stock Gemma / Qwen / Llama template — it falls back to full-sequence SFT.- Unknown / misnamed keys warn instead of crashing — a typo logs
WARNING: ignoring unknown config key '...'and training continues.
When to Use praisonai-train vs praisonai train
Install the standalone package when you only need training; use the wrapper’s praisonai train when you already run the full stack.
Both entry points expose the same commands: every praisonai train <sub> also runs as praisonai-train <sub>.
CLI Subcommands
Nine subcommands cover dataset tooling, benchmarking, fine-tuning, serving, export, and agent training.
See Train CLI for full flags.
Supported models
praisonai-train llm fine-tunes any Unsloth-supported model. The trainer uses each model’s own chat template, so chat_template is optional — set it only to override.
PraisonAI PR #3274 validated
unsloth/Qwen2.5-0.5B-Instruct-bnb-4bit and unsloth/gemma-2-2b-it-bnb-4bit end-to-end. See Train → Model & template keys for the full chat_template reference.Common Patterns
Fine-tune a non-Llama base (Gemma / Qwen)
Point--model at any Gemma or Qwen base — the trainer uses each model’s own chat template automatically.
The trainer previously force-applied the Llama-3.1 template to every model, corrupting Gemma / Qwen runs. Fixed as of PraisonAI PR #3274 — set
chat_template in config.yaml only when a base model has no built-in template.Fine-tune on 2 GPUs with checkpointing
Launch undertorchrun and add a handful of checkpoint keys — an interrupted run resumes from the latest. See Multi-GPU.
Train, review, apply
Run a training session, inspect the iterations, then bake the best one into your agent.Apply in Python
Apply a session’s suggestions to an agent directly.Train on any console
The same commands run identically on macOS, Linux, and Windows — no encoding configuration needed.Force all iterations
Benchmarks, regression tests, and demos that need to observe the feedback loop across every iteration should pass--no-early-stop (CLI) or no_early_stop=True (Python) so the 9.5 threshold is bypassed.
--iterations behaves as a maximum in LLM-as-Judge mode — training stops as soon as any iteration scores ≥ 9.5.
Exporting an already-trained model
Publish alora_model/ you trained earlier — no dataset, no re-training.
1
Push to Hugging Face
2
Export a GGUF
Writes a local
.gguf; add --hf to also push it to the Hub.3
Push to Ollama
Export doesn't need a dataset
Export doesn't need a dataset
for_export() skips the training-only validation, so an export-only run needs no dataset: — and no config file at all.Chat template is inferred
Chat template is inferred
The base model (for chat-template selection) is read from
<model-dir>/config.json:_name_or_path, falling back to the directory name. Override it with --base-model.Quantization is validated up front
Quantization is validated up front
--quant accepts the same values as the LLM training path (q4_k_m, q5_k_m, q8_0, q4_0, q4_1, q5_0, q5_1, q3_k_m, q6_k, f16, bf16, q2_k). A typo fails fast, listing every valid choice.Ollama needs a namespaced model + registered key
Ollama needs a namespaced model + registered key
The model must be namespaced
<username>/<name>, and your public key must be registered at https://ollama.com/settings/keys. An unauthorized push tells you exactly where to click and prints your local ~/.ollama/id_ed25519.pub.Python API
Export-only, straight from a config dict — no dataset required.for_export() accepts either model_name or its alias model (matching the --model CLI flag), and validates quantization_method up front — a typo like q4km raises ValueError with the full valid-methods list.praisonai train export for every flag and exit code.
Windows & non-UTF-8 Consoles
praisonai-train agents renders its summary table with emoji (✅ PASSED, ❌ NEEDS WORK, ★ best-iteration marker) when stdout supports UTF-8, and automatically falls back to ASCII (PASSED, NEEDS WORK, *) when it doesn’t. It detects the console’s encoding at runtime.
The ASCII summary is the correct output on a cp1252 Windows console — not a truncation. The session is saved either way;
praisonai-train show <session-id> re-renders it in whichever encoding your current console supports.Exit Codes
praisonai-train agents reports three distinct outcomes.
Best Practices
Install the base package for agent training
Install the base package for agent training
pip install praisonai-train pulls praisonaiagents plus litellm (needed for LLM-as-Judge grading) — enough for agents, list, show, and apply. Add [llm] only when you need Unsloth fine-tuning.Use the standalone script when you don't want the wrapper
Use the standalone script when you don't want the wrapper
The
praisonai-train console script exposes the full train group without installing praisonai. Ideal for lightweight training-only environments.Old imports keep working
Old imports keep working
Existing
praisonai.train.*, praisonai.train_vision, and praisonai.upload_vision imports still resolve to the same module objects in praisonai_train. Nothing to migrate.Let the tokenizer's native template win
Let the tokenizer's native template win
For LLM fine-tuning, only set
chat_template for models without one, or to force a specific one. Forcing llama-3.1 on Gemma/Qwen was the old default and silently corrupted training — the trainer now uses each model’s own template by default. See Train → Chat Template.Update to the modern Unsloth stack
Update to the modern Unsloth stack
The
[llm] extra now requires unsloth>=2025.9.1, trl>=0.18.2, transformers>=4.51.3, and torch>=2.6.0. If you had pinned trl<0.9.0, upgrade — the pre-0.9 TRL API is no longer supported.Backward-compatible: if you already have the wrapper installed,
praisonai.train.* imports and the setup-conda-env entry point continue to work unchanged.Related
Train
Training overview and fine-tuning setup.
Train CLI
Full flag reference for the nine subcommands.
Serve & MTP Fast-Inference
Serve a GGUF over OpenAI HTTP with lossless MTP speculative decoding.
Ollama
Publish and run fine-tuned models locally with Ollama.
Dataset Tooling
Generate and quality-check instruction datasets.
Speed Benchmark
Rank deployments by generation speed before you fine-tune.
Multi-GPU Training
Fine-tune across multiple GPUs with torchrun.
Checkpointing
Save, resume, and keep the best checkpoint.
Installation Extras
The train install matrix.
Package Tiers
How the six packages stack.
Windows Terminal Encoding
Fix Rich crashes and ASCII rendering on legacy Windows consoles.

