The Math Behind the Methods

Low-Rank Approximation: Why So Many Models Exploit It

Learn why large matrices can often be replaced by two thin ones, what that saves, where models use the trick and when it breaks down.

Key takeaways

  • A rank-r matrix can be written as the product of an (m, r) factor and an (r, n) factor.
  • Truncated singular value decomposition gives the closest rank-r matrix in the Frobenius and spectral norms.
  • Savings are real only if you keep the two factors separate instead of multiplying them back together.
  • Recommenders, adapter-based fine-tuning, model compression and kernel approximation all use low rank.
  • A slowly decaying singular value spectrum means a small rank will lose important information.

Low-rank approximation replaces a large matrix with the product of two much thinner ones. An m by n matrix has m · n entries, while a rank-r product of an m by r matrix and an r by n matrix has r(m + n). When r is small, you store less, compute less and have fewer numbers to estimate.

Models exploit it because many matrices that arise from data or training are well described by a few shared patterns. The word "many" matters. It is a property to test, not a guarantee.

What rank means

The rank of a matrix is the number of linearly independent columns, which always equals the number of linearly independent rows. A rank-one matrix has every column proportional to a single column. A multiplication table is an example: entry (i, j) is i · j, so the whole grid comes from two lists.

A rank-r matrix is built from r such pieces added together. Writing W ≈ B A, with B of shape (m, r) and A of shape (r, n), forces every output to pass through r intermediate numbers. That narrow passage is both the saving and the restriction.

Why data matrices are often close to low rank

Consider a table of customers by products. Purchases are driven partly by a modest number of shared tendencies, such as price sensitivity or interest in a hobby. Rows influenced by the same causes look like mixtures of the same few patterns.

Sensor channels that watch one physical process, pixels in a set of aligned faces and word counts across related documents behave similarly. Measurement noise makes the matrix technically full rank, but the extra directions have small singular values.

Training can also produce structure of this kind. In many networks, the learned weights or the changes made during fine-tuning concentrate much of their size in a subset of directions. How strong this is varies by layer, model and task, so measure it.

The best approximation and its error

The singular value decomposition orders a matrix's patterns by strength. Keeping the top r gives the best rank-r approximation. This is the Eckart-Young theorem, extended by Mirsky to other norms that depend only on singular values.

Frobenius error of best rank r:  √(σ_{r+1}² + σ_{r+2}² + ...)
spectral error of best rank r:   σ_{r+1}

Suppose the singular values are 10, 6, 1 and 0.5. Their squares are 100, 36, 1 and 0.25, which total 137.25.

Rank kept Share of squared size kept Relative Frobenius error
1 about 72.9% about 52%
2 about 99.1% about 9.5%
3 about 99.8% about 4.3%

Notice that keeping 99% of the "energy" still leaves a relative error near 10%, because the error is the square root of the missing share. State which of the two you are quoting.

The arithmetic of savings

Applying a full matrix W of shape (m, n) to a vector costs m · n multiply-adds. Applying B(Ax) costs r(n + m). The factorized form wins when r < mn / (m + n). For a square 1,000 by 1,000 matrix, that means r below 500.

At r = 50 the factors hold 100,000 numbers instead of 1,000,000, and each product is ten times cheaper in arithmetic. If you form BA first and then multiply, you are back to the full cost. Counting FLOPs covers the effect of multiplication order.

Real speedups can be smaller than the arithmetic suggests. Two small products have more overhead than one large one, and accelerators often run large dense products especially efficiently.

Where models use it

One idea, many uses
Low rank Two thin factors in place of one big matrix Components Fewer data dimensions Kernels Approximate huge Gram matrices Recommenders User and item vectors Adapters Small trainable weight updates Compression Split a layer in two Low rank Two thin factors in place of one big matrix Recommenders User and item vectors Adapters Small trainable weight updates Compression Split a layer in two Kernels Approximate huge Gram matrices Components Fewer data dimensions

Dimension reduction. Principal component analysis is truncated SVD of a centered data matrix.

Recommendation. A ratings table is modeled as user vectors times item vectors, fitted only where data exist.

