A Survey of Graph-based Approximate Nearest Neighbor (ANN)

A Survey of Graph-based Approximate Nearest Neighbor (ANN) (Updating…)

A Comprehensive Survey and Experimental Comparison of Graph-Based Approximate Nearest Neighbor Search

https://arxiv.org/abs/2101.12631

Background

This paper compared graph-based ANN algorithm in a uniform test environment on eight real-world datasets and 12 synthetic datasets with varying sizes and characteristics.

Nearest Neighbor Search (NNS) is a fundamental building block in various application domains. With the explosive growth of datasets’ scale, accurate NNS cannot meet actual requirements for efficiency and cost. Much of the literature has focused on efforts to research approximate NNS (ANNS).

The existing ANNS algorithms can be divided into four major types: (1) hashing-based; (2) tree-based; (3) quantization-based; and (4) graph-based algorithms. Recently, graph-based algorithms have emerged as mainstream for research and practice in academia and industry. They only need to evaluate fewer points of dataset to receive more accurate results.

Graph-based ANNS’ general procedure: Initially, for query vertex q q q, a seed vertex can be randomly sampled as the result vertex r r r, and we can conduct ANNS from this seed vertex. Specifically, if δ ( n , q ) < δ ( r , q ) \delta(n, q)<\delta(r, q) δ(n,q)<δ(r,q), where n n n is one of the neighbors of r , r r, r r,r will be replaced by n n n. We repeat this process until the termination condition (e.g., ∀ n , δ ( n , q ) ≥ δ ( r , q ) \forall n, \delta(n, q) \geq \delta(r, q) n,δ(n,q)δ(r,q) ) is met, and the final r r r (the green vertex) is q q q 's nearest neighbor.

Mathematic Preparation

