Lensa ML
Lensa ML

Singular Value Decomposition

Step 1 of 6

What SVD Does

Any matrix = rotate, scale, rotate — decomposed into UΣVᵀ

A[1,2] matrix element1.00
v₁v₂A = UΣVᵀ
σ₁
2.558
σ₂
0.977
σ₁/σ₂
2.62

The unit circle (dashed) transforms into an ellipse. SVD reveals that ANY matrix = rotate (Vᵀ) → scale (Σ) → rotate (U). The pink and purple arrows show the principal axes.

Step 1 of 6: What SVD Does

Any matrix = rotate, scale, rotate — decomposed into UΣVᵀ

A[1,2] matrix element1.00
v₁v₂A = UΣVᵀ
σ₁
2.558
σ₂
0.977
σ₁/σ₂
2.62

The unit circle (dashed) transforms into an ellipse. SVD reveals that ANY matrix = rotate (Vᵀ) → scale (Σ) → rotate (U). The pink and purple arrows show the principal axes.

Step 2 of 6: U, Σ, V Separately

Watch each component's role: Vᵀ rotates, Σ scales, U rotates

Decomposition phase0.00
A = U · Σ · VᵀVᵀ (Rotate)
PHASE
Vᵀ (Rotate)
σ₁
2.558
σ₂
0.977

Phase 1: Vᵀ rotates the input into the 'natural basis' of the matrix. The circle stays circular — only the coordinate system changes.

Step 3 of 6: Singular Values

σ₁ and σ₂ control how much the matrix stretches each axis

σ₁/σ₂ ratio3.00
σ₁=2.0σ₂=0.67
σ₁
2.00
σ₂
0.67
RATIO σ₁/σ₂
3.0
AREA RATIO
1.33

σ₁ is 3.0× larger than σ₂. The matrix amplifies one direction more than the other. The condition number (σ₁/σ₂) measures how 'skewed' the transformation is.

Step 4 of 6: Low-Rank Approximation

Keep the top-k singular values, discard the rest

Rank k (of 8)5
8.0σ14.0σ22.7σ32.0σ41.6σ51.3σ61.1σ71.0σ8Keep top-5 singular values95.8% energy retained
RANK k
5
ENERGY %
95.8%
PARAMS (full)
64
PARAMS (k)
80

Rank 5 captures 95.8% of the matrix's energy with only 80 parameters (vs 64 full). The discarded singular values were small — little information lost.

Step 5 of 6: SVD and PCA

SVD of centered data gives you principal components for free

Number of components2
PC1PC2SVD of centered data = PCA
COMPONENTS
2
EXPLAINED
100.0%
σ₁²
1.16
σ₂²
0.09

With both components, reconstruction is perfect. PCA via SVD: center the data, compute SVD of the data matrix, and the right singular vectors ARE the principal components.

Step 6 of 6: SVD in ML

LoRA, compression, and recommender systems all rely on low-rank structure

Compression ratio (d/r)4
W (64×64)4096 paramsB (64×16)·A (16×64)2048 params (50% saved)
FULL PARAMS
4,096
LORA PARAMS
2,048
RANK r
16
SAVINGS
50%

4× compression — rank 16 uses only 2048 parameters vs 4096 full. This is the sweet spot for LoRA fine-tuning: enough rank to capture task-specific changes, huge memory savings.