4.3.9 · D3Pretraining & Fine-Tuning LLMs

Worked examples — Adapter layers and prefix tuning

2,054 words9 min readBack to topic

Symbols we reuse (all defined in the parent, restated so line one stands alone):

  • = hidden dimension (width of a token's vector). Picture a column of numbers.
  • = adapter bottleneck dimension, the squeezed middle width. means "much smaller".
  • = number of transformer layers stacked top to bottom.
  • = adapters inserted per layer.
  • = prefix length = number of learned fake tokens prepended.
  • = real sequence length (how many actual words).
  • Adapter params · Prefix params .

The scenario matrix

Cell Case class Covered by
C1 Adapter, normal regime Ex 1
C2 Adapter, degenerate Ex 2
C3 Adapter, saturated (no saving) Ex 3
C4 Adapter, removed (rank collapse) Ex 4
C5 Prefix, normal small Ex 5
C6 Prefix, degenerate Ex 5
C7 Prefix, limiting large (compute blow-up) Ex 6
C8 Head-to-head: pick cheaper method Ex 7
C9 Real-world serving-cost word problem Ex 8
C10 Exam twist: init-to-identity failure Ex 9

Each example below is tagged with the cell(s) it fills.


Adapter examples





Prefix examples




Word problem & exam twist



Recall Quick self-test over the matrix

Adapter params for ? ::: M ( of a 350M backbone). What does produce? ::: The exact identity, zero trainable params. Above which does an adapter cost more than a full map? ::: . Rank of a -less adapter correction with ? ::: At most 16 (rank collapse). Prefix params for ? ::: . Attention-work ratio going at ? ::: (quadratic ). Disk saving serving 100 customers, PEFT vs full FT? ::: less. Why init ? ::: Makes so the adapter starts as exact identity, preserving pretrained behaviour.