advanced classification-sentiment 40 min read

Fine-Tuning and Low-Rank Adaptation

A pretrained encoder can be read by a probe, rewritten by full fine-tuning, or nudged inside a low-rank subspace. The factored update's first step is a random sketch of the full one, its two factors conserve a hyperbola under gradient flow, and what fine-tuning never touches is what it forgets least. On a toy encoder, the full update turns out to be nearly low-rank, and LoRA forgets more than full fine-tuning at ten times its rate but less at the same rate

Overview & Motivation

The aspect sentiment topic ended on a limit. One attention layer whose query is the aspect is a signed vote, and replacing one word by another moves the vote in a direction no context can reverse, so no such layer reads “sales were not weak this period”. It pointed to the standard escape: a pretrained encoder, fine-tuned, in which every word’s representation is already a function of its neighbors. This page does that. The encoder is the one the masked-LM topic trained from scratch on synthetic filings: an 879879-word vocabulary, 3232 positions, width d=64d = 64, two pre-LN blocks, 158,447158{,}447 parameters. The task is Topic 19’s: read the polarity of a gold aspect, from the mean of the encoder’s final states over the aspect’s words.

There are three ways to adapt a pretrained network to a task:

  • Read it. Train a classifier on its frozen features, the linear probe of formalML’s representation-learning.
  • Rewrite it. Train every weight from the pretrained start with a new head (Devlin and colleagues 2019).
  • Nudge it. Freeze every weight and train a low-rank correction to each matrix (Hu and colleagues 2022).

On 14,17914{,}179 test aspects, the probe reads 0.7610.761. The same encoder never pretrained, fine-tuned identically, reads 0.9510.951. The pretrained encoder, fine-tuned, reads 0.9700.970 to 0.9890.989 over three seeds. The gap between the last two is what pretraining buys, and its largest part, construction by construction, is negation: negated adjectives are read at 0.9200.920 to 0.9910.991 against 0.7170.717. Counted in rows, plain adjectives gain more, since there are four times as many of them.

The page proves what can be said exactly about the third way and measures the rest on this encoder, in order:

  1. One weight, two factors. What the factorization gives and costs.
  2. The first step. Why the scale must fall like 1/r1/\sqrt r.
  3. What two factors conserve. A hyperbola under gradient flow.
  4. Is the update low-rank? Full fine-tuning’s answer.
  5. What fine-tuning leaves alone. The span lemma, probe-first fine-tuning, and forgetting.
  6. Two lenses on why a small update suffices. Random subspaces and kernels.
  7. Reading negation in filings. A shortcut, its repair, and document tone.

One weight, two factors

Start with one number. A weight w0w_0 is frozen, and the adaptation moves it by s abs\,ab, a product of two trained numbers aa and bb and a fixed scale ss. Every update Δw\Delta w is reached along a whole curve of pairs, the hyperbola ab=Δw/sab = \Delta w/s, so the parameters are not identified by the function they compute. If bb starts at 00, the update starts at 00. The matrix version is the same picture in higher dimension.

Definition 1 (Low-rank adaptation).

A layer maps a row vector x∈Rkx \in \mathbb R^k to xWxW with W∈Rk×mW \in \mathbb R^{k \times m}. Its low-rank adaptation freezes W0W_0 and trains

W=W0+s AB,A∈Rk×r, B∈Rr×m,W = W_0 + s\,AB, \qquad A \in \mathbb R^{k \times r},\ B \in \mathbb R^{r \times m},

from A0A_0 with independent N(0,σ2)N(0, \sigma^2) entries, σ2=1/k\sigma^2 = 1/k, and B0=0B_0 = 0. The scale ss is α/r\alpha/r (Hu and colleagues) or α/r\alpha/\sqrt r (rank-stabilized, Kalajdzievski 2023), for a constant α\alpha. A probe trains only a new head on frozen features; full fine-tuning trains every parameter.

Hu and colleagues write the transpose, for column vectors, with their BB zero and their AA random. We keep the roles: AA is the random factor and BB the one that starts at zero. Their text draws AA from a Gaussian; their reference code draws it from a uniform distribution.

Proposition 1 (What the factorization buys and costs).

(a) rank⁡(s AB)≤r\operatorname{rank}(s\,AB) \le r, with r(k+m)r(k + m) trained parameters in place of kmkm.

(b) x(W0+s AB)=xW0+s (xA)Bx(W_0 + s\,AB) = xW_0 + s\,(xA)B, so after training the update merges into one matrix and inference costs nothing extra.

(c) For every invertible S∈Rr×rS \in \mathbb R^{r \times r}, the pair (AS,S−1B)(AS, S^{-1}B) gives the same update, so the factors are not identified.

(d) When 2r≤min⁡(k,m)2r \le \min(k, m), two updates of rank rr can sum to rank 2r2r, so the set of rank-at-most-rr updates is not a linear space.

Proof.

