Skip to content

Add approximate nearest neighbor backend #2519

Closed

Description

@flying-sheep

Goals:

  • flexibility in creation

  • Neighbor querying API

  • Harmonize storage of backends’ querying indices

    • use it in doublet detection and scanorama reimplementations

Current solution: method arg.

_Method = Literal['umap', 'gauss', 'rapids']

Evaluating options

See ann-benchmarks.com.

Build time vs query time is not straightforward, see erikbern/ann-benchmarks#207 (comment) and erikbern/ann-benchmarks#207 (comment)

If, however, you are simply interested in knn-graph construction then you can get that from pynndescent in less time than even the index construction time (since the prepare phase isn't required, but is a non-trivial part of the index construction time).

Plots for index building are on individual dataset pages, like glove-100-angular.

Used metrics

_MetricSparseCapable = Literal[
'cityblock', 'cosine', 'euclidean', 'l1', 'l2', 'manhattan'
]
_MetricScipySpatial = Literal[
'braycurtis',
'canberra',
'chebyshev',
'correlation',
'dice',
'hamming',
'jaccard',
'kulsinski',
'mahalanobis',
'minkowski',
'rogerstanimoto',
'russellrao',
'seuclidean',
'sokalmichener',
'sokalsneath',
'sqeuclidean',
'yule',
]

Interesting:

Name Demo wheels: Platforms wheels: Python Search speed Index build
NMSLIB 6 notebooks Linux wheels Outdated (3.9) top slow
ScaNN notebook All wheels Slightly outdated (3.10) very fast middling
Faiss wiki –* –* middling to very fast faiss-ivf: top

*no official package on PyPI

Activity

  1. converted this from a draft issue on Jun 19, 2023
  2. changed the title [-]nearest neighbors (backend flexibility)[/-] [+]Add new nearest neighbor backend[/+] on Jun 19, 2023
  3. changed the title [-]Add new nearest neighbor backend[/-] [+]Add approximate nearest neighbor backend[/+] on Jun 19, 2023
  4. adamgayoso commented on Jun 22, 2023

    @adamgayoso
    Member

    faiss was reasonably easy to install via conda and has fairly easy to use gpu support which is nice

  5. flying-sheep commented on Jun 23, 2023

    @flying-sheep
    MemberAuthor

    We’re thinking about making the backend configurable through something like https://github.com/frankier/sklearn-ann (that specific one doesn’t seem maintained though). A recipe for this is found here: https://scikit-learn.org/stable/auto_examples/neighbors/approximate_nearest_neighbors.html#sphx-glr-auto-examples-neighbors-approximate-nearest-neighbors-py

    Faiss does seem nice as an option, but a hard dependency on something that isn’t on PyPI is out of the question.

  6. moved this from meta/ backlog to Done in scanpy 2.0on Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions