While prompt engineering and Retrieval-Augmented Generation (RAG) provide in-context knowledge to Large Language Models (LLMs), adapting a foundation model to master domain-specific syntax, output strict JSON schemas, or adopt specialized reasoning patterns requires Fine-Tuning.
This guide details Parameter-Efficient Fine-Tuning (PEFT) architectures (LoRA and QLoRA), Supervised Fine-Tuning (SFT) dataset construction, and Direct Preference Optimization (DPO).
+-----------------------------------------------------------------------------------------+
| LLM FINE-TUNING PARADIGMS |
+-----------------------------------------------------------------------------------------+
| Method | Trainable Parameters | GPU VRAM Requirements |
+------------------------+-----------------------------------+----------------------------+
| Full Parameter Tuning | 100% of weights (70B params) | Extreme (8x H100 80GB) |
| LoRA (Low-Rank Adapt.) | 0.1% - 1.0% (Low-rank matrices) | Moderate (1x - 2x A100) |
| QLoRA (4-Bit NF4 LoRA) | 0.1% - 1.0% (Quantized base model)| Low (1x Consumer RTX 4090) |
+-----------------------------------------------------------------------------------------+
Rather than updating the frozen d imes k weight matrix W_0, LoRA decomposes the weight update \Delta W into two low-rank matrices B (d imes r) and A (r imes k), where rank r \ll \min(d, k):
During forward passes on input x:
Setting r = 8 or r = 16 reduces trainable memory parameters by over 99\%, allowing fine-tuning of 70B parameter models on accessible hardware.