Toggle search
Search
Toggle menu
notifications
Toggle personal menu
Editing
LoRA
(section)
From llamawiki.ai
Views
Read
Edit
Edit source
View history
associated-pages
Page
Discussion
More actions
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Technical Description == The key idea behind LoRA is to represent the update to the pretrained weights as low rank matrices that are injected into the original model. For a given layer with original weight matrix <math>W</math> in <math>\mathbb{R}^{d \times k}</math> (i.e. a set of <math>d \times k</math> [[wikipedia:real number|real numbers]] typically represented as 16-bit floating point numbers), the low rank update is represented as: <math>\Delta W = BA</math> where <math>B</math> in <math>\mathbb{R}^{d \times r}</math> and <math>A</math> in <math>\mathbb{R}^{r \times k}</math> with rank r much less than the smaller of d and k (i.e. <math>r << min(d,k)</math>). In this way a large matrix is represented as the product of two much smaller matrices, greatly reducing the amount of data involved. During training, the original weight matrix <math>W</math> is frozen and only <math>B</math> and <math>A</math> are trained, which dramatically reduces the number of trainable parameters. The forward pass is computed as: <math>Y = XW + \alpha X A B</math> where <math>X</math> is the input to the layer. The scalar <math>\alpha</math> controls the magnitude of the low rank update. This allows adapting a huge pretrained model using only 0.01% additional trainable parameters stored in B and A. Since W remains fixed, LoRA does not add any inference latency or memory overhead.
Summary:
Please note that all contributions to llamawiki.ai may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
LlamaWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)