Singular Value Decomposition › Randomized SVD for Scale
Language AI HandbookAll chapters Singular Value Decomposition › Randomized SVD for ScaleOne section · Sections in this chapter7 / 14 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Even with sparse algorithms, exact SVD becomes slow for matrices with millions of rows or columns. Modern production NLP systems may want to compute embeddings for vocabularies of 500,000 to 1 million words. Randomized SVD, introduced by Halko, Martinsson, and Tropp in their influential 2011 paper "Finding structure with randomness," provides a principled approximation that dramatically reduces computation while maintaining high accuracy.
Randomized SVD approximates the top- singular vectors of a matrix by first projecting it onto a random low-dimensional subspace, then applying standard SVD to the smaller projected matrix. The result is nearly as accurate as exact SVD but much faster to compute, especially when is small relative to the matrix dimensions.
The algorithm works in two stages that together are much cheaper than direct SVD.
Stage 1: Range finding. The goal of this stage is to find a small orthonormal matrix whose columns approximately span the range (column space) of , restricted to the dominant directions. Generate a random matrix of shape , where is a small oversampling parameter, typically 5 to 10. The oversampling provides insurance that the random projection does not miss any important directions. Form the sample matrix:
Compute an orthonormal basis for the column space of using QR decomposition. The key insight is that multiplying by a random matrix produces a "sketch" of the column space of . If has dominant singular directions with much larger singular values than the rest, then will be approximately a linear combination of those directions plus small random perturbations. QR decomposition extracts an orthonormal basis for this sketch.
Stage 2: SVD of the projected matrix. Form the smaller matrix:
has dimensions . Rather than being enormous, is small in its first dimension: only rows. Compute the exact SVD of :
Recover the approximate left singular vectors as .
The computational saving is substantial. The expensive operations in the randomized algorithm are the matrix-vector products in forming and , each costing for a sparse matrix. The full SVD of costs , which is small when . Compared to exact SVD at , the asymptotic cost is similar, but the constant factors are much smaller because the algorithm avoids the iterative Lanczos refinement. For very large matrices, the difference is an order of magnitude in wall time.
The theoretical guarantee is that the error of randomized SVD is, with high probability, only slightly larger than the error of the best rank- approximation. Specifically:
where the expectation is over the random choice of and is the -th singular value. When is even modestly large (say, ) and the singular values decay rapidly (as they do in NLP matrices), the bound is tight and the approximation is excellent.
An optional but often used power iteration step can further improve accuracy: instead of computing , compute for small (typically 1 or 2). Each power iteration squares the singular values, making the dominant ones even more prominent relative to the small ones and producing a better sketch of the dominant subspace. The cost is additional matrix-vector products.
Scikit-learn's TruncatedSVD uses randomized SVD internally for large matrices, making it the practical tool of choice for LSA at scale. The algorithm='randomized' option (the default) invokes this randomized approach.