Skip to content

Commit

Permalink
Merge pull request #473 from drubinstein/voyager
Browse files Browse the repository at this point in the history
Add voyager to algorithms
  • Loading branch information
erikbern authored Oct 23, 2023
2 parents e6395b7 + ee5519a commit b8cdbdf
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
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

0 comments on commit b8cdbdf

Please sign in to comment.