LoRA / QLoRA Fine-tuning — adapt models without retraining
Inject low-rank adaptation matrices into transformer layers to fine-tune a model on domain-specific data using a single consumer GPU.
Fine-tuning4.6

Prompt template
N/A — this is a fine-tuning workflow, not a prompting technique. Use the following training configuration:
Base model: {base_model}
LoRA rank: 8-64
LoRA alpha: 16-128
Target modules: q_proj, v_proj (or all linear layers)
Learning rate: 1e-4 to 3e-4
Epochs: 3-10
Batch size: 4-16 (with gradient accumulation)How to use
- 1Prepare a high-quality instruction dataset (500-10,000 examples) in chat or instruction-response format
- 2Clean and deduplicate the dataset; remove low-quality or off-policy examples
- 3Load the base model in 4-bit (QLoRA) or 16-bit (LoRA) precision with bitsandbytes
- 4Configure LoRA adapters with rank 8-64, alpha 16-128, targeting attention projection layers
- 5Train using SFTTrainer (TRL) with cosine learning rate schedule and warmup
- 6Evaluate the adapter on a held-out test set; merge with base model or deploy as separate adapter
Pro tips
- QLoRA with 4-bit quantization can fine-tune a 70B model on a single 48GB GPU
- Start with rank 8-16; higher ranks (32-64) help for complex tasks but increase storage and compute
- Target all linear layers (not just q/v projections) for better adaptation at the cost of more parameters
- Always keep a copy of the base model — LoRA adapters are small (tens of MB) and can be swapped
Works best with
pefttrlbitsandbyteshuggingface
LoRAQLoRAFine-tuningPEFTDomain Adaptation
Ratings & Reviews
Loading reviews…
Related Skills

Fine-tuning
DPO Alignment — align models with preferences without reward models
Use Direct Preference Optimization to fine-tune a model on chosen/rejected response pairs, aligning outputs with human preferences directly without a separate reward model.
DPORLHFAlignment
4.5
Data
Synthetic Data Generation — create training data with LLMs
Use strong LLMs to generate diverse, high-quality training examples for fine-tuning, then filter and verify quality before use in model training.
Synthetic DataData GenerationFine-tuning
4.3