Skip to content

About

A general purpose rig for fine-tuning LLMs

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

posttrainer

General-purpose serverless fine-tuning and evaluation for language models.

posttrainer is a RunPod Hub worker that gives you LoRA/QLoRA supervised fine-tuning, lm-eval benchmarking, and LoRA adapter merging — against any HuggingFace model — via a single API call. No infrastructure setup, no pip installs, no waiting for CUDA to compile.

What it does

Task What happens
train QLoRA SFT on any HuggingFace dataset via Unsloth + TRL. Pushes merged weights to your HF repo.
eval Runs lm-eval benchmarks (any task: MMLU, MedQA, HellaSwag, etc.) against any model.
merge Merges a LoRA adapter into its base model and pushes merged 16-bit weights to HF Hub.

Stack

Usage

Fine-tune a model (QLoRA SFT)

{
  "input": {
    "task": "train",
    "model_id": "unsloth/gemma-4-E4B-it",
    "dataset_id": "FreedomIntelligence/medical-o1-reasoning-SFT",
    "dataset_config": "en",
    "text_field": "text",
    "output_repo": "yourname/my-fine-tuned-model",
    "hf_token": "hf_...",
    "epochs": 1,
    "learning_rate": "2e-4",
    "lora_r": 64,
    "lora_alpha": 64,
    "max_seq_length": 8192,
    "load_in_4bit": true,
    "merge_and_push": true,
    "run_name": "my-run-001",
    "wandb_api_key": "optional"
  }
}

Response:

{
  "status": "completed",
  "output_repo": "yourname/my-fine-tuned-model",
  "train_loss": 1.432,
  "epochs": 1,
  "total_steps": 312
}

Evaluate a model

{
  "input": {
    "task": "eval",
    "model_id": "yourname/my-fine-tuned-model",
    "tasks": ["medqa_4options", "mmlu_clinical_knowledge", "hellaswag"],
    "num_fewshot": 0,
    "limit": 500,
    "batch_size": 4,
    "hf_token": "hf_...",
    "run_name": "eval-001"
  }
}

Response:

{
  "status": "completed",
  "model": "yourname/my-fine-tuned-model",
  "metrics": {
    "medqa_4options/acc,none": 0.6124,
    "mmlu_clinical_knowledge/acc,none": 0.7132,
    "hellaswag/acc_norm,none": 0.8241
  }
}

Merge a LoRA adapter

{
  "input": {
    "task": "merge",
    "base_model_id": "unsloth/gemma-4-E4B-it",
    "adapter_repo": "yourname/my-lora-adapter",
    "output_repo": "yourname/my-merged-model",
    "hf_token": "hf_...",
    "lora_r": 64,
    "lora_alpha": 64
  }
}

GPU recommendations

Model size Recommended GPU Notes
Up to 4B RTX 4090 (24 GB) QLoRA fits comfortably
7B–8B RTX A6000 / A100 40GB QLoRA with seq ≤ 4096
13B–14B A100 80GB / H100 QLoRA with seq ≤ 4096
30B+ H100 / H200 Multi-GPU or strong QLoRA

Environment variables

All parameters can be passed either in the job input JSON or as environment variables (the Hub UI exposes them with the names below).

Variable Default Description
TASK train train, eval, or merge
MODEL_ID — HuggingFace model ID
HF_TOKEN — HuggingFace API token
DATASET_ID — HuggingFace dataset ID (train only)
OUTPUT_REPO — HF repo to push output to
EPOCHS 1 Training epochs
LORA_R 64 LoRA rank
LORA_ALPHA 64 LoRA alpha
LEARNING_RATE 2e-4 Learning rate
MAX_SEQ_LENGTH 8192 Maximum sequence length
LOAD_IN_4BIT true Enable QLoRA (4-bit)
MERGE_AND_PUSH true Merge adapter before pushing
EVAL_TASKS hellaswag,... Comma-separated lm-eval tasks
WANDB_API_KEY — Optional W&B logging

License

Apache 2.0

About

A general purpose rig for fine-tuning LLMs

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages