Skip to main content
Publish a model you already trained to Hugging Face, GGUF, or Ollama — no re-training, one command.

Quick Start

You already have a trained model in lora_model/. Pick a target and publish.
1

Publish to Hugging Face

Merge and push FP16 weights to a Hub repo.
2

Publish a GGUF build

Write a local .gguf — add --hf to also push it to the Hub.
3

Publish to Ollama

Create and push a quantized model to ollama.com.

When to use this

You already trained a model (e.g. lora_model/ exists) and don’t want to spend an hour re-running training just to publish it to a different target, fix a chat_template, or try a different quantization. export loads the trained weights once and publishes them.

How It Works

Export skips the training-only preflight, so it runs on CPU — there’s nothing to fine-tune. The base model name drives chat-template selection so the exported model isn’t garbled.

CLI flags

gguf always writes a local .gguf (so you can serve it). Add --hf me/my-model to additionally push it to the Hub. Without --hf, the GGUF is written under <model-dir>/gguf.

How the base model is inferred

The base model name selects the chat template, so the exported model formats prompts correctly. Resolution order:
  1. --base-model if passed.
  2. else model_name in --config.
  3. else _name_or_path from <model-dir>/config.json.
  4. else the model-dir name itself.

Prerequisites

HF_TOKEN env var or a cached huggingface-cli login. The token must have write scope and the repo must be under your own username.
CUDA is not required for export-only. CPU is fine because there is nothing to fine-tune.

Valid --quant values

Any of these quantization methods (from VALID_QUANTIZATION_METHODS):
A typo like q4km fails fast with the full list of valid choices — no long run wasted.

Failure modes → clean errors

Every known failure prints a single actionable message instead of a raw traceback.
The readiness probe honours OLLAMA_HOST and confirms GET /api/version — a healthy remote or non-default daemon is used instead of being ignored.

Python API

Script exports with the TrainModel.for_export() classmethod — it builds an export-only trainer (no dataset required) and validates the quantization up front.

Best Practices

Set --hf me/my-model (not a bare name). A namespaced repo id is treated as a Hub target, never a local directory to delete.
Pass --quant q4_k_m so the model is packed small. Ollama exports run ollama create --quantize, avoiding a huge FP16 intermediate.
If the exported model’s output looks garbled, pass --base-model explicitly (e.g. unsloth/gemma-2-2b-it-bnb-4bit) so the right chat template is used.

Train

Full fine-tuning flow and config.yaml reference.

Train CLI

Every praisonai train subcommand, including export.

praisonai-train Package

Install matrix for the standalone trainer.

Multi-GPU Training

Fine-tune across every GPU with torchrun.