liveBook · Manning

Low-rank adaptation

As explained in Deep Learning with R, Third Edition

Low-rank adaptation is a parameter-efficient fine-tuning technique that freezes a model's original weights and trains a low-rank update to selected projections.

Low-rank adaptation (LoRA) reduces fine-tuning memory use by freezing a model’s original weights and training a compact low-rank update to selected projections. section 16.3.3

A smaller update

For a 2,048 × 2,048 kernel, the frozen weights number 4,194,304. A rank-8 update uses two smaller matrices with 32,768 parameters in total. In KerasHub, LoRA can be enabled on a model backbone with `enable_lora(rank = 8L)`. section 16.3.3

Listing 16.13 Enabling LoRA training for a KerasHub model
gemma_lm$backbone$enable_lora(rank = 8L)

See the KerasHub call for enabling LoRA on a model backbone. section 16.3.3

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains frozen kernels, low-rank updates, parameter counts, and selective attention projections.
Examples
Uses a 2,048-square kernel, a rank-8 update, and KerasHub model configuration.
What you can do after
Apply LoRA through KerasHub or enable it on selected attention projections.
How it connects
Connects fine-tuning with Transformer attention projections and accelerator memory use.

Also explained in

Compare how 9 books explain low-rank adaptation →

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.