(a) The columns of ABAB are combinations of the rr columns of AA. (b) and (c) are associativity: (AS)(S−1B)=AB(AS)(S^{-1}B) = AB. (d) The sum A1B1+A2B2A_1B_1 + A_2B_2 is [A1 A2][A_1\ A_2] times the stacked matrix of B1B_1 over B2B_2, so it has rank 2r2r when [A1 A2][A_1\ A_2] has 2r2r independent columns and the stacked matrix has 2r2r independent rows; at r=1r = 1, e1e1⊤+e2e2⊤e_1e_1^\top + e_2e_2^\top has rank 22. Column spaces that meet only at 00 are not enough: ue1⊤+ve1⊤ue_1^\top + ve_1^\top has rank 11.

∎

On this encoder we adapt the query and value maps of both blocks, as Hu and colleagues do in most of their experiments. Each is a 64×6464 \times 64 matrix once the four heads sit side by side, so rank 1616 trains 8,1928{,}192 numbers of the encoder’s 158,447158{,}447. The One weight, two factors tab draws the one-dimensional picture: the loss 12(ab−2)2\tfrac12(ab - 2)^2 in the (a,b)(a, b) plane, and the paths of gradient descent and of Adam from (a0,0)(a_0, 0).

One weight, two factors: w = ab, from (a₀, 0) toward ab = 2
start a₀
step size η
000.50.5111.51.5222.52.5a (random factor)b (starts at 0)
minimizers ab = 2a² − b² = a₀² (conserved by gradient flow)gradient descentAdam
GD ends at (a, b)
(1.457, 1.373)
Adam ends at (a, b)
(1.737, 1.151)
GD: max |a² − b² − a₀²|
0.0126
Adam: max |a² − b² − a₀²|
1.5642

Theorem 2: gradient flow keeps a² − b² fixed, so the path rides its hyperbola to the one minimizer on it, and b can grow only as fast as a. GD's drift is O(η) over the run, so it grows with the step; Adam rescales each coordinate, and its paths drift much further. Both paths run 400 steps.


The first step of a factored update

Write G=∂L/∂WG = \partial L / \partial W for the gradient full fine-tuning would use at the current weights. The chain rule (formalCalculus jacobian, Theorem 2) gives the factors’ gradients in terms of GG, and at the zero start one of them vanishes.

Theorem 1 (The factored gradient and the first step).

(a) ∂L/∂A=s GB⊤\partial L/\partial A = s\,GB^\top and ∂L/∂B=s A⊤G\partial L/\partial B = s\,A^\top G.

(b) At B=0B = 0, ∂L/∂A=0\partial L / \partial A = 0, and one SGD step of rate η\eta moves the weights by

ΔW1=−η s2A0A0⊤G,\Delta W_1 = -\eta\, s^2 A_0 A_0^\top G,

the full step −ηG-\eta G pushed through the random map A0A0⊤A_0A_0^\top of rank rr.

(c) E[A0A0⊤]=rσ2I\mathbb E[A_0A_0^\top] = r\sigma^2 I, so E ΔW1=−η s2rσ2G\mathbb E\,\Delta W_1 = -\eta\, s^2 r \sigma^2 G: under s=α/rs = \alpha/r the mean step shrinks like 1/r1/r, and under s=α/rs = \alpha/\sqrt r it does not depend on rr. A single draw is noisy: E∥A0A0⊤−rσ2I∥F2=rσ4k(k+1)\mathbb E \lVert A_0A_0^\top - r\sigma^2 I \rVert_F^2 = r\sigma^4 k(k+1), a relative deviation of (k+1)/r\sqrt{(k+1)/r}.

(d) Adam’s first step from zero moments, with its ϵ\epsilon set to 00, is the sign step B1=−ηsgn⁡(A0⊤G)B_1 = -\eta \operatorname{sgn}(A_0^\top G), so ΔW1=−η s A0sgn⁡(A0⊤G)\Delta W_1 = -\eta\, s\, A_0 \operatorname{sgn}(A_0^\top G), and when no entry of A0⊤GA_0^\top G is zero,

η srm σmin⁡(A0)≤∥ΔW1∥F≤η srm σmax⁡(A0).\eta\, s \sqrt{rm}\ \sigma_{\min}(A_0) \le \lVert \Delta W_1 \rVert_F \le \eta\, s \sqrt{rm}\ \sigma_{\max}(A_0).

Proof.

(a) WW depends on AA through s ABs\,AB, so a change dAdA changes LL by ⟨G,s dA B⟩=⟨s GB⊤,dA⟩\langle G, s\, dA\, B\rangle = \langle s\,GB^\top, dA\rangle; likewise ⟨G,s A dB⟩=⟨s A⊤G,dB⟩\langle G, s\,A\, dB\rangle = \langle s\,A^\top G, dB\rangle.

(b) At B=0B = 0 the first gradient is 00. The step sets B1=−ηsA0⊤GB_1 = -\eta s A_0^\top G and leaves AA at A0A_0, so ΔW1=s A0B1\Delta W_1 = s\,A_0 B_1.

