Skip to content
AI & Machine Learning

LoRA (Low-Rank Adaptation)

Definition

LoRA is a cheap way to fine-tune a large model: the original weights stay frozen and only small added matrices are trained. A LoRA adapter is a tiny file compared with the model, so one base model can serve many customized versions.

Diagram

How LoRA fine-tunes a modelA 4,096 by 4,096 weight matrix with about 16.8 million values stays frozen. Two thin matrices, 4,096 by 8 and 8 by 4,096, are trained instead, 65,536 values in all, and their product is added to the frozen matrix.Wfrozen4,096 × 4,096+B×A4,096 × 8 and 8 × 4,096, trainedTRAINED65,536values, not16,777,216
For this one layer, LoRA trains 0.39% of the values a full fine-tune would. The two thin matrices are the adapter: a small file you can store per customer or per task and swap in on top of the same base model. A higher rank (here 8) gives the adapter more room to learn, at a larger size.

Case study

Worked example