OBXHnswQuantType class sealed
Quantization (compression) of the vectors held in memory for the HNSW index (vector search). This only affects the in-memory representation: the vectors persisted on disk always stay unchanged, thus changing the quantization requires no data migration and no re-indexing. The search level (OBXHnswSearchLevel) selects how searches explore and rescore candidates; each quantization type has its own measured levels.
Which type to use (bytes per vector of d dimensions in parentheses; full-precision f32: 4 d):
- TurboQuant4 (the default; d / 2 + 12): the best all-rounder; at the same recall, it is as fast as or faster than the other types on most data, at about 1/8 of f32's memory. Start here.
- ScalarQuant8 (d + 8): for low to medium dimensions (e.g. up to 256) if twice TQ4's memory is acceptable; the most accurate quantized distances, thus the highest recall without rescoring (search levels 1-3) and the fastest type at a medium recall (e.g. 0.9) on such data; slower than TQ4 at high dimensions.
- TurboQuant2, TurboQuant1_5 and TurboQuant1 (d / 4, 3 d / 16 and d / 8, each + 12): only to save memory at high dimensions (e.g. 768+, for TQ1 1000+); in this order, less memory and less recall; lower recall than TQ4 at its speed, slower than TQ4 at its recall; avoid them on low dimensions (e.g. 100-128), where they lose much recall.
- TurboQuant3 (3 d / 8 + 12): rarely useful; between TQ2 and TQ4 in memory at high dimensions, but slower than TQ4 at about its recall; at up to 128 dimensions, it takes more memory than TQ4.
- None (4 d): small data sets, vectors with less than 32 dimensions, or if the exact distances are needed at every search level. The codes are padded to multiples of 32 bytes (e.g. at 100-128 dimensions, TQ1, TQ1.5 and TQ2 take 44 bytes, TQ4 76).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- None → const int
- No quantization; the full-precision vectors are used.
- ScalarQuant8 → const int
- Scalar quantization with 8 bits per dimension ("SQ8"; int8 with one scale per vector, training-free); for low to medium dimensions (e.g. up to 256). It uses about 1/4 of the memory of the full-precision f32 vectors.
- TurboQuant1 → const int
- TurboQuant with 1 bit per dimension ("TQ1"); needs high dimensions (e.g. 1000+). Its search levels rescore from level 3 on (all explored candidates), to compensate for the low precision.
- TurboQuant1_5 → const int
- TurboQuant with 1.5 bits per dimension ("TQ1.5"; 1-bit codes over the vector zero-extended to 1.5x its dimensions); for high dimensions (e.g. 1000+), between TQ1 and TQ2 in memory and recall. Its search levels rescore from level 3 on, to compensate for the low precision.
- TurboQuant2 → const int
- TurboQuant with 2 bits per dimension ("TQ2"); for high dimensions (e.g. 768+). Its search levels rescore from level 3 on, to compensate for the low precision.
- TurboQuant3 → const int
- TurboQuant with 3 bits per dimension ("TQ3"); rarely useful (see above).
- TurboQuant4 → const int
- TurboQuant with 4 bits per dimension ("TQ4"): the default and the recommended quantization. It uses about 1/8 of the memory of the full-precision f32 vectors.
- Undefined → const int
- Not a real type; the default applies (see obx_model_property_index_hnsw_quantization()).