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 in literature. However, a 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 general problem and contrast it with the existing best-match algorithms. First, we propose a general branch-and-bound algorithm using a tree data structure. Subsequently, we present a dual-tree algorithm for the case where there are multiple queries. Finally we present a new data structure for increasing the efficiency of the dual-tree algorithm. These branch-and-bound algorithms involve novel bounds suited for the purpose of best-matching with inner products. 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.
Introduction
In many modern applications, such as recommender systems and document retrieval, the goal is to find the "best match" for a query within a massive dataset. While mature tools exist for Euclidean distance (e.g., KD-trees) and Cosine similarity, the Maximum Inner-Product Search (MIPS) problem is significantly more challenging.
The inner product is mathematically "messy" because it does not satisfy the triangle inequality. This inequality is the fundamental rule most fast search algorithms use to "prune" or skip large parts of a dataset. Without it, standard metric trees often fail, leading many to believe that a linear scan—checking every single item—was the only exact solution unless the data was normalized. However, normalization changes the meaning of the search by ignoring vector magnitudes.
As shown in Figure 1, the point that maximizes the inner product ($p_I$) is often different from the Euclidean nearest neighbor ($p_E$) or the point with the highest cosine similarity ($p_C$).
Methodology
The authors propose a branch-and-bound framework tailored specifically for inner products, avoiding the need for normalization.
Single-Tree and Dual-Tree Search
The core of the approach is a standard Ball-tree, which organizes points into hierarchical hyper-spheres. The innovation lies in a novel analytical upper bound for the inner product. This bound allows the algorithm to prove that a specific "ball" of points cannot contain the best match, enabling efficient pruning.
Figure 3 illustrates the geometric construction used to derive these bounds. By considering the query vector $q$ and the bounding ball centered at $p_0$ with radius $R_p$, the algorithm can calculate a tight upper bound on the inner product for any point $p^*$ within that ball.
For scenarios with many queries, a dual-tree algorithm traverses two trees simultaneously (a query tree and a reference tree), amortizing the search cost across similar queries.
Cone-trees
The paper introduces Cone-trees, a new data structure designed for indexing queries. Recognizing that the direction of a query vector is often more critical than its magnitude for determining rankings, Cone-trees group queries based on their angular spread from the origin. This leads to much tighter bounds than traditional spatial grouping.
Kernelization
The framework also extends to general kernel functions (e.g., Gaussian RBF) even when data cannot be explicitly represented as vectors, using a "representative point" strategy to calculate bounds.
Key Results
The proposed algorithms were evaluated on 15 diverse datasets, including collaborative filtering (Netflix, MovieLens), image recognition (MNIST), and astronomy (LCDM, PSF).
- Massive Speedups: On astronomy datasets, the algorithms achieved up to 100,000x speedup over linear scans.
- High-Dimensional Efficiency: Even in datasets with over 25,000 dimensions (LiveJournal), the single-tree search provided a 28x speedup.
- Cone-trees vs. Ball-trees: Cone-trees consistently outperformed Ball-trees for query sets, particularly in collaborative filtering where vector magnitudes vary significantly.
- Low Overhead: Preprocessing time for building trees was typically less than 1% of the time required for a single linear scan.
Conclusion
This research proves that tree-based structures can handle non-metric similarity searches where standard techniques usually fail. By developing novel analytical bounds and the Cone-tree data structure, the authors provide a practical and highly efficient solution for exact MIPS. Future work will focus on rigorous theoretical runtime analysis and adapting the framework for approximate search to achieve even greater performance gains.
Summary updated