Notation

  • δ ( ) \delta() δ(): The Euclidean distance between points. The most commonly used distance function is the Euclidean distance δ ( x , y ) ( l 2 \delta(x, y)\left(l_2\right. δ(x,y)(l2 norm): δ ( x , y ) = ∑ i = 0 d − 1 ( x i − y i ) 2 \delta(x, y)=\sqrt{\sum_{i=0}^{d-1}\left(x_i-y_i\right)^2} δ(x,y)=i=0d1(xiyi)2 . The larger the δ ( x , y ) \delta(x, y) δ(x,y), the more dissimilar x x x and y y y are, and the closer to zero, the more similar they are.

  • G ( V , E ) G(V, E) G(V,E): A graph index G where the set of vertices and edges are V and E, respectively

  • N ( v ) N(v) N(v): The neighbors of the vertex v in a graph

Problem Definition

Nearest Neighbor Search (NNS): Given a finite dataset S S S in Euclidean space E d E^d Ed and a query q q q, NNS obtains k k k nearest neighbors R \mathcal{R} R of q q q by evaluating δ ( x , q ) \delta(x, q) δ(x,q), where x ∈ S x \in S xS. R \mathcal{R} R is described as follows: R = arg ⁡ min ⁡ R ⊂ S , ∣ R ∣ = k ∑ x ∈ R δ ( x , q ) \mathcal{R}=\arg \min _{\mathcal{R} \subset S,|R|=k} \sum_{x \in \mathcal{R}} \delta(x, q) R=argminRS,R=kxRδ(x,q).

Approximate Nearest Neighbor Search (ANNS): Given a finite dataset S S S in Euclidean space E d E^d Ed, and a query q q q, ANNS builds an index I I I on S S S. It then gets a subset C C C of S S S by I I I, and evaluates δ ( x , q ) \delta(x, q) δ(x,q) to obtain the approximate k k k nearest neighbors R ~ \tilde{\mathcal{R}} R~ of q q q, where x ∈ C x \in C xC. (Attention! There are two steps, (1) getting a subset C ⊂ R C \subset R CR, (2) find k k k nearest neighbors in C C C)

Generally, we use recall rate Recall@ k = ∣ R ∩ R ~ ∣ k k=\frac{|\mathcal{R} \cap \tilde{\mathcal{R}}|}{k} k=kRR~ to evaluate the search results’ accuracy. ANNS algorithms aim to maximize Recall@ k k k while making C C C as small as possible (e.g., ∣ C ∣ |C| C is only a few thousand when ∣ S ∣ |S| S is millions on the SIFT1M dataset). As mentioned earlier, ANNS algorithms based on graphs have risen in prominence because of their advantages in accuracy versus efficiency. We define graph-based ANNS as follows.

Graph-based ANNS. Given a finite dataset S S S in Euclidean space E d , G ( V , E ) E^d, G(V, E) Ed,G(V,E) denotes a graph (the index I I I in Definition if ANNS) constructed on S , ∀ v ∈ V S, \forall v \in V S,vV that uniquely corresponds to a point x x x in S S S. Here ∀ ( u , v ) ∈ E \forall(u, v) \in E (u,v)E represents the neighbor relationship between u u u and v v v, and u , v ∈ V u, v \in V u,vV. Given a query q q q, seeds S ^ \widehat{S} S , routing strategy, and termination condition, the graph-based ANNS initializes approximate k k k nearest neighbors R ~ \tilde{\mathcal{R}} R~ of q q q with S ^ \widehat{S} S , then conducts a search from S ^ \widehat{S} S and updates R ~ \tilde{\mathcal{R}} R~ via a routing strategy. Finally, it returns the query result R ~ \tilde{\mathcal{R}} R~ once the termination condition is met.

Dataset: The base data and query data comprise high-dimensional feature vectors extracted by deep learning technology (such as VGG [87] for image)

Overview of Graph-based ANNS

Base Graph for ANNS

We first dissect four classic base graphs, including Delaunay Graph , Relative Neighborhood Graph , K-Nearest Neighbor Graph and Minimum Spanning Tree. After that, we review 13 representative graph-based ANNS algorithms working off different optimizations to these base graphs.

Delaunay Graph (DG): In Euclidean space E d E^d Ed, the DG G ( V , E ) G(V, E) G(V,E) constructed on dataset S S S satisfies the following conditions: For ∀ e ∈ E \forall e \in E eE (e.g., the yellow line in Figure 2(a)), where its corresponding two vertices are x , y x, y x,y, there exists a circle (the red circle in Figure 2(a)) passing through x , y x, y x,y, and no other vertices inside the circle, and there are at most three vertices (i.e., x , y , z x, y, z x,y,z ) on the circle at the same time. DG ensures that the ANNS always return precise results [67], but the disadvantage is that DG is almost fully connected when the dimension d d d is extremely high, which leads to a large search space [ 38 , 43 ] [38,43] [38,43].

请添加图片描述

Relative Neighborhood Graph (RNG): In Euclidean space E d E^d Ed, the RNG G ( V , E ) G(V, E) G(V,E) built on dataset S S S has the following property: For x , y ∈ V x, y \in V x,yV, if x x x and y y y are connected by edge e ∈ E e \in E eE, then ∀ z ∈ V \forall z \in V zV, with δ ( x , y ) < δ ( x , z ) \delta(x, y)<\delta(x, z) δ(x,y)<δ(x,z), or δ ( x , y ) < δ ( z , y ) \delta(x, y)<\delta(z, y) δ(x,y)<δ(z,y). In other words, z z z is not in the red lune in Figure 2(b) (for RNG’s standard definition, refer to [92]). Compared with DG, RNG cuts off some redundant neighbors (close to each other) that violate its aforementioned property, and makes the remaining neighbors distribute omnidirectionally, thereby reducing ANNS’ distance calculations [67]. However, the time complexity of constructing RNG on S S S is O ( ∣ S ∣ 3 ) O\left(|S|^3\right) O(S3) [49].

The definition is not that clear here, we provide supplement materials and another example for RNG here:

Consider again a set P P P of n n n distinct points on the plane: P = { p 1 , p 2 , … , p n } P=\left\{p_1, p_2, \ldots, p_n\right\} P={p1,p2,,pn}. There are many possible ways of defining whether or not two points p i p_i pi and p j p_j pj are neighbours of each other. Several definitions are considered [ 18 , 13 , 8 , 10 ] [18,13,8,10] [18,13,8,10]. Lankford [8] defines two points p i p_i pi and p j p_j pj as being “relatively close” if d ( p i , p j ) ≤ max ⁡ [ d ( p i , p k ) , d ( p j , p k ) ] ∀ k = 1 , … , n , k ≠ i , j d\left(p_i, p_j\right) \leq \max \left[d\left(p_i, p_k\right), d\left(p_j, p_k\right)\right] \forall k=1, \ldots, n, k \neq i, j d(pi,pj)max[d(pi,pk),d(pj,pk)]k=1,,n,k=i,j. Actually, Lankford uses ’ < < < ’ rather than ’ ≤ \leq ’ in his definition. The difference is essentially that with this minor modification, in a degenerate situation such as three points lying equidistant from each other, all three points are considered relative neighbours of each other, whereas with only ’ < < < ’ in the definition none of the three points are relative neighbours of each other. Intuitively, the definition states that two points are relative neighbours if they are at least as close to each other as they are to any other point. The relative neighbourhood graph is obtained by connecting an edge between points p i p_i pi and p j p_j pj for all i , j = 1 , … , n , i ≠ j i, j=1, \ldots, n, i \neq j i,j=1,,n,i=j if, and only if, p i p_i pi and p j p_j pj are relative neighbours. Figure 2 illustrates a set of points and its RNG.

请添加图片描述

K-Nearest Neighbor Graph (KNNG): Each point in dataset S S S is connected to its nearest K K K points to form a KNNG G ( V , E ) G(V, E) G(V,E) in Euclidean space E d E^d Ed. As Figure 2 ( c ) ( K = 2 ) 2(\mathrm{c})(K=2) 2(c)(K=2) shows, for x , y ∈ V x, y \in V x,yV, x ∈ N ( y ) = { x , u } x \in N(y)=\{x, u\} xN(y)={x,u}, but y ∉ N ( x ) = { z , v } y \notin N(x)=\{z, v\} y/N(x)={z,v}, where N ( y ) , N ( x ) N(y), N(x) N(y),N(x) are the neighbor sets of y y y and x x x, respectively. Therefore, the edge between y y y and x x x is a directed edge, so KNNG is a directed graph. KNNG limits the number of neighbors of each vertex to K K K at most, thus avoiding the surge of neighbors, which works well in scenarios with limited memory and high demand for efficiency. It can be seen that KNNG does not guarantee global connectivity in Figure 2©, which is unfavorable for ANNS.

Minimum Spanning Tree (MST): In Euclidean space E d E^d Ed, MST is the G ( V , E ) G(V,E) G(V,E) with the smallest ∑ i = 1 ∣ E ∣ w ( e i ) \sum_{i=1}^{|E|} w\left(e_i\right) i=1Ew(ei) on dataset S S S, where the two vertices associated with e i ∈ E e_i \in E eiE are x x x and y , w ( e i ) = δ ( x , y ) y, w\left(e_i\right)=\delta(x, y) y,w(ei)=δ(x,y). If ∃ e i , e j ∈ E , w ( e i ) = w ( e j ) \exists e_i, e_j \in E, w\left(e_i\right)=w\left(e_j\right) ei,ejE,w(ei)=w(ej), then MST is not unique [68]. Although MST has not been adopted by most current graph-based ANNS algorithms, HCNNG [72] confirms MST’s effectiveness as a neighbor selection strategy for ANNS. The main advantage for using MST as a base graph relies on the fact that MST uses the least edges to ensure the graph’s global connectivity, so that keeping vertices with low degrees and any two vertices are reachable. However, because of a lack of shortcuts, it may detour when searching on MST [38, 65]. For example, in Figure 2(d), when search goes from s s s to r r r, it must detour with s → x → y → u → r s \rightarrow x \rightarrow y \rightarrow u \rightarrow r sxyur. This can be avoided if there is an edge between s s s and r r r.

Graph-Based ANNS Algorithms

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值