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

First attempt at LSH matching with nbits #3679

Closed
Closed
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
9 changes: 5 additions & 4 deletions faiss/index_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,12 @@ Index* parse_other_indexes(
}

// IndexLSH
if (match("LSH(r?)(t?)")) {
bool rotate_data = sm[1].length() > 0;
bool train_thresholds = sm[2].length() > 0;
if (match("LSH([0-9]*)(r?)(t?)")) {
int nbits = sm[1].length() > 0 ? std::stoi(sm[1].str()) : d;
bool rotate_data = sm[2].length() > 0;
bool train_thresholds = sm[3].length() > 0;
FAISS_THROW_IF_NOT(metric == METRIC_L2);
return new IndexLSH(d, d, rotate_data, train_thresholds);
return new IndexLSH(d, nbits, rotate_data, train_thresholds);
}

// IndexLattice
Expand Down
6 changes: 6 additions & 0 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ def test_factory_NSG(self):
assert index.nlist == 65536 and index_nsg.nsg.R == 64
assert index.pq.M == 2 and index.pq.nbits == 8

def test_factory_lsh(self):
index = faiss.index_factory(128, 'LSHrt')
self.assertEqual(index.nbits, 128)
index = faiss.index_factory(128, 'LSH16rt')
self.assertEqual(index.nbits, 16)

def test_factory_fast_scan(self):
index = faiss.index_factory(56, "PQ28x4fs")
self.assertEqual(index.bbs, 32)
Expand Down
Loading