AI Hints
Home›Fine-Tuning LLMs Tutorial›Interview Questions and Cheat Sheets
Fine-Tuning LLMs · Lesson 115 of 120

Interview: LoRA and Training

The deeper questions.

⏱ 2 min read▶ Video at 2:54:20🎓 Free
Watch this lesson in the Fine-Tuning LLMs courseWatch on YouTube ↗Full Fine-Tuning LLMs course

The next questions go deeper. Interviewers want to know that you understand how LoRA works, and how to train well.

  • Deeper questions
  • How LoRA works
  • How to train well

How does LoRA work?

Question one. How does LoRA work? A good answer. LoRA freezes the original weights. It adds two small matrices, B and A, beside chosen layers. Their product is a low rank update, added to the layer's output. Only B and A are trained.

keyvalue
Freezeoriginal weights
Addsmall matrices B and A
UpdateB × A, low rank
Trainonly B and A

Rank and alpha

Question two. What are rank, and alpha? Rank is the inner size of B and A. A higher rank can learn more, but trains more parameters. Alpha scales the update. A common choice is alpha equals twice the rank.

keyvalue
Rank rinner size of B and A
Higher rmore capacity, more params
Alphascales the update
Commonalpha = 2 × r

QLoRA and memory

Question three. What is QLoRA? It loads the base model in four bit precision, and trains LoRA adapters on top. It cuts memory by about four times, so big models fit on one GPU. Question four. Other ways to save memory? Gradient accumulation, and gradient checkpointing.

keyvalue
QLoRA4-bit base + LoRA
Savesabout 4× memory
Alsogradient accumulation
Andgradient checkpointing

Practice question

Here's a tricky one. Why does LoRA usually forget less than full fine-tuning? Pause, and think about it. The answer is C. The original weights are frozen, so the model's old knowledge stays intact.

Quick check
Why does LoRA usually forget less?

Preferences

Question six. What's the difference between SFT, and DPO? SFT copies example answers. DPO learns from pairs of a chosen, and a rejected answer, with no reward model. It usually comes after SFT, to polish style.

keyvalue
SFTcopy good answers
DPOchosen vs rejected
Noreward model needed
OrderSFT, then DPO

Summary

Let's recap. LoRA trains small matrices, beside frozen weights. Rank sets capacity, and alpha scales the update. QLoRA adds four bit loading. And DPO learns from preferences. Next, a code cheat sheet.

Key takeaways
  • LoRA: B × A
  • Rank and alpha
  • QLoRA, DPO
Next up: Cheat Sheet: Code — the lines you will reuse