OBXHnswSearchLevel class sealed

Search levels of a HNSW index: the preferred way to trade search speed for quality (recall); see obx_query_param_vector_search_level(). Start from L4_Balanced and adjust from there if you want to optimize the speed/quality trade-off. The levels range from the fastest search (lowest recall) to the highest recall (slowest search); each level costs roughly 1.3-2x the time of the previous one. With quantization, levels 1-3 do not rescore, so their result distances are estimates; levels 4 and higher rescore (TurboQuant1, TurboQuant1_5 and TurboQuant2 already rescore at level 3). Queries without a level search at the index's level (obx_model_property_index_hnsw_search_level(); default: L4_Balanced). The single search parameters (e.g. obx_query_param_vector_oversample_factor()) are for power users only, who tune them for their data. If the highest levels do not reach a recall target, build the graph at a higher build level (OBXHnswBuildLevel) instead. Each quantization type has its own measured levels. The table gives the explored / rescored candidates per level for result_count 10 ("-": no rescoring; other counts scale proportionally, rounded, at least result_count). These values may change in future versions. For TQ4, TQ3 and SQ8, they include the index's default quantization oversample (1.25 with rescoring, 1.5 without) and rescore factor (max(1.5, sqrt(oversample))); changing these index options changes them (obx_model_property_index_hnsw_quantization_oversample() and obx_model_property_index_hnsw_quantization_rescore_factor()). TQ1, TQ1.5 and TQ2 rescore more candidates than TQ4 to compensate for their low precision (TQ1: all explored ones), and their counts are fixed.

Level None (f32) TQ4, TQ3 SQ8 TQ2 TQ1.5 TQ1
1 10 10 / - 10 / - 10 / - 10 / - 10 / -
2 15 15 / - 15 / - 20 / - 15 / - 15 / -
3 20 30 / - 25 / - 20 / 20 20 / 15 20 / 20
4 30 25 / 15 30 / 15 30 / 20 25 / 25 25 / 25
5 40 50 / 20 50 / 20 50 / 30 40 / 40 50 / 50
6 80 100 / 28 100 / 28 100 / 50 100 / 50 70 / 70
7 150 150 / 35 150 / 35 150 / 50 100 / 100 100 / 100
8 250 250 / 45 250 / 45 200 / 200 150 / 150 150 / 150
9 400 400 / 57 400 / 57 300 / 300 200 / 200 300 / 300
10 600 600 / 69 600 / 69 600 / 69 400 / 400 400 / 400

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

L1_Fastest → const int
The fastest: explores only result_count candidates; with quantization, no rescoring (estimated distances)
L2_VeryFast → const int
With quantization, no rescoring (estimated distances)
L3_Fast → const int
With quantization, no rescoring (estimated distances) except for TQ1, TQ1.5 and TQ2
L4_Balanced → const int
The default and a good starting point; with quantization, the best candidates are rescored (exact distances)
L5_BalancedQuality → const int
If level 4 misses too many neighbors; reaches a recall of about 0.97 on "easy" data such as OpenAI embeddings
L6_Quality → const int
If missing a neighbor matters (e.g. for RAG); reaches a recall of about 0.99 on "easy" data
L7_QualityHigh → const int
"Easy" data saturates here; higher levels pay off only on "hard" data (e.g. GloVe word embeddings)
L8_QualityHigher → const int
For "hard" data; on "easy" data, it costs time without gaining recall
L9_QualityUltra → const int
For "hard" data and high recall targets; a higher build level (OBXHnswBuildLevel) is often faster
L10_QualityMax → const int
The highest recall (slowest search); if it misses your recall target, use a higher build level instead