Graph-based Nearest Neighbor Search: From Practice to Theory - - PowerPoint PPT Presentation

graph based nearest neighbor search from practice to
SMART_READER_LITE
LIVE PREVIEW

Graph-based Nearest Neighbor Search: From Practice to Theory - - PowerPoint PPT Presentation

Graph-based Nearest Neighbor Search: From Practice to Theory Liudmila Prokhorenkova, Aleksandr Shekhovtsov ICML 2020 Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 1 / 16 Nearest neighbor search Dataset D = { x 1 , . .


slide-1
SLIDE 1

Graph-based Nearest Neighbor Search: From Practice to Theory

Liudmila Prokhorenkova, Aleksandr Shekhovtsov ICML 2020

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 1 / 16

slide-2
SLIDE 2

Nearest neighbor search

Dataset D = {x1, . . . xn}, xi ∈ Rd For a given query q let x ∈ D be its nearest neighbor Exact NNS: find x c-ANN: find such x′ that ρ(q, x′) ≤ cρ(q, x)

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 2 / 16

slide-3
SLIDE 3

Graph-based algorithms

Main idea: Construct a proximity graph, where each element of D is connected to its nearest neighbors For a given query q, take an element in D and make greedy steps towards q on the graph At each step, check the neighbors of the current node

Malkov Y., Yashunin D. “Efficient and robust approximate nearest neighbor search using hierarchical navigable small world graphs”. IEEE transactions on pattern analysis and machine intelligence, 2018.

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 3 / 16

slide-4
SLIDE 4

Graph-based algorithms

Main idea: Construct a proximity graph, where each element of D is connected to its nearest neighbors For a given query q, take an element in D and make greedy steps towards q on the graph At each step, check the neighbors of the current node Additional heuristics: Adding shortcut edges Beam search: maintaining a dynamic list of several candidates instead

  • f just one optimal point

Diversification of neighbors

Malkov Y., Yashunin D. “Efficient and robust approximate nearest neighbor search using hierarchical navigable small world graphs”. IEEE transactions on pattern analysis and machine intelligence, 2018.

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 3 / 16

slide-5
SLIDE 5

Overview of our work

Graph-based methods are known to outperform other approaches in many large-scale applications, but they do not have much theoretical support1 We fill this gap assuming the uniform distribution of data We mostly focus on the dense regime (d ≪ log n) We show the effect of:

◮ Local kNN edges ◮ Properly distributed long edges ◮ Beam search

We empirically motivate our assumptions about dense regime and uniform distribution

1We are aware of one related study: Laarhoven, T. “Graph-based time-space

trade-offs for approximate near neighbors”. SoCG 2018.

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 4 / 16

slide-6
SLIDE 6

Dense and sparse regimes

Dense regime: d ≪ log n Sparse regime: d ≫ log n Assuming the uniform distribution over a d-dimensional sphere: Dense regime: the nearest neighbor is at distance n−1/d → 0 Sparse regime: the nearest neighbor is at distance ≈ √ 2, as other elements

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 5 / 16

slide-7
SLIDE 7

Dense and sparse regimes

Complexity of known exact algorithms scales exponentially in d, which is a problem in sparse regime d ≫ log n. While real-world datasets may have large d, they usually have lower intrinsic dimension. Fortunately, most graph-based algorithms do not care about the original dimension.

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 6 / 16

slide-8
SLIDE 8

Plan: NN graphs in dense regime Shortcut edges Beam search Empirical illustrations

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 7 / 16

slide-9
SLIDE 9

Plain NN graphs in dense regime

For any constant M > 1, let G(M) be a graph obtained by connecting xi and xj iff ρ(xi, xj) ≤ arcsin

  • M n−1/d

.

Theorem (simplified)

Let d ≫ log log n and M > √ 2. Then, with probability 1 − o(1), G(M)-based NNS solves the NN problem. Time complexity is Θ

  • d1/2 · n1/d · Md

. Space complexity is Θ

  • n · d−1/2 · Md · log n
  • .

The expected number of neighbors is Θ(d−1/2 · Md) So, the complexity of one step is Θ(d1/2 · Md) The number of steps is Θ

  • n1/d

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 8 / 16

slide-10
SLIDE 10

Long edges on a lattice

Kleinberg’s result: Consider a 2-dimensional grid Each node has local edges + one random long link The probability of a link from u to v is proportional to ρ(u, v)−r If r = 2, the greedy graph-based search finds the target element in O

  • log2 n
  • steps

Any other r gives at least nϕ with ϕ > 0

Kleinberg J. “The small-world phenomenon: An algorithmic perspective”. ACM symposium on Theory of computing, 2000.

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 9 / 16

slide-11
SLIDE 11

Long edges in our setting

P(edge from u to v) = ρ(u, v)−d

  • w=u ρ(u, w)−d .

Theorem

Sampling one long edge for each node reduces the number of steps to O(log2 n) (with high probability). Importantly, we allow d → ∞

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 10 / 16

slide-12
SLIDE 12

Long edges in our setting

P(edge from u to v) = ρ(u, v)−d

  • w=u ρ(u, w)−d .

Theorem

Sampling one long edge for each node reduces the number of steps to O(log2 n) (with high probability). Importantly, we allow d → ∞ Long edges can guarantee O

  • log2 n
  • steps

Plain NN graphs give Θ

  • n1/d

steps So, reducing the number of steps is reasonable if d <

log n 2 log log n

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 10 / 16

slide-13
SLIDE 13

Dimension-independent probabilities

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 11 / 16

slide-14
SLIDE 14

Dimension-independent probabilities

Let ρrank(u, v) = (k/n)1/d if v is the k-th neighbor of u ρ(u, v) ∝ ρrank(u, v) for uniform datasets (the number of nodes at distance ρ grows as ρd) P(edge to k-th neighbor) ∝ 1 k This distribution is dimension-independent

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 11 / 16

slide-15
SLIDE 15

Beam search

Theorem (informal)

Using beam search allows to get space complexity Ld and time complexity RdLd, where L, R > 1 and L2 1 −

L2 4R2

  • > 1.

In particular, time complexity can be reduced to 27

16

d/2 Without beam search we can get only 2d/2

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 12 / 16

slide-16
SLIDE 16

Beam search

q

c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-17
SLIDE 17

Beam search

q

c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-18
SLIDE 18

Beam search

q

c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-19
SLIDE 19

Beam search

q

c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-20
SLIDE 20

Beam search

q

c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-21
SLIDE 21

Beam search

q

c c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-22
SLIDE 22

Beam search

q

c c c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-23
SLIDE 23

Beam search

q

c c c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-24
SLIDE 24

Beam search

q

c c c c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-25
SLIDE 25

Beam search

q

c c c c c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-26
SLIDE 26

Beam search

q

c c c c c c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-27
SLIDE 27

Beam search

q

c c c c c c c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-28
SLIDE 28

Beam search

q

c c c c c c c c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-29
SLIDE 29

Beam search

q

c c c c c c c c c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-30
SLIDE 30

Beam search

q

c c c c c c c c c c c c c

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

slide-31
SLIDE 31

Synthetic uniform datasets

10

3

10

2

10

1

500 1000 1500 2000 2500

dist calc d = 2

10

3

10

2

10

1

200 300 400 500 600 700

d = 4

10

2

10

1

Error = 1 - Recall@1

200 400 600 800 1000 1200 1400

dist calc d = 8

10

2

10

1

Error = 1 - Recall@1

1000 2000 3000 4000 5000 6000 7000

d = 16 algorithm kNN kNN + Kl kNN + beam kNN + beam + Kl Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 14 / 16

slide-32
SLIDE 32

Uniformization and dimensionality reduction

Our theoretical guarantees hold for uniform data For a general dataset, we can map it to a smaller dimension and make it more uniform while trying to preserve the neighborhoods2 We perform beam search in the lower-dimensional space and then evaluate the candidates in the original space This allows to significantly improve the quality of plain NN graphs supplied with long edges See details in our paper

2Sablayrolles, A., Douze, M., Schmid, C., J´

egou, H. “Spreading vectors for similarity search”. ICLR 2019.

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 15 / 16

slide-33
SLIDE 33

Thank you!

Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 16 / 16