Latent semantic indexing (Deerwester and colleagues, 1990) replaces the term dimensions of the vector space model with the $k$ largest layers of the singular value decomposition $C = U\Sigma V^{\mathsf{T}}$. By the Eckart–Young theorem, proved here for both norms, the truncation $C_k$ is the best approximation of rank at most $k$, with spectral error $\sigma_{k+1}$ and Frobenius error $\sqrt{\sigma_{k+1}^2 + \dots + \sigma_r^2}$. On the textbook's six documents, two dimensions raise the cosine of boat ocean and ship, which share no term, from 0 to 0.94. On Cranfield (1,400 abstracts, 225 queries), unscaled LSI at $k = 100$ raised MAP from 0.265 to 0.354, past BM25's 0.307, almost entirely by reranking documents that already matched. Its dimensions are contrasts, not topics.
In the six documents of what is topic modeling, $d_2$ says boat ocean and $d_3$ says only ship. They share no term, so their cosine in the vector space model is 0, though the collection uses ship, boat and ocean together. Can plain linear algebra, with no thesaurus and no probabilities, turn that pattern of use into a space where $d_2$ and $d_3$ are close?
It can. Latent semantic indexing (LSI), also called latent semantic analysis (LSA), does exactly that, and it was the first topic model, though it predates the name. Deerwester, Dumais, Furnas, Landauer, and Harshman (1990) proposed it to address the vocabulary problem: queries and relevant documents often use different words for the same thing. LSI replaces the thousands of term dimensions of the vector space model with a few hundred dimensions found by a matrix factorization, in which terms that occur in similar documents lie close together. Queries and documents are then compared by cosine similarity in the smaller space.
First we build the singular value decomposition from an eigendecomposition, and prove that keeping its largest parts gives the best small approximation. Then we work every step by hand on the six documents, up to a folded-in query. Finally we test LSI on Cranfield, where it beat BM25 for an unexpected reason, and solve four problems on the six documents. The article follows Manning, Raghavan, and Schütze (2008, chapter 18), and is the course's home for the SVD and low-rank approximation.
The singular value decomposition
Write the collection as an $M \times N$ term-document matrix $C$. It has one row for each of $M$ terms and one column for each of $N$ documents, holding term counts or TF-IDF weights. Every matrix has a singular value decomposition (SVD):
$$C = U \Sigma V^{\mathsf{T}}.$$
- $U$ is an $M \times r$ matrix whose columns are orthonormal: one row for each term, one column for each of $r$ dimensions, where $r$ is the rank of $C$.
- $\Sigma$ is an $r \times r$ diagonal matrix of singular values $\sigma_1 \ge \sigma_2 \ge \dots \ge \sigma_r > 0$.
- $V^{\mathsf{T}}$ is an $r \times N$ matrix with orthonormal rows: one column for each document.
The columns of $U$ are eigenvectors of $CC^{\mathsf{T}}$, the term co-occurrence matrix. Its entry for two terms measures how often they appear in the same documents. The columns of $V$ are eigenvectors of $C^{\mathsf{T}}C$, the document similarity matrix. The singular values are the square roots of their shared eigenvalues. (An eigenvector is a direction a matrix only stretches; PageRank is the course's home for them.) Each dimension is a pattern of co-occurrence: a direction in term space along which documents vary together. Its $\sigma_k^2$ is its share of the squared Frobenius norm of $C$, a measure of how much of the collection it accounts for.
Where the decomposition comes from
The SVD can be built from an eigendecomposition, and doing so explains every claim in the previous paragraph. Here is the plan: the symmetric matrix $C^{\mathsf{T}}C$ has orthonormal eigenvectors, the document patterns $v_k$; sending each through $C$ gives a term pattern $u_k$; and we check that these are orthonormal too and rebuild $C$.
- Start from $C^{\mathsf{T}}C$. This $N \times N$ matrix is symmetric, and it is positive semidefinite, since $x^{\mathsf{T}} C^{\mathsf{T}} C x = \|Cx\|^2 \ge 0$ for every $x$. A real symmetric matrix has a full set of orthonormal eigenvectors $v_1, \dots, v_N$. That is the spectral theorem, the one result this construction uses without proof (Horn and Johnson, 2013, chapter 4, on Hermitian matrices; Manning, Raghavan, and Schütze, 2008, §18.1.1, state it as the symmetric diagonalization theorem, Theorem 18.2). Positive semidefiniteness makes the eigenvalues nonnegative: if $C^{\mathsf{T}}C v = \lambda v$ with $\|v\| = 1$, then $\lambda = v^{\mathsf{T}} C^{\mathsf{T}} C v = \|Cv\|^2 \ge 0$. Number them $\lambda_1 \ge \lambda_2 \ge \dots \ge 0$. Exactly $r$ of them are positive, where $r$ is the rank of $C$. The reason is that $C^{\mathsf{T}}C$ and $C$ send the same vectors to zero: $C^{\mathsf{T}}Cx = 0$ gives $\|Cx\|^2 = x^{\mathsf{T}}C^{\mathsf{T}}Cx = 0$, so $Cx = 0$, and $Cx = 0$ gives $C^{\mathsf{T}}Cx = 0$ at once. Writing any $x$ as $\sum_i a_i v_i$ gives $C^{\mathsf{T}}Cx = \sum_i \lambda_i a_i v_i$, which is zero exactly when $a_i = 0$ for every $i$ with $\lambda_i \neq 0$. So the vectors that $C^{\mathsf{T}}C$ sends to zero are the span of the eigenvectors with $\lambda = 0$, and the number of those eigenvectors is the dimension of that span. That dimension is the dimension of the space of vectors $C$ sends to zero, which by the rank–nullity theorem (the dimension of the space a matrix sends to zero is its number of columns minus its rank) is $N - r$. So $N - r$ eigenvalues are zero and the other $r$ are positive.
- Define the singular values and the left vectors. For each $k \le r$, set $\sigma_k = \sqrt{\lambda_k}$ and $u_k = C v_k / \sigma_k$.
- Check that the $u_k$ are orthonormal. $u_j^{\mathsf{T}} u_k = v_j^{\mathsf{T}} C^{\mathsf{T}} C v_k / (\sigma_j \sigma_k) = \lambda_k\, v_j^{\mathsf{T}} v_k / (\sigma_j \sigma_k)$, which is 1 when $j = k$ and 0 otherwise.
- Check that they are eigenvectors of $CC^{\mathsf{T}}$. $CC^{\mathsf{T}} u_k = C (C^{\mathsf{T}} C v_k)/\sigma_k = \lambda_k C v_k / \sigma_k = \sigma_k^2 u_k$. So $CC^{\mathsf{T}}$ and $C^{\mathsf{T}}C$ share their nonzero eigenvalues.
- Assemble. Step 2 says $C v_k = \sigma_k u_k$, or $C V_r = U \Sigma$ for the first $r$ columns. The remaining eigenvectors have $\lambda = 0$, so $\|C v\|^2 = 0$ and $Cv = 0$: $C$ sends them to nothing. Since the $v_k$ form an orthonormal basis, $C = C \sum_k v_k v_k^{\mathsf{T}} = \sum_{k \le r} \sigma_k u_k v_k^{\mathsf{T}} = U \Sigma V^{\mathsf{T}}$.
The last line is worth keeping in view. The SVD writes $C$ as a sum of $r$ rank-one layers, each an outer product of a term pattern $u_k$ and a document pattern $v_k$, weighted by $\sigma_k$:
$$C = \sigma_1 u_1 v_1^{\mathsf{T}} + \sigma_2 u_2 v_2^{\mathsf{T}} + \dots + \sigma_r u_r v_r^{\mathsf{T}}.$$
The layers are orthogonal to each other as matrices: the entrywise product of two different layers sums to zero, because that sum is $(u_j^{\mathsf{T}} u_k)(v_j^{\mathsf{T}} v_k) = 0$. Each has squared Frobenius norm $\sigma_k^2$, since the squared entries of $u_k v_k^{\mathsf{T}}$ sum to $\|u_k\|^2 \|v_k\|^2 = 1$. So the squared Frobenius norm of $C$, the sum of its squared entries, is $\sigma_1^2 + \dots + \sigma_r^2$, and $\sigma_k^2$ is literally the part of it that layer $k$ carries. For a 0/1 matrix, that sum is just the number of ones.
Example (counting the layers of a $5 \times 6$ matrix). The SVD of the six documents' $5 \times 6$ matrix has at most five layers, since the rank $r$ cannot exceed the number of rows. Each layer needs a positive eigenvalue of $C^{\mathsf{T}}C$, so that $6 \times 6$ matrix has at least one zero eigenvalue. The worked example below finds exactly five layers.
Every layer carries a definite share of the matrix. The next section keeps only the biggest ones and proves that nothing of the same rank does better.
Low-rank approximation
LSI keeps only the $k$ largest singular values and discards the rest:
$$C_k = U_k \Sigma_k V_k^{\mathsf{T}},$$
where $U_k$ and $V_k$ keep the first $k$ columns. In the layer picture, $C_k$ is the sum of the first $k$ layers. Here is the idea in one sentence: since the layers carry separate, additive shares of the matrix, dropping the smallest ones loses the least. The Eckart–Young theorem (Eckart and Young, 1936) makes this exact. It states that $C_k$ is the best possible approximation of $C$ by a matrix of rank at most $k$. Of all such matrices, it has the smallest Frobenius error, the square root of the sum of squared differences in every entry, and that error is $\sqrt{\sigma_{k+1}^2 + \dots + \sigma_r^2}$. It is also the best in a second norm, and the proof for the Frobenius norm goes through that one.
Two norms measure the size of a matrix $A$ here. The Frobenius norm $\|A\|_F$ is the square root of the sum of its squared entries. The spectral norm $\|A\|_2$ is the largest factor by which $A$ stretches any vector: the largest value of $\|Ax\|$ over vectors $x$ of length 1.
Theorem (Eckart–Young). Let $C$ be an $M \times N$ matrix with singular values $\sigma_1 \ge \dots \ge \sigma_r > 0$, and write $\sigma_j = 0$ for $j > r$. For every $M \times N$ matrix $Z$ of rank at most $k$,
$$\|C - Z\|_2 \ge \sigma_{k+1} \qquad \text{and} \qquad \|C - Z\|_F \ge \sqrt{\sigma_{k+1}^2 + \sigma_{k+2}^2 + \dots + \sigma_r^2},$$
and $Z = C_k$ attains both bounds.
Eckart and Young (1936) proved the Frobenius statement. Stewart (1993) reports that Schmidt had already proved the approximation result in 1907, for integral equations, as The Singular Value Decomposition in Statistics notes; we keep the standard name. The spectral statement is a case of Mirsky's (1960) extension to a family of norms, and the proof of it below follows the standard argument given in Golub and Van Loan (2013, §2.4, the section on the singular value decomposition). Here is the plan. First we compute the two errors of $C_k$ from the layers. Then we show that any matrix of rank at most $k$ must send to zero some vector that $C$ stretches by at least $\sigma_{k+1}$, which gives the spectral bound. Finally we apply the spectral bound once for each singular value of the error $C - Z$, which gives the Frobenius bound.
The formal version. The proof has four steps and uses only the facts about the SVD established above.
- The errors of $C_k$. $C - C_k$ is the sum of the discarded layers, $\sum_{i > k} \sigma_i u_i v_i^{\mathsf{T}}$. They are mutually orthogonal, so its squared Frobenius norm is the sum of their squared norms, $\sigma_{k+1}^2 + \dots + \sigma_r^2$. For the spectral norm, take any $x$ of length 1 and write $a_i = v_i^{\mathsf{T}} x$. Since $v_1, \dots, v_N$ is an orthonormal basis, $\sum_{i=1}^{N} a_i^2 = \|x\|^2 = 1$. Then $(C - C_k)x = \sum_{i > k} \sigma_i a_i u_i$, and because the $u_i$ are orthonormal, $$\|(C - C_k)x\|^2 = \sum_{i > k} \sigma_i^2 a_i^2 \le \sigma_{k+1}^2 \sum_{i > k} a_i^2 \le \sigma_{k+1}^2.$$ The choice $x = v_{k+1}$ gives equality, so $\|C - C_k\|_2 = \sigma_{k+1}$. With $k = 0$ this says $\|C\|_2 = \sigma_1$.
- Two subspaces that are too big to miss each other. Let $A$ and $B$ be subspaces of $\mathbb{R}^N$ of dimensions $p$ and $q$ with $p + q > N$. Then some nonzero vector lies in both. To see it, take a basis $a_1, \dots, a_p$ of $A$ and a basis $b_1, \dots, b_q$ of $B$. These are $p + q > N$ vectors in $\mathbb{R}^N$, so they are linearly dependent: $\sum_i \alpha_i a_i + \sum_j \beta_j b_j = 0$ with not all coefficients zero. Put $x = \sum_i \alpha_i a_i = -\sum_j \beta_j b_j$. It lies in $A$ by its first form and in $B$ by its second. It is not zero: if it were, both sums would vanish, and since each basis is linearly independent, every $\alpha_i$ and every $\beta_j$ would be zero.
- The spectral bound. Let $Z$ have rank at most $k$. If $k \ge r$ the bound reads $\|C - Z\|_2 \ge 0$ and there is nothing to prove, so let $k < r$. By the rank–nullity theorem, the vectors $x$ with $Zx = 0$ form a subspace of dimension at least $N - k$. The vectors $v_1, \dots, v_{k+1}$ span a subspace of dimension $k + 1$. The dimensions add to more than $N$, so by step 2 there is a vector $x$ of length 1 with $Zx = 0$ and $x = c_1 v_1 + \dots + c_{k+1} v_{k+1}$, where $\sum_i c_i^2 = 1$. Since $C v_i = \sigma_i u_i$, $$\|(C - Z)x\|^2 = \|Cx\|^2 = \Big\| \sum_{i=1}^{k+1} c_i \sigma_i u_i \Big\|^2 = \sum_{i=1}^{k+1} c_i^2 \sigma_i^2 \ge \sigma_{k+1}^2 \sum_{i=1}^{k+1} c_i^2 = \sigma_{k+1}^2.$$ The spectral norm is the largest stretch over all unit vectors, so $\|C - Z\|_2 \ge \sigma_{k+1}$.
- The Frobenius bound. Let $Z$ have rank at most $k$ and write $E = C - Z$ for the error. $E$ is a matrix like any other, so it has an SVD, with singular values $\sigma_1(E) \ge \sigma_2(E) \ge \dots$ (zero beyond its rank), and $\|E\|_F^2 = \sum_i \sigma_i(E)^2$ by the layer argument. Fix $i \ge 1$ and let $E_{i-1}$ be the sum of the first $i - 1$ layers of $E$. By step 1, applied to $E$, $\|E - E_{i-1}\|_2 = \sigma_i(E)$. Now consider the matrix $Z + E_{i-1}$. Each of its columns is a column of $Z$ plus a column of $E_{i-1}$, so its columns lie in a space of dimension at most $k + (i - 1)$, and its rank is at most $k + i - 1$. Step 3, applied to $C$ with $k + i - 1$ in place of $k$, gives $$\sigma_i(E) = \|E - E_{i-1}\|_2 = \|C - (Z + E_{i-1})\|_2 \ge \sigma_{k+i}.$$ So the $i$th singular value of the error is at least the $(k+i)$th singular value of $C$, for every $i$. Squaring and summing over $i$, $$\|C - Z\|_F^2 = \sum_{i \ge 1} \sigma_i(E)^2 \ge \sum_{i \ge 1} \sigma_{k+i}^2 = \sigma_{k+1}^2 + \dots + \sigma_r^2.$$
Steps 1, 3 and 4 together are the theorem. The worked example below checks each inequality on the six documents.
Example (a common misstatement). Manning, Raghavan, and Schütze (2008, §18.3, Theorem 18.4, eqs. 18.16 and 18.17) write the minimum Frobenius error as $\sigma_{k+1}$ alone. That value is the minimum error in the spectral norm, the first bound of the theorem. The Frobenius error is the larger quantity in the second bound, which equals $\sigma_{k+1}$ only when $k \ge r - 1$, and the example below shows the difference.
Example (where the two norms agree). In the example below, the five singular values are 2.16, 1.59, 1.28, 1.00 and 0.39, and the best rank-4 approximation has Frobenius error $\sigma_5 = 0.394$, the same as its spectral error. Only the fifth layer is discarded, so the two statements coincide because $k = r - 1$. At every smaller $k$ the Frobenius error is larger.
The approximation is not the goal in itself. Deerwester and colleagues argued that the discarded dimensions are mostly noise: the accidental choices of particular words by particular authors. The kept dimensions, they argued, capture the structure of association among terms. Forcing documents into $k$ dimensions makes documents that use related words similar even if they share none, because related words load on the same dimensions. Typical values of $k$ are a few hundred; Manning, Raghavan, and Schütze (2008, §18.4) speak of the low hundreds.
The six documents show it at work.
A worked example
Manning, Raghavan, and Schütze (2008, §18.4) use the five terms and six documents of what is topic modeling:
| $d_1$ | $d_2$ | $d_3$ | $d_4$ | $d_5$ | $d_6$ | |
|---|---|---|---|---|---|---|
| ship | 1 | 0 | 1 | 0 | 0 | 0 |
| boat | 0 | 1 | 0 | 0 | 0 | 0 |
| ocean | 1 | 1 | 0 | 0 | 0 | 0 |
| voyage | 1 | 0 | 0 | 1 | 1 | 0 |
| trip | 0 | 0 | 0 | 1 | 0 | 1 |
The same matrix is used throughout the topic: pLSA and LDA are fitted to it in their articles. The steps below compute everything by hand, to the precision shown. The values come from lsi_walkthrough.py in tools/experiments/topics/, rounded to two or three decimals.
Step 1: the co-occurrence matrix and its eigenvalues
$CC^{\mathsf{T}}$ counts, for each pair of terms, the documents that contain both. Its diagonal holds each term's document frequency:
| ship | boat | ocean | voyage | trip | |
|---|---|---|---|---|---|
| ship | 2 | 0 | 1 | 1 | 0 |
| boat | 0 | 1 | 1 | 0 | 0 |
| ocean | 1 | 1 | 2 | 1 | 0 |
| voyage | 1 | 0 | 1 | 3 | 1 |
| trip | 0 | 0 | 0 | 1 | 2 |
ship and boat never occur in the same document, so their entry is 0. Both co-occur with ocean, and that indirect link is what LSI will exploit. The eigenvalues of this matrix are 4.676, 2.542, 1.626, 1.000, and 0.155. They sum to 10, the trace, which is the number of ones in $C$. Their square roots are the singular values:
$$\sigma_1 = 2.16, \quad \sigma_2 = 1.59, \quad \sigma_3 = 1.28, \quad \sigma_4 = 1.00, \quad \sigma_5 = 0.39.$$
$C^{\mathsf{T}}C$, which is $6 \times 6$, has the same five nonzero eigenvalues and one zero, because six documents in a five-term space cannot be linearly independent.
The eigenvalues are the roots of the characteristic polynomial of $CC^{\mathsf{T}}$, which factors:
$$\lambda^5 - 10\lambda^4 + 34\lambda^3 - 48\lambda^2 + 26\lambda - 3 = (\lambda - 1)(\lambda^4 - 9\lambda^3 + 25\lambda^2 - 23\lambda + 3).$$
One eigenvalue is therefore exactly 1, and its eigenvector can be checked by hand. Take $x = (-1, 0, 0, 1, -1)$ in the term order ship, boat, ocean, voyage, trip, and multiply it by each row of the table:
- ship: $2(-1) + 1(1) = -1$;
- boat: $0$;
- ocean: $1(-1) + 1(1) = 0$;
- voyage: $1(-1) + 3(1) + 1(-1) = 1$;
- trip: $1(1) + 2(-1) = -1$.
The result is $x$ again, so $CC^{\mathsf{T}}x = 1 \cdot x$. Scaled to length 1, $x/\sqrt{3}$ is the fourth column of $U$ in the next step, where $1/\sqrt{3}$ appears as 0.58. Its document pattern is $C^{\mathsf{T}}x/\sigma_4 = (0, 0, -1, 0, 1, -1)$, again divided by $\sqrt{3}$: each document's entry is the sum of $x$ over its terms, such as $-1 + 0 + 1 = 0$ for $d_1$. The other four eigenvalues are the roots of the quartic factor. It has no rational root: a rational root of a polynomial with integer coefficients and leading coefficient 1 is an integer that divides the constant term, and the quartic's values at $1$, $-1$, $3$ and $-3$ are $-3$, $61$, $-3$ and $621$. So those four eigenvalues are computed numerically.
Step 2: the three factors
$U$ has one row per term and one column per dimension:
| 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|
| ship | 0.44 | −0.30 | 0.57 | −0.58 | 0.25 |
| boat | 0.13 | −0.33 | −0.59 | 0.00 | 0.73 |
| ocean | 0.48 | −0.51 | −0.37 | 0.00 | −0.61 |
| voyage | 0.70 | 0.35 | 0.15 | 0.58 | 0.16 |
| trip | 0.26 | 0.65 | −0.41 | −0.58 | −0.09 |
$V^{\mathsf{T}}$ has one row per dimension and one column per document:
| $d_1$ | $d_2$ | $d_3$ | $d_4$ | $d_5$ | $d_6$ | |
|---|---|---|---|---|---|---|
| 1 | 0.75 | 0.28 | 0.20 | 0.45 | 0.33 | 0.12 |
| 2 | −0.29 | −0.53 | −0.19 | 0.63 | 0.22 | 0.41 |
| 3 | 0.28 | −0.75 | 0.45 | −0.20 | 0.12 | −0.33 |
| 4 | 0.00 | 0.00 | −0.58 | 0.00 | 0.58 | −0.58 |
| 5 | −0.53 | 0.29 | 0.63 | 0.19 | 0.41 | −0.22 |
The sign of each dimension is arbitrary: flipping both $u_k$ and $v_k$ leaves the product unchanged. The textbook prints the first and fourth columns of $U$ (and rows of $V^{\mathsf{T}}$) with the opposite signs. Here each dimension is oriented so that voyage has a nonnegative entry. That makes the first dimension entirely positive.
The one-signed first dimension is not an accident of this example. $CC^{\mathsf{T}}$ has no negative entry, and its cube has no zero entry, because any two of the five terms are joined by a chain of at most three co-occurrences (boat to trip through ocean and voyage). The cube has the same eigenvectors, with the eigenvalues cubed. The Perron–Frobenius theorem, stated for matrices with all entries positive in PageRank, then says that the largest eigenvalue is simple and has an eigenvector with all entries positive; Horn and Johnson (2013, §8.4, on irreducible nonnegative matrices) give the general form, for nonnegative matrices whose rows are all connected in this way. Every later dimension must then mix signs. A nonzero vector with no negative entry has a positive dot product with an all-positive vector, so a column of $U$ orthogonal to the first cannot be of one sign. The rows of $V^{\mathsf{T}}$ behave alike. The first, $v_1 = C^{\mathsf{T}}u_1/\sigma_1$, is positive because $u_1$ is positive and every document contains at least one term. Each later row is orthogonal to it, and so has entries of both signs.
The squared singular values divide the matrix's squared norm of 10 among the dimensions: 46.8, 25.4, 16.3, 10.0, and 1.6 percent. The first two dimensions carry 72.2 percent.
Step 3: the layers, and the rank-2 matrix
The first layer, $\sigma_1 u_1 v_1^{\mathsf{T}}$, is an all-positive matrix. It gives each entry roughly "how active this term is, times how long this document is"; its largest entry is 1.14, for voyage in $d_1$. The second layer adds the first contrast. It is positive where a sea term meets a sea document or a travel term meets a travel document, and negative across the divide. For example, it adds $+0.43$ for ocean in $d_2$ and $-0.54$ for trip in $d_2$. Their sum is $C_2$:
The Frobenius error of $C_2$ is 1.668, and $\sqrt{1.275^2 + 1.000^2 + 0.394^2} = 1.668$, as the layer argument says. The error by rank falls as 2.307, 1.668, 1.075, 0.394, and 0 for $k = 1$ to 5. The spectral norm of $C - C_2$ is 1.275, which is $\sigma_3$, the value in the textbook's statement of the theorem.
The theorem proves that no rank-2 matrix does better. Three experiments show its bounds holding on this matrix:
- Keeping any other pair of dimensions gives a larger error: 1.923 for the first and third, and up to 2.974 for the fourth and fifth.
- Minimizing $\|C - AB\|_F$ over all $5 \times 2$ matrices $A$ and $2 \times 6$ matrices $B$ by gradient descent, from 30 random starts, ended at 1.668 every time, never lower.
- Of 3,000 other rank-2 matrices $Z$, half drawn at random and half small perturbations of $C_2$, none had a Frobenius error below 1.668 or a spectral error below 1.275. Each satisfied the inequality of step 4 of the proof, $\sigma_i(C - Z) \ge \sigma_{i+2}$ for $i = 1, 2, 3$. The same held at ranks 1, 3 and 4 against their own bounds.
Step 4: coordinates in two dimensions
Keeping $k = 2$ places each document at a point in a plane. Its coordinates are its column of $\Sigma_2 V_2^{\mathsf{T}}$, which equals $U_2^{\mathsf{T}} C$:
| $d_1$ | $d_2$ | $d_3$ | $d_4$ | $d_5$ | $d_6$ | |
|---|---|---|---|---|---|---|
| Dimension 1 | 1.62 | 0.60 | 0.44 | 0.97 | 0.70 | 0.26 |
| Dimension 2 | −0.46 | −0.84 | −0.30 | 1.00 | 0.35 | 0.65 |
Terms get coordinates the same way, as the rows of $U_2 \Sigma_2$: ship (0.95, −0.47), boat (0.28, −0.53), ocean (1.03, −0.81), voyage (1.52, 0.56), trip (0.57, 1.03).
Back to the question of the opening. The second dimension separates the sea (negative: ship, boat, ocean) from travel (positive: voyage, trip). Documents $d_2$ (boat ocean) and $d_3$ (ship) share no term, and their cosine in the original space is 0. In the reduced space it is 0.94, because ship, boat, and ocean co-occur and so load on the same dimensions. The same happens to the terms. ship and boat never appear together, and the cosine of their rows of $C$ is 0. The cosine of their two-dimensional coordinates is 0.81.
Example (a pair LSI does not bring together). LSI does not bring ship and trip close, as it did ship and boat: their two-dimensional cosine is 0.04. They never appear together either, and the cosine of their rows of $C$ is also 0. The second dimension puts ship on the sea side and trip on the travel side, and that contrast cancels nearly all the overlap the first dimension gives them: from their coordinates above, the first dimension contributes $0.95 \times 0.57 = 0.54$ to their dot product and the second $-0.47 \times 1.03 = -0.49$. Their one indirect link, through voyage, is outweighed.
The reduction moves every pair of documents, not only the ones with no shared terms:
| Pair | Shared terms | Cosine, original space | Cosine, 2 dimensions |
|---|---|---|---|
| $d_2, d_3$ | none | 0.00 | 0.94 |
| $d_1, d_3$ | ship | 0.58 | 0.95 |
| $d_1, d_2$ | ocean | 0.41 | 0.78 |
| $d_5, d_6$ | none | 0.00 | 0.75 |
| $d_4, d_6$ | trip | 0.71 | 0.93 |
| $d_2, d_6$ | none | 0.00 | −0.53 |
Pairs within one side of the sea/travel divide move closer, whether or not they share a word. Pairs across it move apart, to negative cosines that no pair of count vectors can have. $d_1$, which mixes ship and ocean with voyage, sits between the two groups.
A query, though, arrives as words. The next section gives it a position in the plane.
Queries and new documents
A query is a vector $\vec{q}$ in term space, so it must be mapped into the reduced space before it can be compared with documents. Here is the idea: the matrix that carries each document to its reduced coordinates can carry a query too, and it comes from the decomposition itself.
Multiply $C = U \Sigma V^{\mathsf{T}}$ on the left by $U_k^{\mathsf{T}}$. Because the columns of $U$ are orthonormal, $U_k^{\mathsf{T}} U$ is the identity on the first $k$ dimensions and zero on the rest. So $U_k^{\mathsf{T}} C = \Sigma_k V_k^{\mathsf{T}}$, and therefore $V_k^{\mathsf{T}} = \Sigma_k^{-1} U_k^{\mathsf{T}} C$. Each column of $C$, a document in term space, is sent to its column of $V_k^{\mathsf{T}}$ by the matrix $\Sigma_k^{-1} U_k^{\mathsf{T}}$. The same map applies to the query:
$$\vec{q}_k = \Sigma_k^{-1} U_k^{\mathsf{T}} \vec{q}.$$
Documents are then ranked by the cosine between $\vec{q}_k$ and their columns of $V_k^{\mathsf{T}}$.
The query boat ocean
The query vector is $\vec{q} = (0, 1, 1, 0, 0)$ in the term order ship, boat, ocean, voyage, trip.
Example (a query equal to a document). This query must land on $d_2$'s point, and that can be said before computing anything: the query vector equals $d_2$'s column of $C$, and the same matrix maps both. The projection takes the boat and ocean entries of each column of $U_2$:
$$U_2^{\mathsf{T}} \vec{q} = \begin{pmatrix} 0.129 + 0.476 \\ -0.331 - 0.511 \end{pmatrix} = \begin{pmatrix} 0.605 \\ -0.843 \end{pmatrix}, \qquad \vec{q}_2 = \Sigma_2^{-1} U_2^{\mathsf{T}} \vec{q} = \begin{pmatrix} 0.605 / 2.163 \\ -0.843 / 1.594 \end{pmatrix} = \begin{pmatrix} 0.280 \\ -0.528 \end{pmatrix}.$$
This is $d_2$'s column of $V_2^{\mathsf{T}}$, as the example said. The query's cosines with the six documents are:
| $d_1$ | $d_2$ | $d_3$ | $d_4$ | $d_5$ | $d_6$ | |
|---|---|---|---|---|---|---|
| Original space | 0.41 | 1.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| LSI, scaled by $\Sigma_2^{-1}$ | 0.75 | 1.00 | 0.94 | −0.45 | −0.11 | −0.71 |
| LSI, unscaled | 0.78 | 1.00 | 0.94 | −0.18 | 0.16 | −0.53 |
In the original space the query matches only $d_1$ and $d_2$. In the reduced space, $d_3$, which contains only ship, scores 0.94 and ranks second. It comes ahead of $d_1$, which contains ocean itself. That is the synonymy effect LSI was designed for: a document retrieved for a query with which it shares no term.
The document-pair table of step 4 used the unscaled coordinates $U_k^{\mathsf{T}}\vec{x} = \Sigma_k V_k^{\mathsf{T}}$, while the query formula uses coordinates scaled by $\Sigma_k^{-1}$; the query table shows both. In this example the cosine of $d_2$ and $d_3$ is 0.94 either way, but other values differ. With scaling, all three travel documents score below zero; without it, $d_5$ scores slightly above.
Whether to scale by $\Sigma_k^{-1}$, by $\Sigma_k$, or not at all is a choice the theory does not settle. It matters in practice, as the Cranfield experiment below shows. Without scaling, $U_k^{\mathsf{T}}\vec{x}$ is simply the projection of a vector onto the subspace spanned by the first $k$ dimensions, and every dimension keeps the weight it has in the data. Scaling by $\Sigma_k^{-1}$ gives every dimension equal weight, which magnifies the weaker ones.
Folding in documents
A new document can be folded in the same way, mapped into the existing space without recomputing the SVD. A new document boat trip, for instance, gets the unscaled coordinates $U_2^{\mathsf{T}} \vec{x} = (0.129 + 0.263,\ -0.331 + 0.647) = (0.39, 0.32)$. That lies between the sea and travel groups, as a document with one word from each should. Folding in is cheap, but the dimensions do not change to reflect the new documents, so after many additions the SVD must be recomputed. Terms that are new to the collection are simply dropped, since they have no row in $U$ (Manning, Raghavan, and Schütze, 2008, §18.4).
Whether this helps real searches takes a test collection to show.
An experiment on Cranfield
LSI was tested on the Cranfield collection (Cleverdon, 1967) of 1,400 aerodynamics abstracts and 225 queries, with the text processing of comparing ranking models. Documents and queries were weighted by logarithmic term frequency times IDF and normalized to unit length. That gives a $4{,}803 \times 1{,}400$ term-document matrix. The baseline is cosine similarity in the full space with the same weights.
| Method | MAP | P@10 |
|---|---|---|
| Cosine, full space | 0.265 | 0.211 |
| LSI, $k = 50$ | 0.321 | 0.247 |
| LSI, $k = 100$ | 0.354 | 0.261 |
| LSI, $k = 200$ | 0.353 | 0.270 |
| LSI, $k = 300$ | 0.334 | 0.257 |
| LSI, $k = 500$ | 0.310 | 0.240 |
| LSI, $k = 800$ | 0.287 | 0.228 |
| BM25, for comparison | 0.307 |
These LSI runs project without scaling. Scaling by $\Sigma_k^{-1}$, as in the textbook's formula, did worse at every $k$: for example 0.327 at $k = 100$ and 0.170 at $k = 800$. The likely reason is that it inflates the weakest dimensions, which are the noisiest. The first 100 of the 1,398 dimensions hold 30.8 percent of the squared Frobenius norm, and the first 500 hold 72.5 percent. Even a good reduction discards most of the matrix.
The spectrum explains why the choice of $k$ has to be made empirically. In the five-term example, two dimensions held 72 percent of the matrix. Cranfield's largest singular value, 8.14, stands apart because every column has unit length and positive entries. So the first dimension mostly records the average document, and The Singular Value Decomposition in Statistics measures how closely. After it, the values fall slowly, from 3.81 for the second to 1.54 for the hundredth and 0.96 for the five-hundredth. Keeping half of the squared norm takes 241 dimensions, and keeping 90 percent takes 868. At $k = 100$ the approximation's error is 83 percent of the norm of $C$ itself. Retrieval improved anyway. What LSI discards, then, is not uniformly noise, but much of what it keeps is the part that matters for ranking. Limits of Single-Vector Retrieval compresses Cranfield's BM25 vectors, in the same 4,803 term dimensions, by a random projection instead of the SVD, and measures how often BM25's first abstract for a query survives the compression.
Every value of $k$ tested beat the full-space cosine. Every value from 50 to 500 also beat BM25, the strongest model in comparing ranking models, though at $k = 500$ only barely. At $k = 100$, LSI was better than BM25 on 142 of the 225 queries, and a randomization test gave $p < 0.0001$. The best $k$ was chosen on the same queries it is reported on, which slightly overstates it, but the gain does not depend on a single lucky choice. Mixing the full-space and LSI scores did no better than LSI alone.
Where the gain came from
The usual explanation for LSI is that it retrieves relevant documents that share no words with the query, as $d_3$ was retrieved for boat ocean above.
Example (what the top-ten results share). That explanation does not account for the gain on Cranfield. LSI at $k = 100$ returned 2,250 top-ten results for the 225 queries. If the usual explanation were the source of its gain, many of those results would share no term with their query. In fact just one of the 2,250 did, and it was not relevant. Relevant documents with no shared term are rare on Cranfield to begin with: only 61 of the 1,612 relevant query-document pairs share no term at all. LSI improved the ranking among documents that already matched.
A plausible reading is that the projection changes how much each match counts. In the full space, a match on a rare term that happens to appear in the query carries a large IDF weight, even if the document is about something else. In the reduced space, a term counts through the dimensions it loads on. A match on terms central to the query's subject, and supported by the document's other terms, then counts for more than an isolated match.
The worked example shows the same effect at small scale. In $C_2$, $d_1$'s weight for ship fell from 1 to 0.85 while $d_3$ gained weight for ocean, because each document's entries were pulled toward the pattern of its dimension. This is a form of smoothing. It is related in spirit to pseudo-relevance feedback, which also raised MAP on Cranfield, from 0.307 to 0.324, by using the vocabulary of documents that match well.
Cranfield is small and confined to one field, where patterns of co-occurrence are strong and consistent. On larger and more varied collections, results have been more modest. Manning, Raghavan, and Schütze (2008, §18.4) summarize Dumais's experiments on TREC (Dumais, 1993, 1995) in three statements. Checked against the TREC-3 report (Dumais, 1995), they describe two different experiments:
- LSI achieved precision at or above that of the median participant. In the report that holds for routing, where standing profiles are matched against new documents: the run whose profiles were built from known relevant documents was at or above the median on 41 of the 50 topics. The ad hoc runs were a little below the median, at or above it on 18 and 19 of the 50 topics.
- On about a fifth of the topics, the LSI system was the top scorer. That is the same routing run, which had the best score on 10 of the 50 topics.
- It was reportedly slightly better on average than standard vector space retrieval, at about 350 dimensions. The report makes that comparison in the ad hoc experiment, where LSI with 199 dimensions was about 5 percent better than vector matching on the same term-document matrix without the reduction. The space of 346 dimensions was the one used for routing.
The textbook also notes cases where it fell short of conventional indexing.
Common misreadings
- "LSI finds synonyms." It finds terms with similar co-occurrence patterns. ship and boat end up close because both appear with ocean, a second-order association: they never appear together. Terms that are true synonyms but appear in different contexts are not brought together. Terms that merely appear in the same contexts are brought together, whether or not they mean the same thing: voyage and trip in this example, or a company's name and its product.
- "Each dimension is a topic." Only the first dimension is all of one sign, as step 2 of the worked example showed. Every later dimension is a contrast, with positive weights for some terms and negative weights for others. It is the combination of dimensions, not any one of them, that places a document. Here the second dimension happens to be readable as sea against travel; in a real collection most are not.
- "The approximation removes noise, so a smaller error is better." The rank-$k$ approximation is the best fit to the data, but retrieval is not fitting. On Cranfield, $k = 800$ fits the matrix far better than $k = 100$ and retrieves worse.
Costs and limits
- Computation. The SVD of a large term-document matrix is expensive. The reduced document vectors are dense, so the efficient sparse inverted index no longer applies. Each query must be compared with every document's $k$-dimensional vector. Nearest neighbor search in high dimensions measures what that full scan costs and shows why a k-d tree examines nearly every vector once the dimension reaches a hundred. Learned sparse retrieval takes the other route to the vocabulary problem: a trained model adds terms a text lacks while the inverted index stays, and it is run on Cranfield through ordinary postings lists.
- Updates. Folding in new documents degrades the space over time, and recomputing the SVD for a changing collection is costly.
- Interpretation. LSI dimensions are contrasts, with positive and negative entries, not topics. In Reuters, one LSI dimension had dividend announcements at one end and earnings tables at the other. Documents can have negative coordinates, and $C_k$ negative entries, which have no natural meaning.
- Statistical basis. Minimizing squared error implicitly assumes that word counts vary with Gaussian noise, a poor fit for counts that are mostly zero. Probabilistic latent semantic analysis was proposed to put the same idea on a probabilistic footing suited to counts.
The same decomposition, applied to a centered data matrix, underlies principal component analysis. Applied to a matrix of words and their neighboring words, it gives dense word vectors: word embeddings uses it that way and compares the result with skip-gram, whose optimum is itself a factorization of such a matrix.
The experiments are iir_lsi.py, lsi_walkthrough.py, cranfield_lsi.py, and cranfield_spectrum.py in tools/experiments/topics/ in the site repository. The figures are drawn by tools/figures/latent-semantic-indexing.py.
Worked problems
The course had no assignment for this topic. These four problems are posed on the six documents of the worked example, one for each main result of the article, and every number in them is checked by lsi_walkthrough.py.
Problem 1 (errors at other ranks). For the six documents, find the Frobenius and spectral errors of the best rank-1 and rank-3 approximations. Then decide whether any rank-3 matrix approximates $C$ with Frobenius error below 1, and whether any rank-1 matrix has spectral error below 1.5.
The squared singular values are 4.676, 2.542, 1.626, 1.000 and 0.155, and they sum to 10. By step 1 of the proof of the Eckart–Young theorem, the errors of $C_k$ are the tail of that list:
- $k = 1$: the squared Frobenius error is $10 - 4.676 = 5.324$, so the error is $\sqrt{5.324} = 2.307$. The spectral error is $\sigma_2 = 1.594$.
- $k = 3$: the squared Frobenius error is $1.000 + 0.155 = 1.155$, so the error is $\sqrt{1.155} = 1.075$. The spectral error is $\sigma_4 = 1.000$.
Both questions are answered by the theorem's lower bounds, and the answer to both is no. Every matrix of rank at most 3 has Frobenius error at least 1.075, which is above 1. Every matrix of rank at most 1 has spectral error at least 1.594, which is above 1.5. No search over matrices is needed.
Problem 2 (two queries that LSI cannot tell apart). Fold the queries ship trip and voyage into the two-dimensional space, without scaling, and compare their rankings of the six documents there and in the original space.
The two queries share no word, and they land on the same point. The unscaled coordinates of a query are $U_2^{\mathsf{T}} \vec{q}$, the sum of its terms' rows of $U_2$. From the first two columns of $U$ in step 2, to three decimals:
- ship trip: $(0.440 + 0.263,\ -0.296 + 0.647) = (0.703, 0.351)$;
- voyage: $(0.703, 0.351)$.
This is exact, not a coincidence of rounding. The difference of the two query vectors is $(0, 0, 0, 1, 0) - (1, 0, 0, 0, 1) = (-1, 0, 0, 1, -1)$, the vector $x$ of step 1, which is $\sqrt{3}\,u_4$. The columns of $U$ are orthonormal, so $U_2^{\mathsf{T}} u_4 = 0$, and the two queries have the same projection. With $k = 2$ the fourth layer is discarded, and with it the only direction that separates voyage from ship plus trip.
The rankings follow. In the plane both queries have the cosines below with the document coordinates of step 4, and $d_5$ (voyage), whose coordinates are $(0.70, 0.35)$, matches both exactly:
| $d_1$ | $d_2$ | $d_3$ | $d_4$ | $d_5$ | $d_6$ | |
|---|---|---|---|---|---|---|
| Original space, ship trip | 0.41 | 0.00 | 0.71 | 0.50 | 0.00 | 0.71 |
| Original space, voyage | 0.58 | 0.00 | 0.00 | 0.71 | 1.00 | 0.00 |
| Two dimensions, either query | 0.74 | 0.16 | 0.49 | 0.94 | 1.00 | 0.75 |
In the original space the query ship trip ranks $d_3$ (ship) and $d_6$ (trip) first and gives $d_5$ a score of 0. In the plane it ranks $d_5$ first, a document that contains neither of its words, and $d_3$ fifth. That is the cost side of the reduction: what the discarded layers distinguished, LSI can no longer see.
Problem 3 (the query the topic opened with). The topic began with a search for boat, which word matching answers with $d_2$ alone. Rank the six documents for the query boat in the two-dimensional space, without scaling.
The ranking is $d_2$, $d_3$, $d_1$, with the three travel documents below zero. The query's coordinates are boat's row of $U_2$, $(0.129, -0.331)$. For $d_3$ (ship), whose coordinates are $(0.440, -0.296)$:
$$\cos = \frac{0.129 \times 0.440 + (-0.331)(-0.296)}{\sqrt{0.129^2 + 0.331^2}\ \sqrt{0.440^2 + 0.296^2}} = \frac{0.1547}{0.3552 \times 0.5303} = 0.82.$$
The six cosines are:
| $d_1$ | $d_2$ | $d_3$ | $d_4$ | $d_5$ | $d_6$ | |
|---|---|---|---|---|---|---|
| Original space | 0.00 | 0.71 | 0.00 | 0.00 | 0.00 | 0.00 |
| Two dimensions | 0.60 | 0.97 | 0.82 | −0.42 | −0.09 | −0.73 |
$d_3$, which says only ship, is retrieved second for a query with which it shares no word. $d_2$'s cosine rises from 0.71 to 0.97, since in the plane its other word, ocean, points nearly the same way as boat.
Problem 4 (the eigenvector of the largest eigenvalue). Without computing it, say why the first column of $U$ for the six documents has no negative entry and no zero entry, and why no other column has that property.
The matrix $CC^{\mathsf{T}}$ of step 1 has no negative entry, and its terms are connected: boat co-occurs with ocean, ocean with ship and voyage, and voyage with trip. Its cube therefore has every entry positive, and by the Perron–Frobenius theorem the eigenvector of its largest eigenvalue can be taken with every entry positive, as step 2 showed. Any other column $u_k$ satisfies $u_1^{\mathsf{T}} u_k = 0$. If $u_k$ had no negative entry, that dot product would be a sum of nonnegative terms with at least one positive, since $u_k \ne 0$ and every entry of $u_1$ is positive. So $u_k$ has a negative entry. Applying this to $-u_k$, which is also orthogonal to $u_1$, shows that $u_k$ has a positive entry too. The table of $U$ agrees: column 1 runs from 0.13 to 0.70, and each of columns 2 to 5 has entries of both signs.
What we have learned
The SVD writes the term-document matrix as a sum of rank-one layers, and keeping the largest $k$ gives the best approximation of rank at most $k$, in the Frobenius norm and in the spectral norm. On the six documents, two layers separate the sea from travel, lift the cosine of $d_2$ and $d_3$ from 0 to 0.94, and let the query boat ocean retrieve $d_3$. On Cranfield, LSI at $k = 100$ raised MAP from 0.265 to 0.354, past BM25, almost entirely by reranking documents that already matched.
What LSI cannot do is say what its numbers mean: its coordinates and approximate counts go negative. Probabilistic latent semantic analysis writes the same factorization as a probability model, with topics that are distributions and mixtures that are proportions.
References
- Cleverdon, C. W. (1967). The Cranfield tests on index language devices. Aslib Proceedings, 19(6), 173–194. https://doi.org/10.1108/eb050097 record · 11 pages
- Deerwester, S., Dumais, S. T., Furnas, G. W., Landauer, T. K., and Harshman, R. (1990). Indexing by latent semantic analysis. Journal of the American Society for Information Science, 41(6), 391–407. record · 4 pages
- Dumais, S. T. (1993). LSI meets TREC: A status report. In Proceedings of the First Text REtrieval Conference (TREC-1), 137–152. NIST Special Publication 500-207. record
- Dumais, S. T. (1995). Latent semantic indexing (LSI): TREC-3 report. In Proceedings of the Third Text REtrieval Conference (TREC-3), 219–230. NIST Special Publication 500-225. record
- Eckart, C., and Young, G. (1936). The approximation of one matrix by another of lower rank. Psychometrika, 1(3), 211–218. record · 2 pages
- Golub, G. H., and Van Loan, C. F. (2013). Matrix Computations (4th ed.). Johns Hopkins University Press. record
- Horn, R. A., and Johnson, C. R. (2013). Matrix Analysis (2nd ed.). Cambridge University Press. record
- Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, chapter 18. Cambridge University Press. record · 102 pages
- Mirsky, L. (1960). Symmetric gauge functions and unitarily invariant norms. The Quarterly Journal of Mathematics, 11(1), 50–59. record
- Stewart, G. W. (1993). On the early history of the singular value decomposition. SIAM Review, 35(4), 551–566. https://doi.org/10.1137/1035134. Read in its technical-report version: University of Maryland, TR-92-31 (CS-TR-2855), March 1992, http://hdl.handle.net/1903/566. record · 2 pages
Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 12 revisions