Quick Start
You already have a trained model inlora_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:--base-modelif passed.- else
model_namein--config. - else
_name_or_pathfrom<model-dir>/config.json. - else the model-dir name itself.
Prerequisites
Hugging Face export
Hugging Face export
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.Ollama export
Ollama export
ollamaCLI installed (from https://ollama.com).- Your signing key registered at https://ollama.com/settings/keys — public key lives at
~/.ollama/id_ed25519.pub. - Enough free space on
$OLLAMA_MODELS(defaults to~/.ollama/models).
No GPU needed
No GPU needed
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):
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 theTrainModel.for_export() classmethod — it builds an export-only trainer (no dataset required) and validates the quantization up front.
Best Practices
Namespace repos to your own username
Namespace repos to your own username
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.Quantize at export time
Quantize at export time
Pass
--quant q4_k_m so the model is packed small. Ollama exports run ollama create --quantize, avoiding a huge FP16 intermediate.Set the base model when in doubt
Set the base model when in doubt
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.Related
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.

