Skip to content

Small changes to Lucene HNSW runner #1

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions algos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ float:
constructor: LuceneBatch
base-args: ["@metric", "@dimension"]
run-groups:
M-4:
M-16:
arg-groups:
- {"M": 4, "efConstruction": 500}
- {"M": 16, "efConstruction": 100}
query-args: [[10, 20, 40, 80, 120, 200, 400, 600, 800]]

luceneknn:
Expand Down
9 changes: 5 additions & 4 deletions ann_benchmarks/algorithms/luceneknn.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ class LuceneBatch(BaseANN):
"""

def __init__(self, metric: str, dimension: int, param):
self.name = f"luceneknn dim={dimension} {param}"
self.metric = metric
self.dimension = dimension
self.param = param
self.short_name = f"luceneknn-{dimension}-{param['M']}-{param['efConstruction']}"
self.n_iters = -1
self.train_size = -1
#if self.metric not in ("euclidean", "angular"):
if self.metric != "angular":
if self.metric not in ("euclidean", "angular"):
raise NotImplementedError(f"Not implemented for metric {self.metric}")

def fit(self, X):
Expand All @@ -44,6 +42,7 @@ def fit(self, X):

def set_query_arguments(self, fanout):
self.fanout = fanout
self.name = f"luceneknn dim={self.dimension} {self.param} fanout={fanout}"

def query(self, q, n):
raise NotImplementedError(f"Single query testing not implemented: use -batch mode only")
Expand Down Expand Up @@ -82,12 +81,14 @@ def get_batch_results(self):
assert len(batch_res) == self.n_iters
return batch_res


def knn_tester(self, *args):
cmd = ['java',
'-cp', 'lib/*:classes',
'-Xmx2g', '-Xms2g',
'org.apache.lucene.util.hnsw.KnnGraphTester',
'-dim', str(self.dimension)
'-dim', str(self.dimension),
'-metric', str(self.metric)
] + list(args)
sys.stderr.write(str(cmd))
subprocess.run(cmd)
Expand Down