(c) Write a1,…,ara_1, \dots, a_r for the columns of A0A_0, so A0A0⊤=∑lalal⊤A_0A_0^\top = \sum_l a_l a_l^\top and E[alal⊤]=σ2I\mathbb E[a_l a_l^\top] = \sigma^2 I. The terms alal⊤−σ2Ia_la_l^\top - \sigma^2 I are independent with mean 00, so the expected squared norm of their sum is r E∥aa⊤−σ2I∥F2=r (E∥a∥4−2σ2 E∥a∥2+kσ4)r\, \mathbb E\lVert aa^\top - \sigma^2 I \rVert_F^2 = r\,(\mathbb E\lVert a\rVert^4 - 2\sigma^2\, \mathbb E\lVert a \rVert^2 + k\sigma^4). For a Gaussian vector, E∥a∥2=kσ2\mathbb E\lVert a\rVert^2 = k\sigma^2 and E∥a∥4=(k2+2k)σ4\mathbb E \lVert a \rVert^4 = (k^2 + 2k)\sigma^4, which gives rσ4(k2+k)r\sigma^4(k^2 + k). Dividing by ∥rσ2I∥F2=r2σ4k\lVert r\sigma^2 I\rVert_F^2 = r^2\sigma^4 k gives (k+1)/r(k+1)/r.

(d) Adam’s first update is m1/(v1+ϵ)m_1/(\sqrt{v_1} + \epsilon) with m1=gm_1 = g and v1=g2v_1 = g^2 after bias correction, which is sgn⁡(g)\operatorname{sgn}(g) when ϵ=0\epsilon = 0; the sign of s A0⊤Gs\,A_0^\top G is the sign of A0⊤GA_0^\top G. Let Q=sgn⁡(A0⊤G)Q = \operatorname{sgn}(A_0^\top G), an r×mr \times m matrix of signs with columns qjq_j, ∥qj∥2=r\lVert q_j \rVert^2 = r. Then ∥A0Q∥F2=∑j∥A0qj∥2\lVert A_0 Q\rVert_F^2 = \sum_j \lVert A_0 q_j\rVert^2, and each term lies between σmin⁡(A0)2 r\sigma_{\min}(A_0)^2\, r and σmax⁡(A0)2 r\sigma_{\max}(A_0)^2\, r.

∎

For a Gaussian A0A_0 with r≤kr \le k, the singular values of A0/σA_0/\sigma lie within k±r\sqrt k \pm \sqrt r in expectation (Vershynin 2012, Theorem 5.32, with the tail bound of Corollary 5.35). So under Adam ∥ΔW1∥F\lVert \Delta W_1 \rVert_F is about η srm\eta\, s\sqrt{rm}: it stays put as rr grows only under s=α/rs = \alpha/\sqrt r, for every draw. Kalajdzievski’s Theorem 3.2 proves the general version for SGD, at every fixed step as r→∞r \to \infty; part (c) is its first step made exact, and part (d), for Adam, is ours.

On the encoder, from the probe’s head (at a zero head every encoder gradient is zero), we averaged 1616 draws of A0A_0 for each rank, with the same draws under both scales. Under Adam with α/r\alpha/\sqrt r, the first step’s size moves from 1.2851.285 at r=1r = 1 to 1.6261.626 at r=64r = 64. With α/r\alpha/r it falls to 0.2030.203, exactly 1/r1/\sqrt r times the other. Under SGD with α/r\alpha/\sqrt r, the mean step is 0.00570.0057 at every rank, but a single draw’s size at r=1r = 1, averaged over the 1616, is 0.04280.0428, and it falls toward the mean, reaching 0.00810.0081 at r=k=64r = k = 64. The moments behind part (c) give the exact law: for a Gaussian column E[∥a∥2aa⊤]=(k+2)σ4I\mathbb E[\lVert a\rVert^2 aa^\top] = (k+2)\sigma^4 I, so E[(aa⊤−σ2I)2]=(k+1)σ4I\mathbb E[(aa^\top - \sigma^2 I)^2] = (k+1)\sigma^4 I and, for every GG, E∥A0A0⊤G∥F2=(1+k+1r)∥rσ2G∥F2\mathbb E\lVert A_0A_0^\top G\rVert_F^2 = \big(1 + \tfrac{k+1}{r}\big)\lVert r\sigma^2 G\rVert_F^2. A draw’s root-mean-square size is then 66≈8.1\sqrt{66} \approx 8.1 times the mean at r=1r = 1 and 129/64≈1.42\sqrt{129/64} \approx 1.42 times it at r=64r = 64, so even at r=kr = k it stays about 2\sqrt 2 above the mean; over the 1616 draws the ratios are 7.77.7 and 1.431.43. The Rank and scaling tab plots these, and what training made of them.

Trained for three epochs at one rate, the scale decides the update’s size more than its accuracy. Under α/r\alpha/\sqrt r, the merged update ∥s AB∥F\lVert s\,AB\rVert_F grows from 28.428.4 at rank 11 to 61.861.8 at rank 6464; under α/r\alpha/r it shrinks to 21.421.4. On this seed the accuracies cross (0.9540.954 against 0.9470.947 at rank 44, 0.9330.933 against 0.9560.956 at rank 1616), but both gaps sit inside the spread of the headline LoRA run over three seeds (0.9110.911 to 0.9560.956), so neither scale wins here. Rank stability promises that the right learning rate does not move with rr, not that one scale wins at a fixed rate.


What two factors conserve

