Concept
Low-rank adaptation
A way to change a large model by training a small pair of low-rank matrices added to its layers, instead of changing all of its weights.
Instead of rewriting a whole textbook for a new course, you clip in a short set of extra pages. Low-rank adaptation changes a large model in the same economical way.
How it works
LoRA freezes the pretrained weights and adds, to each layer, a pair of thin matrices that are trained. Their product has the same shape as the layer’s weights but far fewer free numbers, which is what “low rank” means. Hu and colleagues (2021) report that, compared with fine-tuning GPT-3 175B with the Adam optimiser, LoRA can reduce the number of trainable parameters by 10,000 times and the GPU memory needed by 3 times, with quality on par with or better than full fine-tuning on the models they tested, and no extra delay when the model runs.
Aghajanyan and colleagues (2021) offer a reason why so little change can be enough: analysing fine-tuning through the lens of intrinsic dimension, they argue that it can be done in a low-dimensional space. QLoRA (Dettmers and colleagues, 2023) trains such adapters on top of a frozen model stored with 4-bit numbers, and fine-tunes a 65-billion-parameter model on a single 48 GB GPU while preserving the performance of 16-bit fine-tuning.
Where it misleads
A low-rank update is a restriction. “On par” was measured on certain models and tasks, and a change that needs many independent directions may not fit in a thin update. The small size also makes it easy to stack many adapters on one base model, with each one a new set of behaviours to test. Another way of changing behaviour with a tiny change is described in the site’s essay on editing two neurons.
Sources
- Hu, E. J. et al. (2021). LoRA: Low-Rank Adaptation of Large Language Models. ICLR 2022.
- Aghajanyan, A., Zettlemoyer, L., Gupta, S. (2021). Intrinsic Dimensionality Explains the Effectiveness of Language Model Fine-Tuning. ACL 2021.
- Dettmers, T., Pagnoni, A., Holtzman, A., Zettlemoyer, L. (2023). QLoRA: Efficient Finetuning of Quantized LLMs. NeurIPS 2023.
Relations
- related to