Change a giant model through a narrow update.

LoRA freezes the original weight matrix and learns two small factors whose product becomes the task-specific update. Change rank, scale, and data, then inspect capacity, memory, and approximation in 3D.

Open the matrix lab

Fine-tuning can travel through a bottleneck.

A dense d×k update has d·k degrees of freedom. LoRA assumes useful adaptation lies in a lower-dimensional subspace, representing the update as B·A with rank r. The base model stays shareable while small adapters carry specialized behavior.

Frozen W · adapter initialized near zeroDrag to orbit · wheel to zoom
frozen Wlow-rank ΔWresidual
Trainable parameters131K

r(d+k) for a 4096×12288 projection.

Fraction of dense update0.26%

Adapter parameters divided by d·k.

Modeled fit0%

Target update energy captured by rank r.

Adapter memory FP160.25 MB

Trainable factors only, before optimizer states.

Freeze the pretrained map

The original weight W continues to transform the input. Gradients do not update W, preserving the reusable base checkpoint and reducing optimizer state.

h = W x + ΔW x

Learn two thin matrices

A projects the input into r adapter coordinates; B projects those coordinates back to the output dimension. Rank limits the update's independent directions.

ΔW = (α / r) B A

Merge or swap at inference

The product can be added into W for zero adapter lookup overhead, or kept separate so one base model can serve many small task adapters. Multiple adapters are not automatically compositional; their updates may interfere.

W′ = W + (α / r) B A

Rank too low

The bottleneck cannot express all useful update directions. Training plateaus with structured residual energy.

Inspect fit before increasing epochs.

Scale too high

Large α/r amplifies the adapter, potentially overwriting useful base behavior or destabilizing optimization.

Tune learning rate and scale together.

Data too narrow

A capable adapter can memorize examples while failing outside their wording and distribution.

Validate invariance, not training loss alone.

Primary reading

LoRA: Low-Rank Adaptation of Large Language Models Hu et al.QLoRA: Efficient Finetuning of Quantized LLMs Dettmers et al.DoRA: Weight-Decomposed Low-Rank Adaptation Liu et al.LoRA+: Efficient Low Rank Adaptation Hayou et al.