Toward Metric Indexes for Incremental Insertion and Querying

Edward Raff, Charles NicholasarXiv 2018

Abstract

Traditional nearest neighbor search often assumes static datasets, which is impractical for dynamic environments like malware triage. This paper evaluates and optimizes three metric index structures—Cover-trees, Vantage-Point (VP) trees, and Random Ball Covers (RBC)—for incremental insertion and querying. We introduce the Minimum-Variance Vantage-Point tree ($VP_{MV}$), which utilizes a variance-minimizing split strategy to enhance pruning efficiency. Experimental results across diverse datasets demonstrate that $VP_{MV}$ consistently outperforms existing methods in dynamic scenarios, providing a robust solution for live indexing.

Introduction

Nearest neighbor search is a fundamental task in fields ranging from image retrieval to malware analysis. To avoid the computational cost of brute-force search, metric indexes leverage the triangle inequality to prune the search space. However, most research focuses on static datasets where the index is built once and queried many times. In production environments, such as malware analysis labs, millions of new files arrive continuously, requiring indexes that support interleaved insertions and queries without frequent, expensive rebuilds.

Methods for Incremental Indexing

The authors adapted three established metric index structures for incremental use:

Cover-trees

Cover-trees are naturally hierarchical and incremental. However, they typically rely on a maxdist parameter that is expensive to update. The authors implemented $Cover_B$, which employs a looser, computationally cheaper upper bound to facilitate immediate querying post-insertion.

Vantage-Point (VP) Trees

VP trees partition space using distances from a selected "vantage point." While traditionally built top-down, the authors developed an incremental strategy using a bucket system.

Spatial partitioning in a Vantage Point tree using concentric circles centered at a vantage point.

The primary innovation is the $VP_{MV}$ (Minimum-Variance) tree. Standard VP trees split data at the median distance. In contrast, $VP_{MV}$ selects a split point that minimizes the weighted variance of distances, similar to split selection in decision trees. This approach creates a larger "gap" between branches, significantly improving pruning efficiency during search.

Comparison between the standard median split and the proposed Minimum-Variance split in $VP_{MV}$.

Random Ball Cover (RBC)

Originally optimized for GPUs, RBC was modified with an incremental construction procedure. The improved version, $RBC_{Imp}$, enhances search speed by building neighbor lists incrementally and utilizing cached distances to tighten search bounds.

Experimental Evaluation

The study evaluated these structures across diverse datasets, including MNIST (images), Forest Cover Type (tabular), and VirusShare5m (malware). The malware dataset utilized the Lempel-Ziv Jaccard Distance (LZJD) to measure binary similarity.

Key Results

  • Performance Leader: The $VP_{MV}$ tree emerged as the most efficient structure, requiring the fewest distance computations during construction and maintaining top-tier query speeds.
  • Robustness: $VP_{MV}$ demonstrated superior performance in write-heavy scenarios (e.g., 100 insertions per query). On the VirusShare5m dataset, it avoided up to 57% of distance computations compared to brute-force search.
  • Cover-tree Limitations: Despite their theoretical elegance, Cover-trees performed poorly on certain metrics like LZJD, sometimes falling behind brute-force search.

Conclusion

The $VP_{MV}$ tree provides a significant advancement for incremental nearest neighbor search. By optimizing the split strategy to minimize variance, it achieves superior pruning and stability in dynamic environments. Future work will explore better parallelization for tree-based structures and methods to maintain split quality as the index grows.

Summary updated

Abstract

In this work we explore the use of metric index structures, which accelerate nearest neighbor queries, in the scenario where we need to interleave insertions and queries during deployment. This use-case is inspired by a real-life need in malware analysis triage, and is surprisingly understudied. Existing literature tends to either focus on only final query efficiency, often does not support incremental insertion, or does not support arbitrary distance metrics. We modify and improve three algorithms to support our scenario of incremental insertion and querying with arbitrary metrics, and evaluate them on multiple datasets and distance metrics while varying the value of $k$ for the desired number of nearest neighbors. In doing so we determine that our improved Vantage-Point tree of Minimum-Variance performs best for this scenario.
BibTeX
@misc{raff2018toward,
  author = {Edward Raff and Charles Nicholas},
  title = {{Toward Metric Indexes for Incremental Insertion and Querying}},
  year = {2018},
  eprint = {1801.05055},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1801.05055},
}
Figure