Fast nonlinear embeddings via structured matrices

Krzysztof Choromanski, Francois FaganarXiv 2016

Abstract

This paper introduces a generalized framework for accelerating nonlinear embeddings by replacing large, unstructured random matrices with structured counterparts, such as Toeplitz or circulant matrices. By "recycling" a limited budget of randomness through these structures, the authors achieve subquadratic computational complexity and linear space requirements while providing rigorous theoretical guarantees that the embeddings remain accurate. The core of their analysis relies on a novel connection between embedding quality and the chromatic number of coherence graphs.

What Problem Does This Paper Address?

In modern machine learning, many algorithms rely on random projections to map high-dimensional data into lower-dimensional spaces. This technique is fundamental to the Johnson-Lindenstrauss Transform for linear distances and various random feature methods for nonlinear kernels, such as Gaussian or angular similarity kernels.

The primary bottleneck is efficiency. A standard random matrix $A \in \mathbb{R}^{m \times n}$ requires $O(mn)$ space to store and $O(mn)$ time for matrix-vector multiplication. For massive datasets or very high dimensions, this cost is prohibitive. While structured matrices have been used to speed up linear projections, their application to nonlinear embeddings lacked a unified theoretical foundation. This paper bridges that gap, providing a general recipe for fast, memory-efficient nonlinear embeddings.

Methods: The $\mathcal{P}$-model and Structured Projections

The authors propose a $\mathcal{P}$-model for constructing structured matrices. Instead of filling a matrix with $m \times n$ independent Gaussian variables, they use a much smaller "budget of randomness"—a vector $g$ of length $t$ (where $t \ll mn$). The rows of the structured matrix are then generated by multiplying $g$ by a sequence of fixed, sparse matrices.

Toeplitz matrix structure and the associated hierarchy of coherence graphs used to analyze row dependencies.

Key components of their approach include:

  • Structured Matrix Types: The framework covers flagship structures like Circulant, Toeplitz, and Hankel matrices, as well as more complex ones with low displacement rank.
  • The Algorithm:
    1. Preprocessing: Data is multiplied by a randomized Hadamard transform ($D_1 H D_0$) to "spread out" the energy of the vectors, ensuring no single dimension dominates (a property called "balanceness").
  • Structured Projection: The balanced data is multiplied by the structured matrix $A$. Due to the matrix structure, this can often be performed in $O(n \log n)$ time using Fast Fourier Transforms (FFTs).
  • Nonlinear Mapping: A pointwise nonlinear function $f$ (e.g., ReLU, sine/cosine, or step function) is applied to the result.

Theoretical Foundation: Coherence Graphs

To prove these matrices work, the authors introduce coherence graphs. These graphs encode the correlations between different rows of the structured matrix. By analyzing the chromatic number (the minimum colors needed to color the graph such that no two adjacent vertices share a color) of these graphs, they derive how well the structured version approximates a fully random one.

A specific coherence graph $\mathcal{G}_{2,4}$ illustrating the dependencies between different rows in a structured projection.

One of the most elegant ideas is linking the quality of a mathematical embedding to the chromatic number of a graph. If the coherence graph has a low chromatic number, the rows are "independent enough" that the structured matrix behaves almost exactly like a fully random one.

Key Results and Complexity

  • Computational Speedup: For many classes of structured matrices (like Toeplitz), the time complexity of the projection drops from $O(mn)$ to $O(n \log m)$.
  • Space Complexity: Storage requirements are reduced from $O(mn)$ to $O(n)$ or $O(m+n)$, as only the small random seed vector needs to be stored.
  • Universality: Unlike previous works that focused on a single kernel, this framework works for a wide class of "spherically invariant" kernels, including angular distance and arc-cosine kernels used in deep learning theory.
  • Theoretical Tightness: The authors provide strong concentration results, proving that the probability of the structured embedding failing to approximate the true kernel value decreases exponentially with the number of dimensions, matching the reliability of slower, unstructured methods.

Limitations and Future Work

  • Preprocessing Overhead: The algorithm requires a randomized Hadamard transform as a mandatory preprocessing step to ensure theoretical guarantees hold. While efficient ($O(n \log n)$), it adds a constant overhead.
  • Specific Nonlinearities: The sharpness of the bounds depends on the specific nonlinear function $f$ and the sensitivity of the final mapping.
  • Future Directions: The authors suggest that the connection between displacement rank and embedding quality could be explored further to design even more exotic structured matrices tailored for specific hardware architectures.

Summary updated

BibTeX
@misc{choromanski2016fast,
  author = {Krzysztof Choromanski and Francois Fagan},
  title = {{Fast nonlinear embeddings via structured matrices}},
  year = {2016},
  eprint = {1604.07356},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1604.07356},
}
Figure