-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #473 from drubinstein/voyager
Add voyager to algorithms
- Loading branch information
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ jobs: | |
- vald | ||
- vearch | ||
- vespa | ||
- voyager | ||
- weaviate | ||
include: | ||
- library: pynndescent | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |