liveBook · Manning

Low-rank approximation

As explained in Deep Learning with R, Third Edition

A low-rank decomposition represents a matrix transformation as a product of smaller matrices with an intermediate dimension lower than the original matrix dimensions.

Represents a large matrix transformation as two smaller projections with a narrow intermediate dimension. In LoRA, the original kernel stays frozen while the low-rank update learns task-specific changes with far fewer trainable parameters. section 16.3.3

A 2,048 × 2,048 projection with rank 8

A full kernel contains 4,194,304 parameters. Replacing its trainable update with projections of shapes 2,048 × 8 and 8 × 2,048 uses 32,768 parameters. The narrow rank-8 middle limits expressive power, but can be sufficient for fine-tuning after pretraining. The resulting transformation combines the frozen projection with the learned update. section 16.3.3

LoRA applies the approximation operationally by:

  • Freezing most Transformer parameters and adding low-rank weights to attention projections. section 16.3.3
  • Reducing trainable storage, gradients, and optimizer-state memory while retaining the full model parameters. section 16.3.3

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains the frozen-plus-update construction, parameter arithmetic, implementation, and expressive-power trade-off.
Examples
Uses a 2,048 × 2,048 kernel with rank 8, an R layer implementation, and KerasHub configuration for Gemma.
What it assumes
Builds from a simple linear projection and assumes familiarity with Transformer layers and pretrained-model fine-tuning.
What you can do after
Operate/configure LoRA through KerasHub and selectively enable rank-8 adapters on attention layers.
How it connects
Connects matrix transformations, linear projections, Transformer attention, fine-tuning, gradients, and optimizer state.

Also explained in

Compare how 3 books explain low-rank approximation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.