Store an update as two smaller matrices#
LoRA represents a weight update using two low-rank matrices. In this example, inputs are row vectors: y = x @ W, ΔW = A @ B, and the adapted matrix is W + ΔW. The base matrix remains available.
Inspect the update#
Python · NumPy
Ready to run
Output
Run the code to see its output.
Try this: Change one entry of A or B. Compare the update matrix and the output before and after adaptation.
Runs in your browser. Ctrl/⌘ + Enter runs the code.
An adapter needs its base#
The adapter stores the change, not the complete network. Its dimensions and target layers must match the base model. A weight generator can produce these adapter parameters instead of producing an entire model.