Back in one dimension, gradient descent on (a,b)(a, b) for a loss of w=s abw = s\,ab has a˙=−s b g\dot a = -s\,b\,g and b˙=−s a g\dot b = -s\,a\,g for the same scalar gg, so ddt(a2−b2)=0\tfrac{d}{dt}(a^2 - b^2) = 0. The path never leaves the hyperbola it starts on, and from (a0,0)(a_0, 0) that is a2−b2=a02a^2 - b^2 = a_0^2: the factor that started at zero can grow only as fast as the other.

Theorem 2 (Balancedness).

(a) Under gradient flow on (A,B)(A, B), ddt (A⊤A−BB⊤)=0\tfrac{d}{dt}\,(A^\top A - BB^\top) = 0. From B0=0B_0 = 0, A⊤A−BB⊤=A0⊤A0A^\top A - BB^\top = A_0^\top A_0 for all time, and in particular ∥A∥F2−∥B∥F2=∥A0∥F2\lVert A\rVert_F^2 - \lVert B\rVert_F^2 = \lVert A_0\rVert_F^2.

(b) One gradient-descent step of size η\eta changes A⊤A−BB⊤A^\top A - BB^\top by exactly η2s2 (BG⊤GB⊤−A⊤GG⊤A)\eta^2 s^2\,(BG^\top GB^\top - A^\top GG^\top A).

Proof.

(a) By Theorem 1(a), A˙=−s GB⊤\dot A = -s\,GB^\top and B˙=−s A⊤G\dot B = -s\,A^\top G. Then ddt(A⊤A)=A˙⊤A+A⊤A˙=−s (BG⊤A+A⊤GB⊤)\tfrac{d}{dt}(A^\top A) = \dot A^\top A + A^\top \dot A = -s\,(BG^\top A + A^\top G B^\top) and ddt(BB⊤)=B˙B⊤+BB˙⊤=−s (A⊤GB⊤+BG⊤A)\tfrac{d}{dt}(BB^\top) = \dot B B^\top + B \dot B^\top = -s\,(A^\top G B^\top + BG^\top A), the same matrix. Taking traces gives the norms.

(b) With A1=A−ηs GB⊤A_1 = A - \eta s\, GB^\top and B1=B−ηs A⊤GB_1 = B - \eta s\, A^\top G, expand A1⊤A1A_1^\top A_1 and B1B1⊤B_1B_1^\top. The terms linear in η\eta are equal, as in (a), and the quadratic terms are η2s2 BG⊤GB⊤\eta^2 s^2\, BG^\top G B^\top and η2s2 A⊤GG⊤A\eta^2 s^2\, A^\top G G^\top A.

∎

This is Theorem 2.2 of Du, Hu, and Lee (2018), for consecutive linear layers, and part (b) is their Claim B.1; Arora, Cohen, and Hazan (2018) use the same invariant (their Equation 9). Part (b) makes the drift O(η2)O(\eta^2) per step, so over a fixed time horizon it is O(η)O(\eta). On a small least-squares problem, halving η\eta halves the drift at a fixed horizon: the slope against η\eta on log axes is 1.0041.004.

Adam is not gradient descent. It divides every coordinate by its own running scale, and the invariant goes. Fine-tuning the encoder with Adam, the headline LoRA run ends with A⊤A−BB⊤A^\top A - BB^\top moved, in the worst of its four matrices, by 1.421.42 times the size of A0⊤A0A_0^\top A_0. In the kernel experiment below (120120 rows, from the probe’s head, 300300 full-batch steps), gradient descent at its stable rate keeps it within 2.4×10−62.4 \times 10^{-6}, while Adam from the same start moves it by 1.431.43. In the lab, gradient descent drifts off only by the η2\eta^2 terms of part (b), and the Adam paths drift much further.


Is the update low-rank?

Hu and colleagues hypothesized that the update full fine-tuning makes has a low intrinsic rank, which is why a rank-rr correction can stand in for it. We can ask full fine-tuning directly: take its update ΔW\Delta W to each of the twelve block matrices (query, key, value, output, and the two MLP maps, in both blocks) and look at its singular values.

Proposition 2 (Truncating the full update).

For any ΔW\Delta W with singular values σ1≥σ2≥⋯\sigma_1 \ge \sigma_2 \ge \cdots, the truncated SVD ΔWr\Delta W_r, which keeps the top rr singular triples, minimizes ∥ΔW−M∥F\lVert \Delta W - M\rVert_F over all MM of rank at most rr, with ∥ΔW−ΔWr∥F2=∑i>rσi2\lVert \Delta W - \Delta W_r\rVert_F^2 = \sum_{i \gt r} \sigma_i^2.

This is the Eckart–Young–Mirsky theorem, proved in full as Theorem 2 of formalML’s svd. Two yardsticks say whether an update is low-rank. The first is a random matrix of the same size and the same Frobenius norm, whose largest singular value sits near τ(k+m)\tau(\sqrt k + \sqrt m) with τ=∥ΔW∥F/km\tau = \lVert\Delta W\rVert_F / \sqrt{km}, the edge of the Marchenko–Pastur law (formalML’s double-descent, Theorem 1). The second is accuracy: merge the truncated update back in and score the result.

