Scale and post-training
Supervised fine-tuning and PEFT
Instruction tuning, chat formats, data quality, LoRA/QLoRA math, and the tooling that turns a base model into a useful assistant.
A base model predicts the next token on internet text. It completes documents. It does not reliably follow instructions or speak in a consistent assistant voice. Supervised fine-tuning (SFT) teaches that behavior from labeled examples. Parameter-efficient fine-tuning (PEFT) methods like LoRA make the same job cheap enough to run on one GPU.
This is the practical middle of the post-training stack: after pretraining, before preference optimization (RLHF/DPO). Product-facing choices (when to fine-tune versus RAG) live in AI fine-tuning. Here the focus is mechanisms and memory.
Concepts in this section
Read them in order. Each one builds on the one before.
| Step | Concept | What it answers |
|---|---|---|
| 1 | Instruction tuning and loss masking | How do labeled chats become a training signal? |
| 2 | LoRA | How can a thin adapter change a frozen model? |
| 3 | QLoRA | How does 4-bit plus LoRA fit a 70B on one GPU? |
| 4 | PEFT vs full fine-tuning | When do you update every weight? |
Working in practice
Most companies never full-fine-tune a 70B model. They QLoRA on proprietary tickets, SOPs and tone guides, evaluate on a fixed rubric, and export adapters.
Ship checklist: identical train/serve template, held-out golden prompts, regression on a general smoke set, adapter version pinned next to the base revision.
Interviews: explain LoRA shapes, why you mask prompt tokens, the LIMA intuition that quality beats volume, and QLoRA's 4-bit plus adapter split.
Your SFT and RLHF FLOPs are tiny versus pretrain. Pick the best base rather than the bigger number on the badge. See scaling laws.
Typical LoRA knobs: learning rate around 1e-4 to 2e-4, rank 8–64, one to three epochs on solid data. Overfitting shows up as memorized demo phrasing and a falling held-out rubric. For tiny datasets, rewrite the same intents rather than repeating identical rows. At serve time, merge the adapter for simple latency, or keep it separate when each tenant needs its own tune.
Common mistakes
- Template mismatch between train and serve. The model looks "dumber" because the special-token IDs changed.
- Unfiltered instruction dumps. They teach sycophancy and confident hallucination.
- Full fine-tuning as the first experiment. Start with LoRA. Raise rank before you spend a cluster.
Key takeaways
- SFT teaches assistant behavior with masked loss on completions and consistent chat templates.
- Data quality dominates. Curation and filtered synthetic data beat raw dumps.
- LoRA trains
BAof rankrbeside frozenW— orders of magnitude fewer trainable parameters. - QLoRA keeps the base in 4-bit NF4 so large models fine-tune on one GPU.
- Default to PEFT for product work. Use full fine-tuning when you need a large shift and have the budget.
Further learning
Shaw Talebi's QLoRA talk builds the memory picture and walks Python code for single-GPU fine-tuning:
QLoRA: Efficient Finetuning of Quantized LLMsWe present QLoRA, an efficient finetuning approach that reduces memory usage enough to finetune a 65B parameter model on a single 48GB GPU while preserving full 16-bit finetuning task performance. QLoRA backpropagates…arXiv.org
Hugging Face TRL documentationWe’re on a journey to advance and democratize artificial intelligence through open source and open science.huggingface.coRelated
Fine-tuning vs prompting vs RAG
When to change weights instead of the prompt or the retrieved context, and how to decide with evals.
RLHF and preference optimization
How language models learn from human and AI preferences. Supervised fine-tuning, a reward model, a KL-leashed RL step, and DPO as a single-loss alternative. Start here for the map.
LoRA
LoRA freezes the base weights and trains a pair of thin matrices whose product is the update. Trainable parameters drop by orders of magnitude.