Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
jeffallan avatar

Fine Tuning Expert

  • 3.1k installs
  • 10.8k repo stars
  • Updated May 20, 2026
  • jeffallan/claude-skills

fine-tuning-expert is an agent skill that guides LoRA, QLoRA, and PEFT fine-tuning with dataset validation, monitored training, evaluation, and merged model deployment.

About

Fine-Tuning Expert is a Jeffallan agent skill for production LLM adaptation using parameter-efficient fine-tuning with Hugging Face PEFT, TRL SFTTrainer, and optional 4-bit QLoRA. The five-step workflow runs dataset validation before training, method selection based on GPU memory, hyperparameter configuration with warmup and checkpointing, held-out evaluation with perplexity and task metrics, and adapter merge plus quantization for serving. A minimal working example loads Llama-3-8B, configures LoraConfig with rank 16 and target_modules q_proj and v_proj, formats Alpaca-style JSONL prompts, trains with cosine scheduler and eval_steps, and saves adapter weights separately before merge_and_unload deployment. Constraints require validating data quality first, using PEFT for models above 7B parameters, monitoring validation loss for overfitting, versioning datasets and checkpoints, and never deploying without held-out evaluation and latency benchmarks. Output templates include dataset preparation scripts, full TrainingArguments blocks, evaluation scripts, and design rationale for rank and learning rate choices.

  • Five-step workflow: dataset prep, method selection, training, evaluation, deployment merge.
  • Minimal LoRA example with SFTTrainer, LoraConfig rank 16, and Alpaca JSONL formatting.
  • QLoRA variant uses BitsAndBytesConfig 4-bit nf4 loading for memory-constrained GPUs.
  • MUST rules: validate datasets first, use PEFT above 7B, always include LR warmup.
  • Output templates cover dataset validation scripts, training config, and evaluation metrics.

Fine Tuning Expert by the numbers

  • 3,052 all-time installs (skills.sh)
  • +91 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #30 of 2,066 Data Science & ML skills by installs in the Skillselion catalog
  • Security screen: HIGH risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

fine-tuning-expert capabilities & compatibility

Capabilities
dataset validation and alpaca style jsonl format · lora and qlora configuration with sfttrainer · trainingarguments with warmup, eval steps, and c · adapter merge and deployment optimization · hyperparameter and evaluation reference routing
Use cases
api development · testing · devops
From the docs

What fine-tuning-expert says it does

Validate dataset quality before training
SKILL.md
Use parameter-efficient methods for large models (>7B)
SKILL.md
npx skills add https://github.com/jeffallan/claude-skills --skill fine-tuning-expert

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs3.1k
repo stars10.8k
Security audit2 / 3 scanners passed
Last updatedMay 20, 2026
Repositoryjeffallan/claude-skills

How do I fine-tune a large language model efficiently with validated data, correct PEFT settings, and production-ready evaluation?

Fine-tune LLMs with LoRA, QLoRA, and PEFT using validated JSONL datasets, monitored training, evaluation, and merged deployment.

Who is it for?

ML engineers adapting foundation models with Hugging Face PEFT who need checkpointed training and held-out evaluation.

Skip if: Skip when the task is generic MLOps deployment without fine-tuning or when datasets have not passed quality validation.

When should I use this skill?

User mentions LoRA, QLoRA, PEFT, fine-tuning, instruction tuning, RLHF, DPO, or custom LLM training with Hugging Face.

What you get

Validated JSONL dataset, trained LoRA or QLoRA adapter, evaluation metrics, and merged or quantized model ready for serving.

  • dataset validation script
  • training configuration
  • evaluation metrics report

By the numbers

  • [object Object]
  • [object Object]
  • [object Object]

Files

SKILL.mdMarkdownGitHub ↗

Fine-Tuning Expert

Senior ML engineer specializing in LLM fine-tuning, parameter-efficient methods, and production model optimization.

Core Workflow

1. Dataset preparation — Validate and format data; run quality checks before training starts

  • Checkpoint: python validate_dataset.py --input data.jsonl — fix all errors before proceeding

2. Method selection — Choose PEFT technique based on GPU memory and task requirements

  • Use LoRA for most tasks; QLoRA (4-bit) when GPU memory is constrained; full fine-tune only for small models

3. Training — Configure hyperparameters, monitor loss curves, checkpoint regularly

  • Checkpoint: validation loss must decrease; plateau or increase signals overfitting

4. Evaluation — Benchmark against the base model; test on held-out set and edge cases

  • Checkpoint: collect perplexity, task-specific metrics (BLEU/ROUGE), and latency numbers

