Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add voyager to algorithms #473

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
- vald
- vearch
- vespa
- voyager
- weaviate
include:
- library: pynndescent
Expand Down
7 changes: 7 additions & 0 deletions ann_benchmarks/algorithms/voyager/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ann-benchmarks

RUN apt-get install -y python-setuptools python-pip
RUN pip3 install voyager

RUN python3 -c 'import voyager'

45 changes: 45 additions & 0 deletions ann_benchmarks/algorithms/voyager/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
float:
any:
- base_args: ['@metric']
constructor: Voyager
disabled: false
docker_tag: ann-benchmarks-voyager
module: ann_benchmarks.algorithms.voyager
name: voyager
run_groups:
M-12:
arg_groups: [{M: 12, efConstruction: 500}]
args: {}
query_args: [[10, 20, 40, 80, 120, 200, 400, 600, 800]]
M-16:
arg_groups: [{M: 16, efConstruction: 500}]
args: {}
query_args: [[10, 20, 40, 80, 120, 200, 400, 600, 800]]
M-24:
arg_groups: [{M: 24, efConstruction: 500}]
args: {}
query_args: [[10, 20, 40, 80, 120, 200, 400, 600, 800]]
M-36:
arg_groups: [{M: 36, efConstruction: 500}]
args: {}
query_args: [[10, 20, 40, 80, 120, 200, 400, 600, 800]]
M-4:
arg_groups: [{M: 4, efConstruction: 500}]
args: {}
query_args: [[10, 20, 40, 80, 120, 200, 400, 600, 800]]
M-48:
arg_groups: [{M: 48, efConstruction: 500}]
args: {}
query_args: [[10, 20, 40, 80, 120, 200, 400, 600, 800]]
M-64:
arg_groups: [{M: 64, efConstruction: 500}]
args: {}
query_args: [[10, 20, 40, 80, 120, 200, 400, 600, 800]]
M-8:
arg_groups: [{M: 8, efConstruction: 500}]
args: {}
query_args: [[10, 20, 40, 80, 120, 200, 400, 600, 800]]
M-96:
arg_groups: [{M: 96, efConstruction: 500}]
args: {}
query_args: [[10, 20, 40, 80, 120, 200, 400, 600, 800]]
31 changes: 31 additions & 0 deletions ann_benchmarks/algorithms/voyager/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import numpy as np
import voyager

from ..base.module import BaseANN


class Voyager(BaseANN):
def __init__(self, metric, method_param):
self.metric = {"angular": 2, "euclidean": 0}[metric]
self.method_param = method_param
self.name = "voyager (%s)" % (self.method_param)

def fit(self, X):
self.p = voyager.Index(
space=voyager.Space(self.metric),
num_dimensions=len(X[0]),
max_elements=len(X),
ef_construction=self.method_param["efConstruction"],
M=self.method_param["M"],
)
data_labels = np.arange(len(X))
self.p.add_items(np.asarray(X), data_labels)

def set_query_arguments(self, ef):
self.ef = ef

def query(self, v, n):
return self.p.query(np.expand_dims(v, axis=0), k=n, query_ef=self.ef)[0][0]

def freeIndex(self):
del self.p