Fine-tuning, RLHF & Alignment·Question 6 of 61BasicAI-75

Explain how LoRA works - the math, and what r and alpha mean.

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

LoRA (Low-Rank Adaptation) freezes the pretrained weight matrix and learns a low-rank additive update. For a weight $W \in \mathbb{R}^{d \times k}$, the adapted forward pass is:

$$h = Wx + \frac{\alpha}{r},BAx, \qquad B \in \mathbb{R}^{d \times r},; A \in \mathbb{R}^{r \times k},; r \ll \min(d,k)$$

Full worked answer with diagram

LoRA (Low-Rank Adaptation) freezes the pretrained weight matrix and learns a low-rank additive update. For a weight $W \in \mathbb{R}^{d \times k}$, the adapted forward pass is:

$$h = Wx + \frac{\alpha}{r},BAx, \qquad B \in \mathbb{R}^{d \times r},; A \in \mathbb{R}^{r \times k},; r \ll \min(d,k)$$

  • r (rank) is the bottleneck dimension - the capacity of the update. Typical values: 8-64. The full update $BA$ has rank ≤ r, so instead of $d \times k$ trainable params per matrix you have $r(d+k)$. For a 4096×4096 projection with r=16: ~131k params vs ~16.8M - a ~128× reduction on that matrix.
  • alpha is a scaling constant; the update is scaled by $\alpha/r$. This decouples the update's effective magnitude from the rank, so you can change r without retuning the learning rate. Common heuristics: $\alpha = r$ or $\alpha = 2r$. (rsLoRA scales by $\alpha/\sqrt{r}$ instead, which behaves better at high rank.)
  • Initialization: A is random Gaussian, B is zeros - so $BA = 0$ at step 0 and training starts exactly at the base model. That detail matters: it's why LoRA training is stable from the first step.

The underlying hypothesis (from the paper) is that fine-tuning updates have low intrinsic rank - the weight delta needed for a downstream task lives in a low-dimensional subspace, which empirically holds for most adaptation tasks.

Going further: follow-up territory

Two properties worth stating unprompted: (1) the memory win comes from not storing gradients/optimizer states for frozen weights - the base model still occupies memory for forward/backward; (2) after training you can merge $W' = W + \frac{\alpha}{r}BA$ into a single matrix, giving zero inference overhead - unmerged adapters cost a small extra matmul.

Worth sketching. two paths and a sum is the whole idea, and it shows why step 0 is exactly the base model.

flowchart LR
    X["x"] --> W["Frozen W<br/>no grads, no Adam state"]
    X --> A["A: r by k<br/>random init"]
    A --> B["B: d by r<br/>zero init"]
    B -->|"scaled by alpha/r"| S["Sum"]
    W --> S
    S --> H["h"]
    B --> M["Offline merge:<br/>W + alpha/r times BA"]

What a good answer covers

  • LoRA (Low-Rank Adaptation) freezes the pretrained weight matrix and learns a low-rank additive update
  • $$h = Wx + \frac{\alpha}{r}\,BAx, \qquad B \in \mathbb{R}^{d \times r},\; A \in \mathbb{R}^{r \times…
  • r (rank) is the bottleneck dimension - the capacity of the update
  • alpha is a scaling constant; the update is scaled by $\alpha/r$
  • Initialization: A is random Gaussian, B is zeros - so $BA = 0$ at step 0 and training starts exactly at…

Key terms: r (rank) · alpha · Initialization

Interviewer follow-ups to expect

  1. Why initialize B to zero rather than both matrices randomly?

  2. If doubling r doesn't improve quality, what does that tell you?

  3. What breaks if alpha is way too large relative to r?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep