Eigenvalues, SVD, and High-Dimensional Vector Spaces in Machine Learning
Modern artificial intelligence relies fundamentally on linear transformations over high-dimensional vector spaces. From token embeddings in Transformer models and diffusion latent spaces to low-rank fine-tuning (LoRA), spectral matrix decomposition provides the mathematical framework for understanding dimensionality reduction, attention projections, and representation geometry.
1. Spectral Theorem and Orthonormal Bases
Let be a real symmetric matrix (). According to the Spectral Theorem, there exists an orthogonal matrix () and a real diagonal matrix such that:
Where:
- form an orthonormal basis of consisting of eigenvectors of .
- are the corresponding real eigenvalues.
2. Singular Value Decomposition (SVD)
For arbitrary rectangular matrices (such as a document-term matrix or token co-occurrence matrix):
Where:
- is an orthogonal matrix of left singular vectors (eigenvectors of ).
- is a diagonal matrix of non-negative singular values .
- is an orthogonal matrix of right singular vectors (eigenvectors of ).
3. Eckart-Young-Mirsky Low-Rank Approximation
In machine learning compression and parameter-efficient fine-tuning (such as LoRA), we seek the optimal rank- approximation matrix () that minimizes reconstruction loss under the Frobenius norm:
pythonimport numpy as np def compute_low_rank_approximation(X: np.ndarray, target_rank: int): U, S, Vt = np.linalg.svd(X, full_matrices=False) U_k = U[:, :target_rank] S_k = S[:target_rank] Vt_k = Vt[:target_rank, :] X_k = U_k @ np.diag(S_k) @ Vt_k error = np.linalg.norm(X - X_k, 'fro') return X_k, error
4. References & Academic Citations
- Eckart, C., & Young, G. (1936). The approximation of one matrix by another of lower rank. Psychometrika, 1(3), 211–218.
- Strang, G. (2019). Linear Algebra and Learning from Data. Wellesley-Cambridge Press.
- Hu, E. J., et al. (2021). LoRA: Low-Rank Adaptation of Large Language Models. arXiv:2106.09685.