graph based nearest neighbor search from practice to
play

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 , . .


  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

  2. Nearest neighbor search Dataset D = { x 1 , . . . x n } , x i ∈ R d 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

  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

  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 of 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

  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 support 1 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 1 We 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

  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

  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

  8. Plan: NN graphs in dense regime Shortcut edges Beam search Empirical illustrations Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 7 / 16

  9. Plain NN graphs in dense regime For any constant M > 1, let G ( M ) be a graph obtained by connecting x i M n − 1 / d � � and x j iff ρ ( x i , x j ) ≤ arcsin . Theorem (simplified) √ Let d ≫ log log n and M > 2. Then, with probability 1 − o ( 1 ) , G ( M ) -based NNS solves the NN problem. d 1 / 2 · n 1 / d · M d � � Time complexity is Θ . n · d − 1 / 2 · M d · log n � � Space complexity is Θ . The expected number of neighbors is Θ( d − 1 / 2 · M d ) So, the complexity of one step is Θ( d 1 / 2 · M d ) n 1 / d � � The number of steps is Θ Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 8 / 16

  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 log 2 n � � O 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

  11. Long edges in our setting ρ ( u , v ) − d P ( edge from u to v ) = w � = u ρ ( u , w ) − d . � Theorem Sampling one long edge for each node reduces the number of steps to O (log 2 n ) (with high probability). Importantly, we allow d → ∞ Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 10 / 16

  12. Long edges in our setting ρ ( u , v ) − d P ( edge from u to v ) = w � = u ρ ( u , w ) − d . � Theorem Sampling one long edge for each node reduces the number of steps to O (log 2 n ) (with high probability). Importantly, we allow d → ∞ log 2 n � � Long edges can guarantee O steps � n 1 / d � Plain NN graphs give Θ steps log n So, reducing the number of steps is reasonable if d < 2 log log n Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 10 / 16

  13. Dimension-independent probabilities Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 11 / 16

  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

  15. Beam search Theorem (informal) Using beam search allows to get space complexity L d and time complexity R d L d , where L , R > 1 and L 2 � � L 2 1 − > 1. 4 R 2 � 27 � d / 2 In particular, time complexity can be reduced to 16 Without beam search we can get only 2 d / 2 Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 12 / 16

  16. Beam search q c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  17. Beam search q c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  18. Beam search q c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  19. Beam search q c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  20. Beam search q c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  21. Beam search q c c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  22. Beam search q c c c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  23. Beam search q c c c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  24. Beam search c q c c c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  25. Beam search c c q c c c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  26. Beam search c c c q c c c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  27. Beam search c c c q c c c c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  28. Beam search c c c q c c c c c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  29. Beam search c c c c q c c c c c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  30. Beam search c c c c q c c c c c c c c c Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 13 / 16

  31. Synthetic uniform datasets d = 2 d = 4 2500 700 600 2000 500 dist calc 1500 400 1000 300 algorithm kNN 500 200 kNN + Kl kNN + beam 10 3 10 2 10 1 10 3 10 2 10 1 kNN + beam + Kl d = 8 d = 16 7000 1400 6000 1200 5000 1000 dist calc 4000 800 3000 600 2000 400 1000 200 10 2 10 1 10 2 10 1 Error = 1 - Recall@1 Error = 1 - Recall@1 Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 14 / 16

  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 neighborhoods 2 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 2 Sablayrolles, 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

  33. Thank you! Liudmila Prokhorenkova Graph-based Nearest Neighbor Search ICML 2020 16 / 16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend