Introduction: the universal factorization
The eigendecomposition is powerful, but it only works on square matrices. In ML, matrices are rarely square: a dataset of , a weight matrix of , an embedding matrix of .
The SVD (Singular Value Decomposition) is the generalization that works for any matrix, regardless of its shape. It's probably the most important factorization in all of applied linear algebra.
The intuition: rotation, stretching, rotation
Any linear transformation (matrix) can be decomposed into three simple steps:
- Rotation (or reflection) in the input space
- Stretching (or compression) along the axes
- Rotation (or reflection) in the output space
Imagine you take a circle and apply a matrix to it. The circle becomes an ellipse. The SVD tells you exactly: which rotations, and which stretches. It's a complete X-ray of the transformation.

The formula
For any matrix , the SVD is:
Where:
- is an orthogonal matrix (its columns are the left singular vectors)
- is a diagonal matrix containing the singular values (ordered by decreasing value)
- is an orthogonal matrix (its rows are the right singular vectors)
The number is the rank of the matrix, the number of nonzero singular values.
What each component represents
- : the first rotation. It identifies the important directions in the input space.
- : the stretching. Each singular value tells how much the transformation stretches in the -th direction.
- : the second rotation. It places the result in the output space.
Concrete example
Take a simple matrix:
This matrix stretches the horizontal axis by 3 and leaves the vertical axis unchanged. Its SVD is trivial:
- , (no rotation needed)
- ,
For a more complex matrix, the rotations and are nontrivial, but the idea remains the same: we decompose the transformation into its elementary components.
Connection with eigenvalues
SVD and eigendecomposition are closely related:
-
The singular values of are the square roots of the eigenvalues of :
-
The right singular vectors (columns of ) are the eigenvectors of
-
The left singular vectors (columns of ) are the eigenvectors of
For a symmetric positive semi-definite matrix, SVD coincides with the eigendecomposition.
The advantage of SVD: singular values are always real and non-negative, even when the eigenvalues of are complex or negative.
Low-rank approximation
This is where SVD becomes truly powerful for ML.
The Eckart-Young theorem
The rank- approximation of is obtained by keeping only the largest singular values:
This theorem says: among all rank- matrices, is the best approximation of (in terms of the Frobenius norm or spectral norm).
The approximation error is:
If the singular values decay quickly, you can approximate the matrix with very few components. A matrix of rank 5 can be reconstructed exactly with only numbers instead of .
Applications in machine learning
LoRA: efficient adaptation of LLMs
LoRA (Low-Rank Adaptation) is directly inspired by SVD. The idea: when you fine-tune a large language model, the weight changes are often low-rank, they only affect a few directions in parameter space.
Instead of modifying the full matrix (millions of parameters), you learn:
Where and with (typically or ).
It's a low-rank approximation. Instead of storing parameters, you only store . For and , you go from 16 million to 131,000 parameters. A compression factor of 120.

Dimensionality reduction
Like PCA (which is a special case of SVD applied to centered data), SVD allows reducing the dimensionality of data by keeping only the most important components.
Truncated SVD is often preferred over classical PCA because it's more computationally efficient for large sparse matrices.
Image compression
A grayscale image is an matrix. Its SVD gives components. By keeping only the first (), you get a compressed version that preserves the main structures (shapes, contrasts) while eliminating noise and fine details.
The compression ratio is approximately .

Recommendation systems
Netflix, Spotify, and recommendation engines use matrix factorization, a cousin of SVD. The user-movie matrix (with many empty entries) is approximated by a product of two low-rank matrices:
The rows of are the "latent profiles" of users, the columns of are the "latent profiles" of movies. The product predicts missing ratings.
Embeddings and Latent Semantic Analysis
LSA (Latent Semantic Analysis) applies SVD to the term-document matrix to discover "latent concepts." Words that appear in similar contexts end up close in the reduced space. It's an ancestor of modern embeddings like Word2Vec.
SVD in practice
In Python with NumPy:
import numpy as np
# Full SVD
U, S, Vt = np.linalg.svd(A)
# Rank-k approximation
A_k = U[:, :k] @ np.diag(S[:k]) @ Vt[:k, :]
For large sparse matrices, you use the truncated SVD from scipy.sparse.linalg.svds or sklearn.decomposition.TruncatedSVD, which only compute the first components, much faster.
Why this matters for AI
SVD is a cross-cutting tool in ML:
- LoRA makes fine-tuning LLMs accessible to everyone through low-rank approximations
- Model compression reduces size and inference cost
- Matrix factorization powers recommendation systems
- Dimensionality reduction allows visualizing and denoising data
When you see a concept of "low-rank" or "factorization" in ML, SVD is never far away. It's the tool that says: this gigantic matrix can be well approximated by something much smaller. And in ML, smaller often means faster, cheaper, and sometimes even better.
Where this is used. The low-rank approximation described here is the entire idea behind LoRA.