Tiny Adapters
One layer of Robo's brain is a grid of 32 × 32 = 1,024 knobs. It is great at its old job. To learn a new job, do we really have to turn all 1,024 knobs? A LoRA adapter clips on two thin strips of knobs instead, and multiplies them into a whole grid of changes.
The old grid stays locked. Only the thin strips A and B learn. Press Train adapter and watch how much of Job B it learns.
How to play: choose a job and an adapter size (the rank), then press Train adapter. Compare with turning every knob (full fine-tune).
Inside the layer step 0
Blue = plus, orange = minus. B is tall and thin, A is short and wide. Multiplied together they paint a full 32 × 32 grid of changes.
How much of the job is learned
Strength of each "direction" in the change (singular values)
Any grid of changes can be split into simple "directions". The adapter can never have more than rank of them.
Score for every adapter size
Challenges
What just happened?
- The big grid W was already trained. We locked it: not one of its 1,024 knobs moved.
- The adapter is two thin strips, B and A. Multiplying them makes a full grid of changes, but a very simple one: it can only push in r "directions".
- Jobs B and C only needed a few strong directions. So a tiny adapter learned almost all of them, with a fraction of the knobs.
- Bigger rank = more directions = a bit more of the job, but more knobs. Past the job's real number of directions it barely helps.
- Adapters are small, so you can keep one per job and swap them in a blink. Or melt one into W, and the model runs exactly as fast as before.
How it works
- The layer turns 32 numbers in into 32 numbers out using its grid W.
- Each new job is "a different grid": the old one plus a hidden change made of a few strong directions and a little fuzz.
- The adapter starts with A random and B all zeros, so at first it changes nothing.
- Robo shows the layer 160 examples of the new job, measures the mistakes, and nudges only A and B.
- "Job learned" = how much of the old layer's mistake on 300 new inputs the adapter has fixed.
For grown-ups: what's really going on
LoRA (Hu et al., 2021) freezes a pretrained weight W0 ∈ ℝd×d and learns h = (W0 + (α/r)·BA)x with B ∈ ℝd×r, A ∈ ℝr×d. Here d = 32, α = 4, A ~ 𝒩(0, 1/d), B = 0 so training starts exactly at the pretrained model. Trainable parameters: 2dr versus d².
- Task: linear regression
y = W*x + εwithW* = W0 + ΔW*; ΔW* has singular values (2.2, 1.5, 0.9) for Job B and (2.0, 1.1) for Job C plus i.i.d. fuzz (σ = 0.02). MSE, Adam (lr 0.02), full batch of 160; "job learned" =1 − ‖Ŷ−Y‖² / ‖Y0−Y‖²on 300 test inputs. - Gradients: with
G = ∂L/∂ΔW = (2/n)EᵀX,∂L/∂B = (α/r)·G·Aᵀand∂L/∂A = (α/r)·Bᵀ·G. rank(BA) ≤ ralways; the singular-value chart (Jacobi eigen-decomposition of ΔWᵀΔW) shows exactly r non-zero values. The hypothesis behind LoRA is that fine-tuning updates have low intrinsic rank, which this toy builds in.- Merging:
W = W0 + (α/r)BAgives zero inference overhead; keeping adapters separate allows instant task switching with one shared base (multi-LoRA serving). QLoRA adds a 4-bit quantised base.