Skip to content

Commit c4e33a8

Browse files
HNSW index: update Flatbuffers generated model files
1 parent 2d4c61c commit c4e33a8

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

objectbox-java/src/main/java/io/objectbox/model/HnswDistanceType.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,29 @@ private HnswDistanceType() { }
3232
* The default; typically "Euclidean squared" internally.
3333
*/
3434
public static final short Euclidean = 1;
35+
/**
36+
* Cosine similarity compares two vectors irrespective of their magnitude (compares the angle of two vectors).
37+
* Often used for document or semantic similarity.
38+
* Value range: 0.0 - 2.0 (0.0: same direction, 1.0: orthogonal, 2.0: opposite direction)
39+
*/
40+
public static final short Cosine = 2;
41+
/**
42+
* For normalized vectors (vector length == 1.0), the dot product is equivalent to the cosine similarity.
43+
* Because of this, the dot product is often preferred as it performs better.
44+
* Value range (normalized vectors): 0.0 - 2.0 (0.0: same direction, 1.0: orthogonal, 2.0: opposite direction)
45+
*/
46+
public static final short DotProduct = 3;
47+
/**
48+
* A custom dot product similarity measure that does not require the vectors to be normalized.
49+
* Note: this is no replacement for cosine similarity (like DotProduct for normalized vectors is).
50+
* The non-linear conversion provides a high precision over the entire float range (for the raw dot product).
51+
* The higher the dot product, the lower the distance is (the nearer the vectors are).
52+
* The more negative the dot product, the higher the distance is (the farther the vectors are).
53+
* Value range: 0.0 - 2.0 (nonlinear; 0.0: nearest, 1.0: orthogonal, 2.0: farthest)
54+
*/
55+
public static final short DotProductNonNormalized = 10;
3556

36-
public static final String[] names = { "Unknown", "Euclidean", };
57+
public static final String[] names = { "Unknown", "Euclidean", "Cosine", "DotProduct", "", "", "", "", "", "", "DotProductNonNormalized", };
3758

3859
public static String name(int e) { return names[e]; }
3960
}

objectbox-java/src/main/java/io/objectbox/model/HnswParams.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public final class HnswParams extends Table {
7171
public long indexingSearchCount() { int o = __offset(8); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
7272
public long flags() { int o = __offset(10); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
7373
/**
74-
* The distance type used for the HNSW index; for now only "Euclidean" is supported.
74+
* The distance type used for the HNSW index; if none is given, the default Euclidean is used.
7575
* Changing this value causes re-indexing.
7676
*/
7777
public int distanceType() { int o = __offset(12); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }

0 commit comments

Comments
 (0)