Low-rank adapters. In LoRA, a pretrained weight W stays frozen and training learns an update BA with small r. For a 4,096 by 4,096 layer and r = 8, the update has 2 · 4,096 · 8 = 65,536 trainable numbers against 16,777,216 in W, about 0.39%. The frozen weights still take memory and compute. Details are in LoRA explained.

Compression after training. A single linear layer is replaced by two narrower ones built from the SVD of its weights, often followed by more training to recover accuracy. See low-rank factorization of a trained network.

Kernel methods. The Nyström method approximates an n by n kernel matrix using m selected columns, with m much smaller than n, which avoids the cubic cost of working with the full matrix.

Embeddings and attention. Some models factor a large embedding table through a narrower width, and some efficient attention variants approximate the score matrix with low-rank structure.

Low rank as regularization

A factorization with small r has fewer free parameters, so it can fit less noise. Choosing r is then a capacity decision like choosing a penalty strength, and it belongs on the validation set.

When you cannot fix r in advance, a penalty on the nuclear norm, the sum of singular values, encourages low rank while keeping the problem convex for squared error. It plays a role similar to the L1 norm for sparse vectors, because it adds up nonnegative strengths and drives some to zero.

Fitting with missing entries is harder than the complete case. With factors B and A, the objective is not convex in both at once. Alternating between them, each step a least squares problem, or using gradient descent usually works well in practice, but the answer can depend on initialization and regularization.

The factors are not unique

For any invertible r by r matrix R, the pair (BR, R⁻¹A) gives the same product as (B, A). Only the product is determined by the data. The individual columns of a factor therefore have no fixed meaning when you fit by gradient descent.

This has practical consequences. Two training runs can produce user vectors that look unrelated yet make nearly identical predictions. Comparing factors across runs requires aligning them first. A penalty on the squared size of both factors narrows the freedom but still allows rotations.

Scale can drift too. If one factor grows and the other shrinks, the product is unchanged while the optimizer may struggle. Initialization schemes for factorized layers aim to keep the product at a sensible size. One common choice in adapter methods is to start one factor at zero, so that the update begins as nothing and the pretrained behavior is intact at the first step.

If you need factors that people can inspect, add constraints that suit the data. Non-negative matrix factorization forbids negative entries, which often yields additive parts. It still does not guarantee a unique or meaningful answer.

When it fails

The identity matrix is the standard counterexample. All n singular values equal 1, so the best rank-r approximation has relative Frobenius error √((n − r)/n). Keeping half the rank still leaves about 71% relative error. Nothing in it is redundant.

Other warning signs include:

  • A spectrum that declines slowly, with no clear break.
  • Rare but important cases that contribute little to total squared size, such as a small group of unusual users.
  • Structure that is curved or discrete, which may need a high linear rank although few underlying variables produce it.
  • Local patterns, like a band along the diagonal, better described by sparsity or locality.

An approximation that looks fine on average can be poor for particular rows. Report errors by group and test the downstream metric.

Trying it on your own matrix

import numpy as np

rng = np.random.default_rng(0)
W = rng.normal(size=(200, 8)) @ rng.normal(size=(8, 100))  # rank 8
W += 0.05 * rng.normal(size=W.shape)                       # noise

U, s, Vt = np.linalg.svd(W, full_matrices=False)
for r in [2, 4, 8, 16]:
    B = U[:, :r] * s[:r]          # (200, r)
    A = Vt[:r]                    # (r, 100)
    err = np.linalg.norm(W - B @ A) / np.linalg.norm(W)
    print(r, round(err, 4))

The error drops sharply up to r = 8 and creeps down afterward, because later terms fit noise. Real weight matrices rarely show so clean a break.

Weight error is also only a proxy. Directions that matter little to the norm may matter a lot for the inputs the layer actually receives. Comparing outputs, and ultimately task metrics, is the test that counts.

Common questions

Is low rank the same as sparsity?

No. A sparse matrix has many zero entries and may have full rank. A low-rank matrix can have no zeros at all. Some methods model data as a sum of one of each.

How do I pick r?

Look at the spectrum to get a range, then compare validation performance, latency and memory across a few values. Pick the smallest rank that meets your requirements.

Written for 4MachineLearning with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 26 articles in The Math Behind the Methods →

Latest news on this topic