chapter five

5 Parameter-Efficient Fine-Tuning: LoRA and QLoRA

 

This chapter covers

  • How LoRA adapts models with low-rank matrices
  • Choosing LoRA rank, alpha, and other settings
  • Using QLoRA for memory-constrained hardware
  • Testing for safety regressions after tuning
  • Evaluating ROI and selecting training platforms

Parameter-efficient fine-tuning (PEFT) enables organizations to update large language models for new tasks without the expense, technical requirements, or risks of retraining the entire model. With PEFT, only a small number of task-specific parameters are trained (typically 0.1% to 5% of the model’s parameters, which can still be millions), while the main model remains unchanged. Many PEFT approaches use adapter-like modules, small, trainable add-ons placed within specific layers, to guide the model’s responses for specific tasks or areas.

There are several PEFT approaches; however, LoRA (Low‑Rank Adaptation) [1] is the most widely used. It delivers most of the benefits of supervised fine‑tuning at a fraction of the cost. QLoRA extends this approach by combining LoRA with aggressive quantization, enabling fine‑tuning of very large models on memory‑constrained hardware. Other PEFT methods, such as prefix vectors, prompt embeddings, and activation scaling, follow the same core principle but differ in how and where adaptation is applied. In practice, LoRA has emerged as the dominant approach due to its simplicity, strong tooling support, scalability, and model quality.

5.1 Hands-on: Your first LoRA fine-tuning

5.1.1 Step 1: Prepare data

5.1.2 Step 2: Train LoRA adapter

5.1.3 Step 3: Evaluate LoRA

5.1.4 Step 4: Understanding the evaluation results

5.1.5 Step 5: Inference

5.1.6 Step 6: QLoRA

5.1.7 Data quality iterations

5.1.8 Where an adapter beats prompting

5.2 How LoRA works

5.2.1 LoRA core idea

5.2.2 Why low rank?

5.2.3 LoRA versus full fine-tuning: When to use each

5.2.4 When LoRA hits its limits

5.3 Choosing LoRA hyperparameters

5.4 Safety and regression testing

5.4.1 Safety regression testing in practice

5.5 QLoRA: Fine-tuning under memory constraints

5.6 Multi-LoRA: One base, many adapters

5.6.1 Choosing the right adapter at inference time

5.7 Assessing value and ROI

5.7.1 Lowe’s: Catalog intelligence at scale