Table of Contents
Fetching ...

Approximate Nearest Neighbor Search with Window Filters

Joshua Engels, Benjamin Landrum, Shangdi Yu, Laxman Dhulipala, Julian Shun

TL;DR

This work identifies window-based filtering as a critical yet underexplored extension to approximate nearest neighbor search, where each item carries a numeric label and queries specify a label interval. It introduces a modular framework built around a β-Window Search Tree (β-WST) that places ANN indices at internal nodes and traverses a logarithmic-depth search across label ranges, achieving c-approximate window search with provable guarantees when combined with a base ANN like Vamana/DiskANN. Theoretical results give explicit time and memory bounds, including how costs scale with dataset size, doubling dimension, and the base index, and they compare against optimized postfiltering and other baselines. Empirically, the approach delivers up to 75× speedups over strong baselines on diverse datasets (including adversarial embeddings and timestamped image embeddings) while maintaining comparable recall, demonstrating a practical path to efficient window-filtered semantic search in vector databases.

Abstract

We define and investigate the problem of $\textit{c-approximate window search}$: approximate nearest neighbor search where each point in the dataset has a numeric label, and the goal is to find nearest neighbors to queries within arbitrary label ranges. Many semantic search problems, such as image and document search with timestamp filters, or product search with cost filters, are natural examples of this problem. We propose and theoretically analyze a modular tree-based framework for transforming an index that solves the traditional c-approximate nearest neighbor problem into a data structure that solves window search. On standard nearest neighbor benchmark datasets equipped with random label values, adversarially constructed embeddings, and image search embeddings with real timestamps, we obtain up to a $75\times$ speedup over existing solutions at the same level of recall.

Approximate Nearest Neighbor Search with Window Filters

TL;DR

This work identifies window-based filtering as a critical yet underexplored extension to approximate nearest neighbor search, where each item carries a numeric label and queries specify a label interval. It introduces a modular framework built around a β-Window Search Tree (β-WST) that places ANN indices at internal nodes and traverses a logarithmic-depth search across label ranges, achieving c-approximate window search with provable guarantees when combined with a base ANN like Vamana/DiskANN. Theoretical results give explicit time and memory bounds, including how costs scale with dataset size, doubling dimension, and the base index, and they compare against optimized postfiltering and other baselines. Empirically, the approach delivers up to 75× speedups over strong baselines on diverse datasets (including adversarial embeddings and timestamped image embeddings) while maintaining comparable recall, demonstrating a practical path to efficient window-filtered semantic search in vector databases.

Abstract

We define and investigate the problem of : approximate nearest neighbor search where each point in the dataset has a numeric label, and the goal is to find nearest neighbors to queries within arbitrary label ranges. Many semantic search problems, such as image and document search with timestamp filters, or product search with cost filters, are natural examples of this problem. We propose and theoretically analyze a modular tree-based framework for transforming an index that solves the traditional c-approximate nearest neighbor problem into a data structure that solves window search. On standard nearest neighbor benchmark datasets equipped with random label values, adversarially constructed embeddings, and image search embeddings with real timestamps, we obtain up to a speedup over existing solutions at the same level of recall.
Paper Structure (19 sections, 12 theorems, 26 equations, 10 figures, 6 tables, 4 algorithms)

This paper contains 19 sections, 12 theorems, 26 equations, 10 figures, 6 tables, 4 algorithms.

Key Result

Lemma 5.0

alg:build_tree instantiated with a "slow preprocessed" $\alpha$-Vamana graph runs in time and returns a $\beta$-WST of memory

Figures (10)

  • Figure 1: Top left: A $2$-WST. Each node of the tree in green contains a recursive partition of the entire dataset $D$ indexed by an ANNS algorithm (see \ref{['alg:build_tree']}). The graph in each green node represents a graph-based ANNS index built by an algorithm like Vamana. Top right: the structure of an example label space partitioning method that ensures that no optimized postfiltering query will have a large blowup (see \ref{['thm:betterblowup']}). Bottom: Different query methods; from left to right: a tree-based query as in \ref{['alg:query']}, an optimized postfiltering query with a small blowup (see \ref{['def:blowup-factor']}), and an optimized postfiltering query with a large blowup (see \ref{['def:blowup-factor']}).
  • Figure 2: Comparison of Pareto frontiers of all methods on window search with different filter fractions on Deep using 16 threads. Up and to the right is better. On medium filter fraction settings, our methods achieve orders of magnitude more queries per second than the baselines at the same recall levels. Points along the Pareto frontier are denoted by circles for baseline methods and X's for our methods.
  • Figure 3: Comparison of window search methods on Adverse. Up and to the right is better. $\mathsf{Vamana WST}$ and $\mathsf{Three Split}$ achieve a good recall vs. latency tradeoff, but besides the $\mathsf{Prefiltering}$ baseline all of the other methods are unable to achieve a reasonable recall. All methods are run with $16$ threads.
  • Figure 4: Pareto curves of recall vs. throughput on the SIFT dataset for a filter fraction of $2^{-1}$ and varying branching factors $\beta$ for $\mathsf{Vamana WST}$. Up and to the right is better. All trials are run with $16$ threads.
  • Figure 5: Illustration of structure of ranges for \ref{['thm:betterblowup']}.
  • ...and 5 more figures

Theorems & Definitions (23)

  • Definition 3.1
  • Definition 3.2
  • Definition 3.3
  • Definition 3.4
  • Lemma 5.0
  • Theorem 5.1
  • Lemma 5.1
  • Lemma 5.1
  • Definition 5.2
  • Lemma 5.2
  • ...and 13 more