For full fine-tuning’s first seed, every one of the twelve updates has its top singular value 1.761.76 to 3.723.72 times above that edge, and a stable rank ∥ΔW∥F2/σ12\lVert\Delta W\rVert_F^2/\sigma_1^2 between 2.062.06 and 5.555.55, out of a possible 6464. The accuracy confirms it. With every block-matrix update removed and only the fine-tuned biases, embeddings, and head kept, the model reads 0.4800.480; with every update truncated to rank 11, 0.8080.808; to rank 22, 0.9290.929; to rank 44, 0.9770.977; to rank 88, 0.9870.987; and the full update reads 0.9890.989. On the other two seeds rank 44 keeps 0.9350.935 of 0.9700.970 and 0.9580.958 of 0.9880.988, and on all three rank 88 is within 0.010.01 of the full update. The What full fine-tuning changed tab shows the spectra and slides the truncation.

So a rank-44 update to every block matrix exists that does nearly everything full fine-tuning does, and LoRA cannot express it: LoRA adapts only the query and value maps, and no embedding. Inside that class, full fine-tuning’s own update does little. Keep only its query and value updates, put every other weight, bias, and embedding back at its pretrained value, and refit the probe: it reads 0.8050.805 to 0.8260.826 at rank 44 over three seeds, and at most 0.8510.851 at full rank. LoRA trained at rank 44 in the same class reads 0.9540.954 under α/r\alpha/r and 0.9470.947 under α/r\alpha/\sqrt r. The update that does the work is spread over all twelve matrices; inside its own class, LoRA finds a far better one than full fine-tuning did.


What fine-tuning leaves alone

Gradient descent on a linear layer has a simple structure: the gradient of WW is a sum of outer products of the layer’s inputs with the backpropagated signals, so every step lies in the span of the inputs the layer saw.

Theorem 3 (What fine-tuning leaves alone).

(a) Let a linear map x↦xWx \mapsto xW be trained by SGD on fixed inputs x1,…,xnx_1, \dots, x_n, and let SS be their span. The columns of Wt−W0W_t - W_0 lie in SS, so vWt=vW0vW_t = vW_0 for every vv orthogonal to SS.

(b) In the encoder, an embedding row whose token never occurs in the fine-tuning inputs has zero gradient at every step, so it never moves, under SGD, under Adam, and under the L2-SP penalty of Proposition 3.

(c) Let f(x)=v⊤Bxf(x) = v^\top B x with B∈Rk×dB \in \mathbb R^{k \times d} and v∈Rkv \in \mathbb R^k be trained by gradient flow on squared loss, from (B0,v0)(B_0, v_0), on inputs spanning SS, with targets v∗⊤B∗xv_\ast^\top B_\ast x. Then Btx=B0xB_t x = B_0 x for all x⊥Sx \perp S and all tt. If the features are perfect, B0=UB∗B_0 = UB_\ast for an invertible UU, the training features B0x1,…,B0xnB_0x_1, \dots, B_0x_n span Rk\mathbb R^k, and v0v_0 is the probe’s least-squares head, then the loss is 00 at every input, in SS or not, for all tt.

Proof.

(a) The gradient of 1n∑iℓ(xiW)\tfrac1n\sum_i \ell(x_iW) is 1n∑ixi⊤δi\tfrac1n\sum_i x_i^\top \delta_i, with δi\delta_i the gradient of ℓ\ell at xiWx_iW. Its columns lie in SS, and so does every sum of such steps. For v⊥Sv \perp S, v(Wt−W0)=0v(W_t - W_0) = 0.

(b) The embedding gradient is a sum over input positions of the backpropagated signal at that position, scattered to the row of the position’s token, so an absent token’s row receives 00 at every step. Adam’s moments for that row then stay 00, and its update m/(v+ϵ)m/(\sqrt v + \epsilon) is 00. L2-SP adds λ(θ−θ0)\lambda(\theta - \theta_0), which is 00 while the row sits at θ0\theta_0, so by induction it stays there.

(c) The flow is B˙=−v (XB⊤v−Y)⊤X\dot B = -v\,(XB^\top v - Y)^\top X up to a constant factor, with the inputs as rows of XX, so B˙ x=0\dot B\, x = 0 whenever Xx=0Xx = 0: that is Kumar and colleagues’ Lemma A.3. With perfect features, the head v=U−⊤v∗v = U^{-\top}v_\ast fits the targets exactly, since B0⊤v=B∗⊤U⊤U−⊤v∗=B∗⊤v∗B_0^\top v = B_\ast^\top U^\top U^{-\top}v_\ast = B_\ast^\top v_\ast. The training features span Rk\mathbb R^k, so it is the unique least-squares head, and the probe returns it. Without that hypothesis the claim fails: with B∗=U=I2B_\ast = U = I_2 and inputs along e1e_1 only, the minimum-norm head fits every training input and reads e2e_2 as 00. Its residual on the training inputs is 00, so both gradients are 00, nothing moves, and the identity B0⊤v=B∗⊤v∗B_0^\top v = B_\ast^\top v_\ast holds at every input.

∎

