What is singular value decomposition (SVD)?
Singular value decomposition factors any real matrix A into three pieces, A = UΣVᵀ. U and V are orthogonal matrices, which only rotate or reflect, and Σ is a diagonal matrix of non-negative singular values sorted from largest to smallest. Every matrix has an SVD, including rectangular ones, which is not true of eigendecomposition.
In machine learning, SVD is behind principal component analysis (PCA), low-rank compression, recommender systems, latent semantic analysis, and the reasoning behind LoRA fine-tuning. The singular values also tell you a matrix's rank and how numerically stable it is to work with.
Key ideas
- Every matrix factors as A = UΣVᵀ: rotate, scale along the axes, rotate.
- Singular values are non-negative, sorted, and unique for a given matrix.
- The number of nonzero singular values is the rank.
- Keeping the top k singular values gives the best rank-k approximation.
- PCA on centered data is an SVD of the data matrix.
- Low-rank structure is what makes compression, recommenders, and LoRA work.
Common questions
Are singular values the same as eigenvalues?
Not in general. The singular values of A are the square roots of the eigenvalues of AᵀA. They match the eigenvalues only for symmetric matrices with non-negative eigenvalues. Eigenvalues can be negative or complex; singular values are always real and non-negative.
What does a zero singular value mean?
The matrix flattens at least one direction completely, so it is not full rank and cannot be inverted. The right singular vectors that go with zero singular values span the null space: the inputs the matrix sends to zero.
Is the SVD unique?
The singular values are. The singular vectors are unique up to a sign flip when the singular values are all different. If two singular values are equal, any rotation of their vectors within that plane is also a valid SVD.
How is SVD computed in practice?
Libraries such as NumPy and PyTorch call LAPACK routines, which reduce the matrix to a simpler form and then iterate. For an m×n matrix with m ≥ n the cost is O(mn²). For very large matrices where only the top k values are needed, randomized SVD computes them much faster.
Related explainers
- Eigenvalues & Eigenvectors — How matrices transform space — eigenvectors, eigenvalues, and decomposition
- Linear Algebra — Vectors, matrices, and the language of data
- Dimensionality Reduction — PCA and t-SNE — seeing high-dimensional data
- LoRA & Parameter-Efficient Fine-Tuning — Adapt large models by training tiny low-rank matrices instead of all the weights
- Norms & Distance Metrics — L1, L2, cosine similarity — measuring closeness in vector spaces
- Matrix Calculus & Jacobians — Partial derivatives, gradients, and the Jacobian — calculus for vectors
References
- Eckart & Young (1936), "The approximation of one matrix by another of lower rank", Psychometrika
- Halko, Martinsson & Tropp (2011), "Finding Structure with Randomness: Probabilistic Algorithms for Constructing Approximate Matrix Decompositions"
- Miyato et al. (2018), "Spectral Normalization for Generative Adversarial Networks"
- Hu et al. (2021), "LoRA: Low-Rank Adaptation of Large Language Models"
Last updated