5. Deployment — Merge adapter weights, quantize, measure inference throughput before serving

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
LoRA/PEFTreferences/lora-peft.mdParameter-efficient fine-tuning, adapters
Dataset Prepreferences/dataset-preparation.mdTraining data formatting, quality checks
Hyperparametersreferences/hyperparameter-tuning.mdLearning rates, batch sizes, schedulers
Evaluationreferences/evaluation-metrics.mdBenchmarking, metrics, model comparison
Deploymentreferences/deployment-optimization.mdModel merging, quantization, serving

Minimal Working Example — LoRA Fine-Tuning with Hugging Face PEFT

from datasets import load_dataset
from transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments
from peft import LoraConfig, get_peft_model, TaskType
from trl import SFTTrainer
import torch

# 1. Load base model and tokenizer
model_id = "meta-llama/Llama-3-8B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.pad_token = tokenizer.eos_token

model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)

# 2. Configure LoRA adapter
lora_config = LoraConfig(
    task_type=TaskType.CAUSAL_LM,
    r=16,               # rank — increase for more capacity, decrease to save memory
    lora_alpha=32,      # scaling factor; typically 2× rank
    target_modules=["q_proj", "v_proj"],
    lora_dropout=0.05,
    bias="none",
)
model = get_peft_model(model, lora_config)
model.print_trainable_parameters()  # verify: should be ~0.1–1% of total params

# 3. Load and format dataset (Alpaca-style JSONL)
dataset = load_dataset("json", data_files={"train": "train.jsonl", "test": "test.jsonl"})

def format_prompt(example):
    return {"text": f"### Instruction:\n{example['instruction']}\n\n### Response:\n{example['output']}"}

dataset = dataset.map(format_prompt)

# 4. Training arguments
training_args = TrainingArguments(
    output_dir="./checkpoints",
    num_train_epochs=3,
    per_device_train_batch_size=4,
    gradient_accumulation_steps=4,     # effective batch size = 16
    learning_rate=2e-4,
    lr_scheduler_type="cosine",
    warmup_ratio=0.03,                 # always use warmup
    fp16=False,
    bf16=True,
    logging_steps=10,
    eval_strategy="steps",
    eval_steps=100,
    save_steps=200,
    load_best_model_at_end=True,
)

# 5. Train
trainer = SFTTrainer(
    model=model,
    args=training_args,
    train_dataset=dataset["train"],
    eval_dataset=dataset["test"],
    dataset_text_field="text",
    max_seq_length=2048,
)
trainer.train()

# 6. Save adapter weights only
model.save_pretrained("./lora-adapter")
tokenizer.save_pretrained("./lora-adapter")

QLoRA variant — add these lines before loading the model to enable 4-bit quantization:

from transformers import BitsAndBytesConfig

bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.bfloat16,
    bnb_4bit_use_double_quant=True,
)
model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config, device_map="auto")

Merge adapter into base model for deployment:

from peft import PeftModel

base = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)
merged = PeftModel.from_pretrained(base, "./lora-adapter").merge_and_unload()
merged.save_pretrained("./merged-model")

Constraints

MUST DO

  • Validate dataset quality before training
  • Use parameter-efficient methods for large models (>7B)
  • Monitor training/validation loss curves
  • Document hyperparameters and training config
  • Version datasets and model checkpoints
  • Always include a learning rate warmup

MUST NOT DO

  • Skip data quality validation
  • Overfit on small datasets — use regularisation (dropout, weight decay) and early stopping
  • Merge incompatible adapters (mismatched rank, base model, or target modules)
  • Deploy without evaluation against a held-out set and latency benchmark

Output Templates

When implementing fine-tuning, always provide: 1. Dataset preparation script with validation logic (schema checks, token-length histogram, deduplication) 2. Training configuration (full TrainingArguments + LoraConfig block, commented) 3. Evaluation script reporting perplexity, task-specific metrics, and latency 4. Brief design rationale — why this PEFT method, rank, and learning rate were chosen for this task

Documentation

Related skills

How it compares

Pick fine-tuning-expert over generic data-cleaning skills when preparing LLM instruction or conversation corpora with Alpaca-style schemas.

FAQ

When should I use QLoRA instead of LoRA?

Use QLoRA with 4-bit BitsAndBytesConfig when GPU memory is constrained; LoRA suits most other tasks.

What checkpoint runs before training starts?

Run python validate_dataset.py and fix all errors before proceeding to method selection.

How do I deploy the trained adapter?

Load the base model, merge the adapter with PeftModel.merge_and_unload, then save or quantize the merged weights.

Is Fine Tuning Expert safe to install?

skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Data Science & MLllmautomation

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.