Part (c) is the easy half of Kumar and colleagues’ Proposition 3.7. The hard half, which we cite, is their Theorem 3.3: from a head that does not already fit, fine-tuning changes the features on SS while leaving them fixed off it, so the head it learns no longer matches the features of inputs off SS, and the out-of-distribution error is bounded below. Their remedy is LP-FT: fit the probe first, then fine-tune everything from there. On a toy of their form, with d=10d = 10, k=2k = 2, and a training span of dimension 44, the features never move off the span (5×10−155 \times 10^{-15} at most), and the out-of-distribution loss stays at 1.6×10−311.6 \times 10^{-31} from the probe’s head but reaches 6.856.85 from a random one.

On the encoder, part (b) is exact. The training rows leave 419419 of the 880880 token rows unseen; full fine-tuning moves exactly the other 461461 and none of the 419419, and LoRA moves no embedding at all. Part (a) is a gradient-descent fact. On a linear toy, SGD leaves the component of the update off the span at 2×10−152 \times 10^{-15}, and Adam, with the same data, at 1.0081.008.

Forgetting is what fine-tuning does to the pretrained skill, and we measure it as the rise of held-out masked-LM loss on test filings, from 1.5231.523 for the pretrained encoder. Full fine-tuning ends at 2.5532.553 to 2.7592.759 over three seeds. LP-FT, from the probe’s head, ends at 1.8891.889 to 1.9651.965 while reading 0.9750.975 to 0.9810.981, within a point of full fine-tuning on average (means 0.9770.977 and 0.9830.983; full fine-tuning spreads over 0.9700.970 to 0.9890.989) and with less than half its forgetting. LoRA ends at 5.2085.208 to 5.7055.705 while reading only 0.9110.911 to 0.9560.956.

That ranking seems to contradict Biderman and colleagues (2024), who found on Llama-2-7B that LoRA learns less and forgets less. Here it learns less and forgets more, but LoRA runs at ten times full fine-tuning’s rate (Biderman and colleagues report the same gap in their best rates). Run the two at a shared rate and the ranking turns around. At full fine-tuning’s 10−310^{-3}, LoRA reads 0.8640.864 to 0.8800.880 and ends at 2.0332.033 to 2.3382.338, under full fine-tuning’s 2.5532.553 to 2.7592.759. At 3×10−33 \times 10^{-3}, full fine-tuning reads 0.9840.984 to 0.9970.997 and ends at 4.0114.011 to 4.4314.431; LoRA reads 0.9160.916 to 0.9480.948 and ends at 2.7292.729 to 3.3033.303. At LoRA’s 10−210^{-2}, full fine-tuning reads 0.9680.968 to 0.9890.989 and ends at 5.6615.661 to 6.3736.373, over LoRA’s 5.2085.208 to 5.7055.705. In all nine seed-matched pairs, LoRA learns less and forgets less, which is the direction Biderman and colleagues found. Update size does not explain it: confined to the query and value maps, LoRA moves them by ∥s AB∥F=45.1\lVert s\,AB \rVert_F = 45.1 at rank 1616, where full fine-tuning at 10−310^{-3} moves the same four matrices by 2.692.69 and at 10−210^{-2} by about 1515, while full fine-tuning, which forgets more at the shared rate, moves every other matrix too. LP-FT, at its own rate, forgets less than every LoRA run at every rate, and every LoRA run in the main grid is beaten by every LP-FT run on both counts.

A third way to keep the pretrained skill is to penalize distance from it.

Proposition 3 (L2-SP is a prior at the pretrained weights).

The penalty λ2∥θ−θ0∥2\tfrac\lambda2\lVert\theta - \theta_0\rVert^2 is −log⁡N(θ; θ0,λ−1I)-\log N(\theta;\, \theta_0, \lambda^{-1}I) up to a constant, so the penalized optimum is the MAP estimate under that prior. For a quadratic loss 12(θ−θ∗)⊤H(θ−θ∗)\tfrac12(\theta - \theta_\ast)^\top H(\theta - \theta_\ast), the penalized optimum is

θ^=θ0+(H+λI)−1H (θ∗−θ0),\hat\theta = \theta_0 + (H + \lambda I)^{-1} H\,(\theta_\ast - \theta_0),

which shrinks the full displacement θ∗−θ0\theta_\ast - \theta_0 by h/(h+λ)h/(h + \lambda) along each eigenvector of HH with eigenvalue hh.

Proof.

The Gaussian log-density is −λ2∥θ−θ0∥2-\tfrac\lambda2\lVert\theta - \theta_0\rVert^2 plus a constant. Setting the gradient H(θ−θ∗)+λ(θ−θ0)H(\theta - \theta_\ast) + \lambda(\theta - \theta_0) to 00 gives (H+λI)(θ−θ0)=H(θ∗−θ0)(H + \lambda I)(\theta - \theta_0) = H(\theta_\ast - \theta_0). In the eigenbasis of HH both matrices are diagonal.

∎

