-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Permutation LSH (Amato, et. al.) incl. internal support for repeated …
…hashes and improved angular benchmarks (#117) - Added Permutation Lsh model and query, based on paper Large Scale Image Retrieval with Elasticsearch by Amato, et. al. - Support for models with repeated hashes. Only used by Permutation Lsh for now. - Picked better hyperparameters for continuous benchmarks for angular similarity. Increasing k seems to help. - Gradle setting to fail compilation on scala warnings. - Test support for Lucene indexing/queries without Elasticsearch.
- Loading branch information
1 parent
11d6fca
commit 72db321
Showing
33 changed files
with
628 additions
and
155 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
.minio/elastiknn-benchmarks/data/processed/annbglove25/test.json.gz
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
.minio/elastiknn-benchmarks/data/processed/annbglove25/train.json.gz
Git LFS file not shown
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
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
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
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
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
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
52 changes: 52 additions & 0 deletions
52
core/src/main/java/com/klibisz/elastiknn/models/HashAndFreq.java
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,52 @@ | ||
package com.klibisz.elastiknn.models; | ||
|
||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
/** | ||
* As the name suggests, represents a hash value and the number of the times it occurs in some context. | ||
* This enables LSH algorithms where the repetition of a hash has some significance. | ||
*/ | ||
public class HashAndFreq implements Comparable<HashAndFreq> { | ||
private final byte[] hash; | ||
private final int freq; | ||
|
||
public static HashAndFreq once(byte[] hash) { | ||
return new HashAndFreq(hash, 1); | ||
} | ||
|
||
public HashAndFreq(byte[] hash, int freq) { | ||
this.hash = hash; | ||
this.freq = freq; | ||
} | ||
|
||
public byte[] getHash() { | ||
return hash; | ||
} | ||
|
||
public int getFreq() { | ||
return freq; | ||
} | ||
|
||
@Override | ||
public int compareTo(HashAndFreq o) { | ||
byte[] ohash = o.getHash(); | ||
return Arrays.compareUnsigned(hash, 0, hash.length, ohash, 0, ohash.length); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
HashAndFreq that = (HashAndFreq) o; | ||
return freq == that.freq && | ||
Arrays.equals(hash, that.hash); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Objects.hash(freq); | ||
result = 31 * result + Arrays.hashCode(hash); | ||
return result; | ||
} | ||
} |
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
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
Oops, something went wrong.