NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Fast Exact Max-Kernel Search

Ryan R. Curtin, Alexander G. Gray, Parikshit Ram

Max-Kernel Search (MKS) is a fundamental operation in modern data science, underpinning applications ranging from collaborative filtering in recommender systems to sequence alignment in bioinformatics. The goal is simple: given a query and a large dataset, find the item that maximizes a specific kernel function—a measure of similarity. However, as datasets scale into the millions, the traditional approach of a linear scan (comparing the query against every item) becomes a significant computational bottleneck.

While efficient indexing exists for Nearest Neighbor Search (NNS) in metric spaces, MKS presents unique challenges. Most existing fast MKS solutions rely on approximations, restrict the search to specific kernel types (like normalized or shift-invariant kernels), or require explicit vector representations. The latter is particularly problematic as it bypasses the "kernel trick," which allows operations in high-dimensional or even infinite-dimensional spaces without explicit mapping. This paper introduces FastMKS, an algorithm designed for exact max-kernel search across any Mercer kernel without requiring explicit feature representations.

The FastMKS Algorithm

The core of FastMKS is the use of a cover tree built directly within the implicit Reproducing Kernel Hilbert Space (RKHS) defined by the kernel. Unlike standard spatial trees that rely on coordinate systems, FastMKS constructs its hierarchy using only pairwise distances. By applying the kernel trick, the distance between two points $x$ and $y$ in the Hilbert space is computed as:

$$d_\mathcal{K}(x,y) = \sqrt{\mathcal{K}(x,x) + \mathcal{K}(y,y) - 2\mathcal{K}(x,y)}$$

To navigate this tree efficiently, the authors developed a novel branch-and-bound pruning strategy. During the search process, the algorithm calculates a mathematical upper bound for the maximum possible kernel value between the query and any point within a specific node's subtree. If this upper bound is lower than the best similarity score found so far, the entire branch is pruned. This allows the search to skip vast portions of the dataset while still guaranteeing an exact result.

Theoretical Innovations

A significant contribution of this work is the formalization of why MKS is computationally distinct from NNS. In NNS, the search complexity is often tied to "distance concentration"—how points are distributed relative to each other. In MKS, the authors argue that complexity depends on how points project along the direction of the query.

To quantify this, they introduce the directional concentration constant. This metric allows for a rigorous proof of the algorithm's efficiency, demonstrating that under certain conditions, FastMKS achieves $O(\log n)$ query time. This theoretical foundation explains why the algorithm remains performant even in high-dimensional spaces where other indexing methods often fail.

Empirical Performance and Versatility

The authors validated FastMKS across a diverse array of datasets and kernels:

  • Vector Data: Using datasets like MNIST, LCDM astronomy data, and various UCI machine learning repositories with linear and polynomial kernels.
  • Abstract Data: Protein sequences from GenBank using the p-spectrum kernel, demonstrating the algorithm's ability to handle non-vectorial data.
  • Collaborative Filtering: Large-scale datasets like Netflix and Yahoo! Music.

The empirical results were striking. FastMKS achieved up to 10,000x speedups over linear scans in terms of kernel evaluations. Furthermore, the experiments on protein sequences confirmed the theoretical $O(\log n)$ scaling, showing that the performance gap between FastMKS and linear scanning grows exponentially as the dataset size increases.

Crucially, FastMKS excels with un-normalized kernels. In many domains, the magnitude of a vector (e.g., the frequency of a specific gene sequence) is as important as its direction. While many competing algorithms require data normalization to function, FastMKS preserves this critical information, making it a more robust tool for real-world scientific and industrial applications.

Conclusion

FastMKS represents a significant step forward in similarity search. By combining the hierarchical structure of cover trees with the mathematical power of the kernel trick and a new pruning logic, the authors have created a domain-agnostic tool that is both theoretically sound and practically powerful. While the $O(n \log n)$ preprocessing time and reliance on the directional concentration constant are factors to consider, the massive gains in query speed make it an essential algorithm for large-scale kernel-based applications.

Summary updated

BibTeX
@inproceedings{curtin2013fast,
  author = {Ryan R. Curtin and Alexander G. Gray and Parikshit Ram},
  title = {{Fast Exact Max-Kernel Search}},
  booktitle = {SDM},
  year = {2013},
  doi = {10.1137/1.9781611972832.1},
}
Figure