For a frozen weight W0 of shape d by k, LoRA learns two small matrices: B (d by r) and A (r by k), with rank r much smaller than d and k.
The forward pass becomes h = W0 x + (alpha / r) x B(A x). A is initialized randomly and B to zero, so the adapter starts as a no-op and training begins from the base model's behavior.
Only A and B receive gradients, which cuts trainable parameters and optimizer memory sharply.
After training you can merge B times A into W0 for zero extra inference latency, or keep adapters separate and swap them per task.
Loading…