Abstract: The problem of efficiently finding the best match for a query in a given set with respect to the Euclidean distance or the cosine similarity has been extensively studied. However, the closely related problem of efficiently finding the best match with respect to the inner-product has never been explored in the general setting to the best of our knowledge. In this paper we consider this problem and contrast it with the previous problems considered. First, we propose a general branch-and-bound algorithm based on a (single) tree data structure. Subsequently, we present a dual-tree algorithm for the case where there are multiple queries. Our proposed branch-and-bound algorithms are based on novel inner-product bounds. Finally we present a new data structure, the cone tree, for increasing the efficiency of the dual-tree algorithm. We evaluate our proposed algorithms on a variety of data sets from various applications, and exhibit up to five orders of magnitude improvement in query time over the naive search technique in some cases.
Introduction
This paper addresses a fundamental bottleneck in modern recommendation engines and machine learning: the Maximum Inner-Product Search (MIPS). While decades have been spent perfecting ways to find "nearest neighbors" using Euclidean distance or Cosine similarity, the raw inner product—the engine behind matrix factorization and deep learning embeddings—presents a unique mathematical challenge that the authors solve using clever tree-based geometry.
What Problem Does This Paper Address?
In many applications, like recommender systems, we represent users and items as vectors. To recommend an item, we calculate the inner product between a user vector ($q$) and an item vector ($p$). The goal is to find the item that maximizes this value.
The challenge is that MIPS is fundamentally different from standard nearest-neighbor search. Standard search relies on the triangle inequality (if A is close to B, and B is close to C, then A is somewhat close to C). Inner products do not satisfy the triangle inequality. Furthermore, unlike Cosine similarity, the lengths (norms) of the vectors in MIPS matter immensely—a very "long" vector might have a high inner product even if its direction isn't a perfect match.
As illustrated above, the point that maximizes the inner product ($p_I$) is often distinct from the Euclidean nearest neighbor ($p_E$) or the point with the highest cosine similarity ($p_C$). Because of these properties, traditional indexing methods like Locality-Sensitive Hashing (LSH) or standard metric trees often fail or return inaccurate results.
Methods
The authors move away from approximate hashing and toward exact branch-and-bound algorithms.
1. Single-Tree Search
They use a Ball-tree to organize the reference points (items). Each node in the tree is a "ball" with a center and a radius. They derive a new analytical upper bound that allows the algorithm to "prune" (skip) entire branches of the tree if the maximum possible inner product in that ball is lower than the best match found so far.
2. Dual-Tree Search
For scenarios with millions of queries, they index the queries themselves into a tree. This allows them to process groups of similar queries against groups of reference points simultaneously.
3. Cone Trees
This is the paper's most novel contribution. They observe that for a query, the direction is often more important for pruning than the length. They propose "Cone-trees," where queries are grouped into overlapping cones defined by a central axis and an aperture angle. This structure provides much tighter bounds for pruning than standard ball-trees when dealing with inner products.
4. Max-Kernel Extension
They show these techniques can be generalized to "Max-Kernel" operations (like Gaussian RBF kernels) even when the vectors are in an implicit, high-dimensional feature space.
Key Insights and Results
- Geometry over Hashing: While the industry often leans toward approximate hashing (LSH), this paper proves that exact geometric pruning is not only possible for MIPS but can be incredibly efficient.
- The Power of Direction: The introduction of Cone-trees highlights that in inner-product space, angular similarity is a more powerful pruning tool than Euclidean distance.
- Massive Speedups: On astronomy datasets (LCDM and PSF), the proposed algorithms were 10,000 to 100,000 times faster than a naive linear scan. For dual-tree search, Cone-trees consistently outperformed Ball-trees for indexing queries, often by a factor of 2x to 10x.
- Scalability: Even on high-dimensional datasets like LiveJournal (25,327 dimensions), the tree-based search remained significantly faster than linear scanning, debunking the myth that trees are only for low-dimensional data.
Limitations and Future Work
While the empirical results are stellar, the authors note they lack a rigorous theoretical runtime complexity bound (e.g., proving it is $O(\log N)$). Additionally, building the trees takes time and requires more memory than a simple matrix of vectors. While this preprocessing is usually a small fraction of the total search time, it could be a bottleneck in highly dynamic systems where vectors change constantly.
Summary updated