Linear algebra for LLMsPart 7: Decompositions and low rank
Low-rank approximation
6 min
The SVD is a sum of rank-1 pieces
written as a sum of outer products: Part 2’s fourth view of a matrix product. Each piece is rank 1, and they come sorted from the biggest down.
Write
Our two pieces
carries most of ; the second piece is the correction.
Keep the top
Eckart–Young theorem: truncating the SVD gives the best rank- approximation there is, measured in the Frobenius or the spectral norm. No other rank- matrix is closer.
Write
How much you lose
The error is exactly the singular values you dropped. Here the first piece keeps of the “energy” .
Write
Storage
If the singular values fall off fast, a few directions hold most of the matrix, and storing two thin factors is far cheaper.
✏️ Your turn
Rank-1 approximation
Write .
Work it out on paper, then go to the next card to check.
Answer
Every column is a multiple of , every row a multiple of : rank 1.
Where low rank shows up
In a transformer
- LoRA learns a low-rank update to a weight (next deck).
- Compression: replacing a weight by a truncated SVD shrinks it, at some cost in accuracy.
- Attention heads are low-rank by construction (Part 3).
- Measuring the singular values of weights or activations is a standard way to see how many directions really matter.
📌 Recap
Low-rank approximation in one card
- , sorted by .
- Truncating to terms is the best rank- approximation.
- Error: .
- Storage: .
Write