Taking a pre-trained model and updating its weights after the fact usually for cases where the task isnβt exactly what itβs designed for.
Say you have weights in for a given model,
Updating the weights is just:
The most naive way of doing this is just making the gradients flow again through the entire learned network, but thatβs expensive and sometimes unnecessary.
LoRA
Making the reasonable assumption that the model has learned something useful from the pre-training step and the domain weβre adapting to is a minimal change from the domain it was trained forβ¦ itβs fair to say that we donβt need to update all the weights of the network.
So letβs learn a factorization for into two matrices of size and , A and B where
Update only and and keep W frozen.
The parameter savings are pretty clear.
- Complete fine-tuning - parameter updates
- LoRA - parameter updates
After training, itβs straightforward to add directly to and not maintain a separate pair of matrices during inference.
Whatβs the tradeoff? Reasoning about it, your choice of constrains the search down to a subspace of rank() within the weight space. is now a low rank matrix. Given the assumption that we donβt need to explore the entire weight space because weβre working from a solid pre-trained model, this works.
Original LoRA paper - https://arxiv.org/abs/2106.09685