Misplaced Pages

Johnson–Lindenstrauss lemma

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Mathematical result

In mathematics, the Johnson–Lindenstrauss lemma is a result named after William B. Johnson and Joram Lindenstrauss concerning low-distortion embeddings of points from high-dimensional into low-dimensional Euclidean space. The lemma states that a set of points in a high-dimensional space can be embedded into a space of much lower dimension in such a way that distances between the points are nearly preserved. In the classical proof of the lemma, the embedding is a random orthogonal projection.

The lemma has applications in compressed sensing, manifold learning, dimensionality reduction, graph embedding, and natural language processing. Much of the data stored and manipulated on computers, including text and images, can be represented as points in a high-dimensional space (see vector space model for the case of text). However, the essential algorithms for working with such data tend to become bogged down very quickly as dimension increases. It is therefore desirable to reduce the dimensionality of the data in a way that preserves its relevant structure.

The lemma likely explains how large language models (LLMs) like transformers are able to represent highly nuanced word meanings and context in relatively low-dimension embeddings.

Lemma

Given 0 < ε < 1 {\displaystyle 0<\varepsilon <1} , a set X {\displaystyle X} of m {\displaystyle m} points in R N {\displaystyle \mathbb {R} ^{N}} , and an integer n > 8 ( ln m ) / ε 2 {\displaystyle n>8(\ln m)/\varepsilon ^{2}} , there is a linear map f : R N R n {\displaystyle f:\mathbb {R} ^{N}\rightarrow \mathbb {R} ^{n}} such that

( 1 ε ) u v 2 f ( u ) f ( v ) 2 ( 1 + ε ) u v 2 {\displaystyle (1-\varepsilon )\|u-v\|^{2}\leq \|f(u)-f(v)\|^{2}\leq (1+\varepsilon )\|u-v\|^{2}}

for all u , v X {\displaystyle u,v\in X} .

The formula can be rearranged: ( 1 + ε ) 1 f ( u ) f ( v ) 2 u v 2 ( 1 ε ) 1 f ( u ) f ( v ) 2 {\displaystyle (1+\varepsilon )^{-1}\|f(u)-f(v)\|^{2}\leq \|u-v\|^{2}\leq (1-\varepsilon )^{-1}\|f(u)-f(v)\|^{2}}

Alternatively, for any ϵ ( 0 , 1 ) {\displaystyle \epsilon \in (0,1)} and any integer n 15 ( ln m ) / ε 2 {\displaystyle n\geq 15(\ln m)/\varepsilon ^{2}} there exists a linear function f : R N R n {\displaystyle f:\mathbb {R} ^{N}\rightarrow \mathbb {R} ^{n}} such that the restriction f | X {\displaystyle f|_{X}} is ( 1 + ε ) {\displaystyle (1+\varepsilon )} -bi-Lipschitz.

Also, the lemma is tight up to a constant factor, i.e. there exists a set of points of size m that needs dimension

Ω ( log ( m ) ε 2 ) {\displaystyle \Omega \left({\frac {\log(m)}{\varepsilon ^{2}}}\right)}

in order to preserve the distances between all pairs of points within a factor of ( 1 ± ε ) {\displaystyle (1\pm \varepsilon )} .

The classical proof of the lemma takes f {\displaystyle f} to be a scalar multiple of an orthogonal projection P {\displaystyle P} onto a random subspace of dimension n {\displaystyle n} in R N {\displaystyle \mathbb {R} ^{N}} . An orthogonal projection collapses some dimensions of the space it is applied to, which reduces the length of all vectors, as well as distance between vectors in the space. Under the conditions of the lemma, concentration of measure ensures there is a nonzero chance that a random orthogonal projection reduces pairwise distances between all points in X {\displaystyle X} by roughly a constant factor c {\displaystyle c} . Since the chance is nonzero, such projections must exist, so we can choose one P {\displaystyle P} and set f ( v ) = P v / c {\displaystyle f(v)=Pv/c} .

To obtain the projection algorithmically, it suffices with high probability to repeatedly sample orthogonal projection matrices at random. If you keep rolling the dice, you will eventually obtain one in polynomial random time.

Alternate statement

A related lemma is the distributional JL lemma. This lemma states that for any 0 < ε , δ < 1 / 2 {\displaystyle 0<\varepsilon ,\delta <1/2} and positive integer d {\displaystyle d} , there exists a distribution over R k × d {\displaystyle \mathbb {R} ^{k\times d}} from which the matrix A {\displaystyle A} is drawn such that for k = O ( ε 2 log ( 1 / δ ) ) {\displaystyle k=O(\varepsilon ^{-2}\log(1/\delta ))} and for any unit-length vector x R d {\displaystyle x\in \mathbb {R} ^{d}} , the claim below holds.

P ( | A x 2 2 1 | > ε ) < δ {\displaystyle P(|\Vert Ax\Vert _{2}^{2}-1|>\varepsilon )<\delta }

