CoolFace
Apppublic

jellewas/gdpr-lora-v2train

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

LoRA Training Pipeline

Train a LoRA adapter (CPT + SFT) on a HuggingFace dataset using Unsloth and push the merged model to a HuggingFace repository. Runs on GPU-enabled HuggingFace Spaces.

Setup

Required Secrets

Set these as Space secrets (Settings > Repository secrets):

SecretDescription
HF_TOKENHuggingFace token with write access to your model repo
DATA_REPOHF dataset repo containing training data (e.g. MataHariResearch/gdpr-training-data)
MODEL_REPOHF model repo to push results to (e.g. MataHariResearch/gdpr-lora)

Optional Secrets

SecretDescription
WANDB_API_KEYWeights & Biases API key for experiment tracking

Training Hyperparameters (Environment Variables)

All have sensible defaults. Override via Space secrets or env vars.

VariableDefaultDescription
BASE_MODELQwen/Qwen3.5-4BBase model to fine-tune
CPT_RANK32LoRA rank for continued pre-training
CPT_ALPHA64LoRA alpha for CPT
CPT_LR2e-4Learning rate for CPT
CPT_EPOCHS3Number of CPT epochs
SFT_RANK16LoRA rank for supervised fine-tuning
SFT_ALPHA32LoRA alpha for SFT
SFT_LR1e-4Learning rate for SFT
SFT_EPOCHS3Number of SFT epochs
MAX_SEQ_LENGTH4096Maximum sequence length
BATCH_SIZE4Per-device training batch size

Training Data Format

Your DATA_REPO dataset should contain these JSONL files:

  • `corpus.jsonl` (or cpt.jsonl / pretrain.jsonl) — For continued pre-training. Each line: {"text": "..."}. If absent, CPT is skipped.
  • `train.jsonl` — SFT training data. Each line: {"text": "..."} (chat-formatted).
  • `val.jsonl` (or validation.jsonl) — SFT validation data. Same format as train.

Workflow

  1. 1.Create a HuggingFace Space with Docker SDK and a GPU runtime (T4 or better).
  2. 2.Set the required secrets listed above.
  3. 3.The Space builds and launches the Gradio UI.
  4. 4.Click Start Training to begin the pipeline.
  5. 5.Monitor progress in the log panel — it auto-refreshes every 5 seconds.
  6. 6.When complete, the merged model is available at your MODEL_REPO.

Pipeline Steps

  1. 1.Download training data from DATA_REPO
  2. 2.Run CPT (continued pre-training) if corpus file is present
  3. 3.Run SFT (supervised fine-tuning) with CPT adapter merged in
  4. 4.Merge all adapters into the base model
  5. 5.Upload merged model to MODEL_REPO
  6. 6.Optionally convert to GGUF and upload (requires llama.cpp in the image)