The first statement is Theorem 5 of formalStatistics’ regularization-and-penalized-estimation, and the shrinkage is its Remark 4 on ridge seen through the SVD, here centered at θ0\theta_0 instead of 00. Li, Grandvalet, and Davoine (2018) introduced the penalty as L2-SP; they also penalize the new head toward 00, which we do not. Elastic weight consolidation (Kirkpatrick and colleagues 2017) replaces λI\lambda I by the Fisher information, the metric of formalML’s information-geometry. L2-SP trades accuracy for retention: λ=0.1\lambda = 0.1 reads 0.9050.905 with loss 1.7121.712, and λ=1\lambda = 1 reads 0.7570.757 with loss 1.5431.543. Full fine-tuning at three-tenths of its rate reads 0.9200.920 with loss 1.8151.815. LP-FT gets the retention without that price. The Learning vs. forgetting tab plots every run on these two axes.


Two lenses on why a small update suffices

LoRA restricts the update to a small set. Two older ideas explain why a small set can be enough, and both can be checked on this encoder.

A random subspace. Li and colleagues (2018) trained networks inside a random subspace, θ=θ0+Sz\theta = \theta_0 + Sz for a fixed P×DP \times D matrix SS and trained z∈RDz \in \mathbb R^D, and called the least DD that reaches 9090 percent of ordinary training the intrinsic dimension. Aghajanyan, Gupta, and Zettlemoyer (2021) measured it for fine-tuning and found that pretraining lowers it. We use the cheapest such SS.

Proposition 4 (A random subspace step is unbiased).

Let S∈RP×DS \in \mathbb R^{P \times D} have exactly one nonzero entry in each row, εp=±1\varepsilon_p = \pm 1 with equal probability, in a column h(p)h(p) uniform on {1,…,D}\lbrace 1, \dots, D\rbrace, all independent. Then (SS⊤)pp=1(SS^\top)_{pp} = 1, E[SS⊤]=I\mathbb E[SS^\top] = I, and for any gradient gg, E∥S⊤g∥2=∥g∥2\mathbb E\lVert S^\top g\rVert^2 = \lVert g \rVert^2. A gradient step in zz, Δθ=−η SS⊤g\Delta\theta = -\eta\, SS^\top g, is the full step in expectation.

Proof.

(SS⊤)pq=εpεq [h(p)=h(q)](SS^\top)_{pq} = \varepsilon_p \varepsilon_q\, [h(p) = h(q)]. On the diagonal this is εp2=1\varepsilon_p^2 = 1. Off it, εpεq\varepsilon_p\varepsilon_q has mean 00 and is independent of the indicator. Then E∥S⊤g∥2=g⊤ E[SS⊤] g=∥g∥2\mathbb E\lVert S^\top g \rVert^2 = g^\top\, \mathbb E[SS^\top]\, g = \lVert g\rVert^2, and the step’s mean is −η E[SS⊤]g=−ηg-\eta\, \mathbb E[SS^\top] g = -\eta g.

∎

This is the structure of Theorem 1(c) again, a random map whose mean is the identity. Li and colleagues normalize the columns of SS instead, and Aghajanyan and colleagues use the Fastfood transform with learned per-layer scales, and under Adam a column’s scale acts as its learning rate: scaling a column by cc scales its gradient in zz by cc, which Adam’s step in zz removes, so θ\theta moves cc times as far. The ±1\pm 1 entries here move every parameter at one rate. Inside subspaces of dimension 6464, 512512, and 4,0964{,}096, out of 157,568157{,}568 encoder parameters, the pretrained encoder reads 0.7540.754, 0.8200.820, and 0.8700.870, and the never-pretrained one 0.7220.722, 0.7860.786, and 0.8230.823. Neither reaches 9090 percent of its own full fine-tuning (0.8850.885 and 0.8560.856) on this grid, so both intrinsic dimensions exceed 4,0964{,}096. The pretrained encoder leads at every dimension tried, which is Aghajanyan and colleagues’ direction, measured.

A kernel. Near its starting point a network is close to its linearization, flin(x;θ)=f(x;θ0)+J(x)(θ−θ0)f_{\text{lin}}(x; \theta) = f(x; \theta_0) + J(x)(\theta - \theta_0), where J(x)J(x) is the Jacobian of the outputs at θ0\theta_0.

Proposition 5 (Linearized fine-tuning is kernel gradient descent).

Let K=J(X)J(X)⊤K = J(X)J(X)^\top over training pairs (example, output), K(x,X)=J(x)J(X)⊤K(x, X) = J(x)J(X)^\top, and let ℓ\ell be any differentiable loss of the training outputs. Gradient descent on θ\theta for flinf_{\text{lin}} with rate η\eta moves the outputs by

f(X)←f(X)−η K ∇fℓ,f(x)←f(x)−η K(x,X) ∇fℓ.f(X) \leftarrow f(X) - \eta\, K\, \nabla_f \ell, \qquad f(x) \leftarrow f(x) - \eta\, K(x, X)\, \nabla_f \ell.

For squared loss, ft(X)−Y=(I−ηK)t (f0(X)−Y)f_t(X) - Y = (I - \eta K)^t\,(f_0(X) - Y).

Proof.

The gradient of ℓ(flin(X;θ))\ell(f_{\text{lin}}(X; \theta)) in θ\theta is J(X)⊤∇fℓJ(X)^\top \nabla_f\ell, so a step moves θ\theta by −ηJ(X)⊤∇fℓ-\eta J(X)^\top \nabla_f \ell, and since flinf_{\text{lin}} is affine in θ\theta, any output moves by J(⋅)J(\cdot) times that. For squared loss, ∇fℓ=f(X)−Y\nabla_f\ell = f(X) - Y, and the recursion is linear.

∎

Corollary 1 (LoRA's kernel).

At B=0B = 0, LoRA’s kernel over its trained factors is KLoRA(x,x′)=s2∑Wtr⁡(Gx⊤A0A0⊤Gx′)K_{\text{LoRA}}(x, x') = s^2 \sum_W \operatorname{tr}\big(G_x^\top A_0A_0^\top G_{x'}\big), summed over the adapted matrices, where GxG_x is the gradient of an output at xx with respect to WW. Its mean over A0A_0 is s2rσ2s^2 r\sigma^2 times the kernel of the adapted matrices themselves.

Proof.

By Theorem 1(a), at B=0B = 0 an output’s gradient in AA is 00 and in BB is s A0⊤Gxs\,A_0^\top G_x, so the kernel is ∑W⟨s A0⊤Gx, s A0⊤Gx′⟩\sum_W \langle s\,A_0^\top G_x,\ s\,A_0^\top G_{x'}\rangle. Its mean follows from E[A0A0⊤]=rσ2I\mathbb E[A_0A_0^\top] = r\sigma^2 I (Theorem 1(c)).

∎

The kernel is the neural tangent kernel of Jacot, Gabriel, and Hongler (2018). Malladi and colleagues (2023) asked when fine-tuning a language model behaves like gradient descent with it, found that prompt-based fine-tuning often does, and proved that LoRA’s kernel is close to the full one with high probability (their Theorem 7.2), the concentrated form of Corollary 1. The lazy-training section of formalML’s double-descent is the regime in general.

A zero head has a zero Jacobian, so we linearize LoRA (rank 1616, query and value maps) around LP-FT’s start, the probe’s head held fixed, on 120120 training rows. Kernel gradient descent and the real LoRA model trained by full-batch gradient descent for 300300 steps agree on 0.9920.992 of 240240 test rows, end at training losses 0.59900.5990 and 0.59890.5989, and the kernel moves by 6.56.5 percent. But at a stable rate, gradient descent barely trains: the loss falls only from 0.6200.620. Adam, from the same start, drives the training loss to 5.2×10−55.2 \times 10^{-5}, its kernel moves by 169169 percent, it agrees with the kernel predictor on 0.6580.658 of test rows, and its test accuracy falls from 0.7670.767 to 0.6210.621. Malladi and colleagues describe Adam’s early steps with a kernel built from signs; on 120120 rows, Adam does not stay in any kernel regime for long.


Reading negation in filings


Where this sits

LoRA is one of a family of parameter-efficient methods. Adapters (Houlsby and colleagues 2019) insert small trained modules instead of correcting the weights, and the methods differ in where the small set lives, not in the questions this page asked of it. The page’s answers on one toy encoder:

  • the factored step is a random sketch of the full one;
  • the factors are balanced only under gradient descent;
  • the full update is nearly low-rank but spread over every matrix, where LoRA’s class cannot hold it;
  • probe-first fine-tuning keeps what pretraining learned better than LoRA does, and at a shared rate LoRA forgets less than full fine-tuning.

Sun, Huang, and Qiu (2019) gave the encoder the aspect as a second sentence. Our reader takes the aspect’s own contextual states instead, which fits Topic 19’s definition and read better than a pair input averaged over every position when we prototyped both. The extraction topics fine-tune the same kind of encoder for span labeling, and formalRAG’s dense-retrieval-dual-encoders bounds the rank of a dual encoder’s scores, where this page bounded the rank of an update.


Honest caveats


Implementation

The companion notebook (notebookPath) imports fine_tuning_low_rank_adaptation.py, which owns every number on this page. That module imports the masked-LM topic’s module for the encoder, its training run, its corruption channel, and its vocabulary. It imports the aspect sentiment topic’s module for the aspect rows, the constructions, the contrast sets, the tone-bearing sentences, and, through it, the linear classifiers topic’s Newton solver and the document baselines. The encoder’s backward pass is lifted from the masked-LM training loop and pinned equal to it, and its attention is rewritten as flattened matrix products, pinned equal to the transformer topic’s. The harness checks:

  • every gradient against central differences;
  • Theorem 1’s identities exactly, its means and the fluctuation law by Monte Carlo, and Adam’s bounds on random instances;
  • Theorem 2’s one-step identity and its drift’s order;
  • Proposition 3’s shrinkage, Proposition 4’s moments, and Proposition 5 and Corollary 1 on random linear models;
  • Theorem 3 on the linear toys and, for the embeddings, on every fine-tuning run;
  • every comparison this page states, across the 4242 fine-tuning runs, including both methods at three shared rates, the truncations at every seed and inside LoRA’s class, and what the encoder calls the deleted-”not” copies.

The laboratory reads its data from a JSON file that one of the harness’s tests requires to equal the module’s viz_payload() exactly, so the figure cannot drift from the code.

Connections

  • Topic 19's single attention layer cannot read negation (its Theorem 1(c)); the fine-tuned encoder here is the deep escape that topic pointed to, scored on its aspect rows and its negation quadruples. aspect-based-sentiment

References & Further Reading