One can obtain the JL lemma from the distributional version by setting x = ( u v ) / u v 2 {\displaystyle x=(u-v)/\|u-v\|_{2}} and δ < 1 / n 2 {\displaystyle \delta <1/n^{2}} for some pair u,v both in X. Then the JL lemma follows by a union bound over all such pairs.

Speeding up the JL transform

Given A, computing the matrix vector product takes O ( k d ) {\displaystyle O(kd)} time. There has been some work in deriving distributions for which the matrix vector product can be computed in less than O ( k d ) {\displaystyle O(kd)} time.

There are two major lines of work. The first, Fast Johnson Lindenstrauss Transform (FJLT), was introduced by Ailon and Chazelle in 2006. This method allows the computation of the matrix vector product in just d log d + k 2 + γ {\displaystyle d\log d+k^{2+\gamma }} for any constant γ > 0 {\displaystyle \gamma >0} .

Another approach is to build a distribution supported over matrices that are sparse. This method allows keeping only an ε {\displaystyle \varepsilon } fraction of the entries in the matrix, which means the computation can be done in just k d ε {\displaystyle kd\varepsilon } time. Furthermore, if the vector has only b {\displaystyle b} non-zero entries, the Sparse JL takes time k b ε {\displaystyle kb\varepsilon } , which may be much less than the d log d {\displaystyle d\log d} time used by Fast JL.

Tensorized random projections

It is possible to combine two JL matrices by taking the so-called face-splitting product, which is defined as the tensor products of the rows (was proposed by V. Slyusar in 1996 for radar and digital antenna array applications). More directly, let C R 3 × 3 {\displaystyle {C}\in \mathbb {R} ^{3\times 3}} and D R 3 × 3 {\displaystyle {D}\in \mathbb {R} ^{3\times 3}} be two matrices. Then the face-splitting product C D {\displaystyle {C}\bullet {D}} is

C D = [ C 1 D 1 C 2 D 2 C 3 D 3 ] . {\displaystyle {C}\bullet {D}=\left.}

This idea of tensorization was used by Kasiviswanathan et al. for differential privacy.

JL matrices defined like this use fewer random bits, and can be applied quickly to vectors that have tensor structure, due to the following identity:

( C D ) ( x y ) = C x D y = [ ( C x ) 1 ( D y ) 1 ( C x ) 2 ( D y ) 2 ] {\displaystyle (\mathbf {C} \bullet \mathbf {D} )(x\otimes y)=\mathbf {C} x\circ \mathbf {D} y=\left} ,

where {\displaystyle \circ } is the element-wise (Hadamard) product. Such computations have been used to efficiently compute polynomial kernels and many other linear-algebra algorithms.

In 2020 it was shown that if the matrices C 1 , C 2 , , C c {\displaystyle C_{1},C_{2},\dots ,C_{c}} are independent ± 1 {\displaystyle \pm 1} or Gaussian matrices, the combined matrix C 1 C c {\displaystyle C_{1}\bullet \dots \bullet C_{c}} satisfies the distributional JL lemma if the number of rows is at least

O ( ϵ 2 log 1 / δ + ϵ 1 ( 1 c log 1 / δ ) c ) {\displaystyle O(\epsilon ^{-2}\log 1/\delta +\epsilon ^{-1}({\tfrac {1}{c}}\log 1/\delta )^{c})} .

For large ϵ {\displaystyle \epsilon } this is as good as the completely random Johnson-Lindenstrauss, but a matching lower bound in the same paper shows that this exponential dependency on ( log 1 / δ ) c {\displaystyle (\log 1/\delta )^{c}} is necessary. Alternative JL constructions are suggested to circumvent this.

See also

Notes

  1. Or any integer n > 128 ( ln m ) / ( 9 ε 2 ) . {\displaystyle n>128(\ln m)/(9\varepsilon ^{2}).}
  2. This result follows from the above result. Sketch of proof: Note 1 / ( 1 + ε ) < 1 3 ε / 4 {\displaystyle 1/(1+\varepsilon )<{\sqrt {1-3\varepsilon /4}}} and 1 + 3 ε / 4 < 1 + ε < 1 + ε {\displaystyle {\sqrt {1+3\varepsilon /4}}<{\sqrt {1+\varepsilon }}<1+\varepsilon } for all ε ( 0 , 1 ) {\displaystyle \varepsilon \in (0,1)} . Do casework for 1=m and 1<m, applying the above result to 3 ε / 4 {\displaystyle 3\varepsilon /4} in the latter case, noting 128 / 9 < 15. {\displaystyle 128/9<15.}

