Tensor Sketch: Fast and Scalable Polynomial Kernel Approximation

Ninh Pham, Rasmus PagharXiv 2025 · DOI

Abstract

Tensor Sketch is a transformative randomized algorithm designed to approximate polynomial kernels on massive, high-dimensional datasets. By integrating "Count Sketches" with the Fast Fourier Transform (FFT), the method reduces the computational complexity of kernel approximation from a quadratic bottleneck to near-linear time. This paper reviews the theoretical foundations, implementation details, and the significant performance gains that have established Tensor Sketch as a standard tool for scalable non-linear machine learning.

Introduction

Kernel methods, such as Support Vector Machines (SVMs), are highly effective in machine learning due to their ability to capture complex, non-linear patterns by implicitly mapping data into high-dimensional feature spaces. However, their scalability is often limited by $O(n^3)$ time and $O(n^2)$ space requirements relative to the number of samples ($n$), making them impractical for large-scale datasets.

While techniques like Random Fourier Features (RFF) addressed these issues for shift-invariant kernels (e.g., Gaussian kernels), they are inapplicable to polynomial kernels, which are essential for modeling feature interactions. For a polynomial kernel of degree $p$, the explicit feature space dimension grows exponentially ($d^p$). Previous approximation methods were constrained by $O(dD)$ complexity, where $d$ is the input dimension and $D$ is the output dimension, creating a significant bottleneck for high-dimensional data such as genomic sequences or text.

Methods

The authors introduce Tensor Sketch, a data-independent random feature map that bridges tensor products and fast convolution. The core innovation lies in avoiding the explicit computation of the massive tensor product $x \otimes y$. Instead, the algorithm computes a Count Sketch of the original vectors.

The fundamental mathematical insight is that the sketch of a tensor product is equivalent to the circular convolution of the individual sketches. By utilizing the Fast Fourier Transform (FFT), this convolution is computed in $O(D \log D)$ time rather than $O(D^2)$. Consequently, mapping a $d$-dimensional vector to a $D$-dimensional "sketched" space requires only $O(d + D \log D)$ time and $O(1)$ additional space to store the random hash functions.

Comparison and Results

The efficiency of Tensor Sketch represents a significant leap over prior state-of-the-art methods. Traditional sketching and Monte Carlo approaches typically scale with the product of input and output dimensions ($dD$), which becomes prohibitive as data dimensionality increases.

Comparison of Tensor Sketch with other kernel approximation techniques.

As illustrated in the table above, Tensor Sketch achieves a time complexity of $O(D \log D)$ and a memory complexity of $O(1)$, effectively breaking the $d \times D$ barrier. This reduction to $O(n(d + D \log D))$ total time allows for the processing of datasets at a previously impossible scale. Theoretical analysis (Theorem 9) further confirms that the inner product in the sketched space is an unbiased estimator of the true polynomial kernel, with variance decreasing as the sketch size $D$ increases.

Key Insights

  • The Convolution Trick: The most significant insight is transforming a combinatorial tensor problem into a signal processing task via circular convolution.
  • Independence Requirements: To provide rigorous error guarantees, the authors demonstrate that while index hash functions require 2-wise independence, the "sign" hash functions require 4-wise independence to effectively bound the variance of the approximation.
  • Widespread Adoption: Due to its efficiency and theoretical fidelity, the method is now a standard part of the scikit-learn library as PolynomialCountSketch.

Applications

Tensor Sketch has been successfully applied across a wide variety of domains:

  • Text Data: Handling high-dimensional sparse bag-of-words vectors.
  • Computer Vision: Powering "Compact Bilinear Pooling" for image classification and multimodal fusion.
  • Bioinformatics: Analyzing genomic data and molecular fingerprints for property prediction.
  • Graph Data: Enabling large-scale network analysis and clustering.

Limitations and Future Work

Despite its advantages, the variance of the approximation contains a $3^p$ term, meaning the error grows exponentially with the degree of the polynomial ($p$). While highly effective for low degrees (e.g., $p=2$ or $p=3$), it becomes less stable for very high-degree polynomials. Subsequent research has explored tree-structured sketching to improve this dependence on $p$. Additionally, like all random feature maps, there remains a trade-off between sketch size $D$ and the accuracy of downstream tasks, which varies based on the specific dataset structure.

Summary updated

BibTeX
@misc{pham2025tensor,
  author = {Ninh Pham and Rasmus Pagh},
  title = {{Tensor Sketch: Fast and Scalable Polynomial Kernel Approximation}},
  year = {2025},
  eprint = {2505.08146},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.08146},
}
Figure