@@ -94,26 +94,26 @@ class HnswFlags(IntEnum):
9494 REPARATION_LIMIT_CANDIDATES = 8
9595
9696
97- class HnswDistanceType (IntEnum ):
98- UNKNOWN = OBXHnswDistanceType_UNKNOWN
99- EUCLIDEAN = OBXHnswDistanceType_EUCLIDEAN
100- COSINE = OBXHnswDistanceType_COSINE
101- DOT_PRODUCT = OBXHnswDistanceType_DOT_PRODUCT
102- DOT_PRODUCT_NON_NORMALIZED = OBXHnswDistanceType_DOT_PRODUCT_NON_NORMALIZED
103-
104- HnswDistanceType .UNKNOWN .__doc__ = "Not a real type, just best practice (e.g. forward compatibility)"
105- HnswDistanceType .EUCLIDEAN .__doc__ = "The default; typically 'euclidean squared' internally."
106- HnswDistanceType .COSINE .__doc__ = """
97+ class VectorDistanceType (IntEnum ):
98+ UNKNOWN = OBXVectorDistanceType_UNKNOWN
99+ EUCLIDEAN = OBXVectorDistanceType_EUCLIDEAN
100+ COSINE = OBXVectorDistanceType_COSINE
101+ DOT_PRODUCT = OBXVectorDistanceType_DOT_PRODUCT
102+ DOT_PRODUCT_NON_NORMALIZED = OBXVectorDistanceType_DOT_PRODUCT_NON_NORMALIZED
103+
104+ VectorDistanceType .UNKNOWN .__doc__ = "Not a real type, just best practice (e.g. forward compatibility)"
105+ VectorDistanceType .EUCLIDEAN .__doc__ = "The default; typically 'euclidean squared' internally."
106+ VectorDistanceType .COSINE .__doc__ = """
107107Cosine similarity compares two vectors irrespective of their magnitude (compares the angle of two vectors).
108108Often used for document or semantic similarity.
109109Value range: 0.0 - 2.0 (0.0: same direction, 1.0: orthogonal, 2.0: opposite direction)
110110"""
111- HnswDistanceType .DOT_PRODUCT .__doc__ = """
111+ VectorDistanceType .DOT_PRODUCT .__doc__ = """
112112For normalized vectors (vector length == 1.0), the dot product is equivalent to the cosine similarity.
113113Because of this, the dot product is often preferred as it performs better.
114114Value range (normalized vectors): 0.0 - 2.0 (0.0: same direction, 1.0: orthogonal, 2.0: opposite direction)
115115"""
116- HnswDistanceType .DOT_PRODUCT_NON_NORMALIZED .__doc__ = """
116+ VectorDistanceType .DOT_PRODUCT_NON_NORMALIZED .__doc__ = """
117117A custom dot product similarity measure that does not require the vectors to be normalized.
118118Note: this is no replacement for cosine similarity (like DotProduct for normalized vectors is).
119119The non-linear conversion provides a high precision over the entire float range (for the raw dot product).
@@ -130,7 +130,7 @@ class HnswIndex:
130130 neighbors_per_node : Optional [int ] = None
131131 indexing_search_count : Optional [int ] = None
132132 flags : HnswFlags = HnswFlags .NONE
133- distance_type : HnswDistanceType = HnswDistanceType .EUCLIDEAN
133+ distance_type : VectorDistanceType = VectorDistanceType .EUCLIDEAN
134134 reparation_backlink_probability : Optional [float ] = None
135135 vector_cache_hint_size_kb : Optional [float ] = None
136136
0 commit comments