References

  1. For instance, writing about nearest neighbor search in high-dimensional data sets, Jon Kleinberg writes: "The more sophisticated algorithms typically achieve a query time that is logarithmic in n at the expense of an exponential dependence on the dimension d; indeed, even the average case analysis of heuristics such as k-d trees reveal an exponential dependence on d in the query time. Kleinberg, Jon M. (1997), "Two Algorithms for Nearest-neighbor Search in High Dimensions", Proceedings of the Twenty-Ninth Annual ACM Symposium on Theory of Computing, STOC '97, New York, NY, USA: ACM, pp. 599–608, doi:10.1145/258533.258653, ISBN 0-89791-888-6.
  2. Hardt, Moritz. "Word Embeddings: Explaining their properties". Off the convex path. Retrieved 2024-10-10.
  3. Fernandez-Granda, Carlos. "Lecture notes 5: Random projections" (PDF). p. 6. Lemma 2.6 (Johnson-Lindenstrauss lemma)
  4. Larsen, Kasper Green; Nelson, Jelani (2017), "Optimality of the Johnson-Lindenstrauss Lemma", Proceedings of the 58th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pp. 633–638, arXiv:1609.02094, doi:10.1109/FOCS.2017.64, ISBN 978-1-5386-3464-6, S2CID 16745
  5. Nielsen, Frank (2016), "10. Fast approximate optimization in high dimensions with core-sets and fast dimension reduction", Introduction to HPC with MPI for Data Science, Springer, pp. 259–272, ISBN 978-3-319-21903-5
  6. Johnson, William B.; Lindenstrauss, Joram (1984), "Extensions of Lipschitz mappings into a Hilbert space", in Beals, Richard; Beck, Anatole; Bellow, Alexandra; et al. (eds.), Conference in modern analysis and probability (New Haven, Conn., 1982), Contemporary Mathematics, vol. 26, Providence, RI: American Mathematical Society, pp. 189–206, doi:10.1090/conm/026/737400, ISBN 0-8218-5030-X, MR 0737400, S2CID 117819162
  7. Ailon, Nir; Chazelle, Bernard (2006), "Approximate nearest neighbors and the fast Johnson–Lindenstrauss transform", Proceedings of the 38th Annual ACM Symposium on Theory of Computing, New York: ACM Press, pp. 557–563, doi:10.1145/1132516.1132597, ISBN 1-59593-134-1, MR 2277181, S2CID 490517
  8. Kane, Daniel M.; Nelson, Jelani (2014), "Sparser Johnson-Lindenstrauss Transforms", Journal of the ACM, 61 (1): 1, arXiv:1012.1577, doi:10.1145/2559902, MR 3167920, S2CID 7821848. A preliminary version of this paper was published in the Proceedings of the Twenty-Third Annual ACM-SIAM Symposium on Discrete Algorithms, 2012.
  9. Esteve, Anna; Boj, Eva; Fortiana, Josep (2009), "Interaction terms in distance-based regression", Communications in Statistics, 38 (18–20): 3498–3509, doi:10.1080/03610920802592860, MR 2589790, S2CID 122303508
  10. ^ Slyusar, V. I. (December 27, 1996), "End products in matrices in radar applications." (PDF), Radioelectronics and Communications Systems, 41 (3): 50–53
  11. ^ Slyusar, V. I. (1997-05-20), "Analytical model of the digital antenna array on a basis of face-splitting matrix products." (PDF), Proc. ICATT-97, Kyiv: 108–109
  12. ^ Slyusar, V. I. (1997-09-15), "New operations of matrices product for applications of radars" (PDF), Proc. Direct and Inverse Problems of Electromagnetic and Acoustic Wave Theory (DIPED-97), Lviv.: 73–74
  13. ^ Slyusar, V. I. (March 13, 1998), "A Family of Face Products of Matrices and its Properties" (PDF), Cybernetics and Systems Analysis C/C of Kibernetika I Sistemnyi Analiz.- 1999., 35 (3): 379–384, doi:10.1007/BF02733426, S2CID 119661450
  14. ^ Slyusar, V. I. (2003), "Generalized face-products of matrices in models of digital antenna arrays with nonidentical channels" (PDF), Radioelectronics and Communications Systems, 46 (10): 9–17
  15. Kasiviswanathan, Shiva Prasad; Rudelson, Mark; Smith, Adam D.; Ullman, Jonathan R. (2010), "The price of privately releasing contingency tables and the spectra of random matrices with correlated rows", in Schulman, Leonard J. (ed.), Proceedings of the 42nd ACM Symposium on Theory of Computing, STOC 2010, Cambridge, Massachusetts, USA, 5–8 June 2010, Association for Computing Machinery, pp. 775–784, doi:10.1145/1806689.1806795, ISBN 978-1-4503-0050-6, OSTI 990798, S2CID 5714334
  16. Woodruff, David P. (2014), Sketching as a Tool for Numerical Linear Algebra, Foundations and Trends in Theoretical Computer Science, vol. 10, arXiv:1411.4357, doi:10.1561/0400000060, MR 3285427, S2CID 51783444
  17. Ahle, Thomas; Kapralov, Michael; Knudsen, Jakob; Pagh, Rasmus; Velingker, Ameya; Woodruff, David; Zandieh, Amir (2020), "Oblivious Sketching of High-Degree Polynomial Kernels", ACM-SIAM Symposium on Discrete Algorithms, Association for Computing Machinery, pp. 141–160, arXiv:1909.01410, doi:10.1137/1.9781611975994.9, ISBN 978-1-61197-599-4

Further reading

Categories: