Skip to main content
Fine-tune a base model on your dataset and push the result to Hugging Face and Ollama with one command.
export HF_TOKEN="${HF_TOKEN:?Set HF_TOKEN in your shell}"
praisonai train \
    --model unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit \
    --dataset yahma/alpaca-cleaned \
    --hf mervinpraison/llama3.1-instruct \
    --ollama mervinpraison/llama3.1-instruct

To upload to Huggingface

export HF_TOKEN="${HF_TOKEN:?Set HF_TOKEN in your shell}"

Initilise praisonai train

praisonai train init

Requirements

Training dependencies are checked at startup via unsloth package availability but only fully loaded when training commands run.
Install training dependencies:
pip install "praisonai[train]"
Required for training:
  1. Huggingface token
  2. Base model to train on (e.g. unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit)
  3. Dataset to train on (e.g. yahma/alpaca-cleaned)
  4. Huggingface model name to upload to (e.g. mervinpraison/llama3.1-instruct) (Optional)
  5. Ollama model name to upload to (e.g. mervinpraison/llama3.1-instruct) (Optional)
If training dependencies are missing, you’ll see:
ERROR: Training dependencies not installed. Install with:

pip install "praisonai[train]"
Or run: praisonai train init

To upload to ollama.com (Linux)

sudo cat /usr/share/ollama/.ollama/id_ed25519.pub
Save the output from above to ollama.com —> Ollama keys
You no longer need to run ollama serve manually before praisonai train. The training command starts the Ollama daemon automatically if it isn’t already running, then creates and pushes the model. Requires the ollama CLI on PATH — install from ollama.com.

RUN PraisonAI Train

praisonai train \
    --model unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit \
    --dataset yahma/alpaca-cleaned \
    --hf mervinpraison/llama3.1-instruct \
    --ollama mervinpraison/llama3.1-instruct
Note: PraisonAI Train currently tested on Linux with 1 GPU. With pytorch-cuda=12.1

Config.yaml example

ollama_save: "true"
huggingface_save: "true"
train: "true"

model_name: "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit"
hf_model_name: "mervinpraison/llama-3.1-instruct"
ollama_model: "mervinpraison/llama3.1-instruct"
model_parameters: "8b"

dataset:
  - name: "yahma/alpaca-cleaned"
    split_type: "train"
    processing_func: "format_prompts"
    rename:
      input: "input"
      output: "output"
      instruction: "instruction"
    filter_data: false
    filter_column_value: "id"
    filter_value: "alpaca"
    num_samples: 20000

dataset_text_field: "text"
dataset_num_proc: 2
packing: false

max_seq_length: 2048
load_in_4bit: true
lora_r: 16
lora_target_modules: 
  - "q_proj"
  - "k_proj"
  - "v_proj"
  - "o_proj"
  - "gate_proj"
  - "up_proj"
  - "down_proj"
lora_alpha: 16
lora_dropout: 0
lora_bias: "none"
use_gradient_checkpointing: "unsloth"
random_state: 3407
use_rslora: false
loftq_config: null

per_device_train_batch_size: 2
gradient_accumulation_steps: 2
warmup_steps: 5
num_train_epochs: 1
max_steps: 10
learning_rate: 2.0e-4
logging_steps: 1
optim: "adamw_8bit"
weight_decay: 0.01
lr_scheduler_type: "linear"
seed: 3407
output_dir: "outputs"

quantization_method: 
  - "q4_k_m"

praisonai train

wandb

wandb login
Get the key from here
export PRAISON_WANDB=True
export WANDB_LOG_MODEL=checkpoint
export WANDB_PROJECT=praisonai-test
export PRAISON_WANDB_RUN_NAME=praisonai-train  

How It Works

You point the trainer at a base model and dataset; it fine-tunes with LoRA and pushes the result to the hubs you configured.

Best Practices

Export HF_TOKEN in your shell before training so the trainer can push to Hugging Face. Never commit the raw token.
Use a low max_steps and a small num_samples for a first run to confirm the pipeline before a full training job.
Run pip install "praisonai[train]" (or praisonai train init) so unsloth and CUDA deps are available.
Set PRAISON_WANDB=True and the WANDB_* variables to log loss curves and checkpoints for each run.

Models

Use your fine-tuned model with an Agent.

Installation

Install the training extras.