@@ -118,14 +118,6 @@ impl IndexOptions {
118
118
}
119
119
Ok ( ( ) )
120
120
}
121
- QuantizationOptions :: RaBitQ ( _) => {
122
- if !matches ! ( self . vector. v, VectorKind :: Vecf32 ) {
123
- return Err ( ValidationError :: new (
124
- "scalar quantization or product quantization is not support for `vector`" ,
125
- ) ) ;
126
- }
127
- Ok ( ( ) )
128
- }
129
121
}
130
122
}
131
123
fn validate_self ( & self ) -> Result < ( ) , ValidationError > {
@@ -156,6 +148,18 @@ impl IndexOptions {
156
148
) ) ;
157
149
}
158
150
}
151
+ IndexingOptions :: Rabitq ( _) => {
152
+ if !matches ! ( self . vector. d, DistanceKind :: L2 ) {
153
+ return Err ( ValidationError :: new (
154
+ "inverted_index is not support for distance that is not l2" ,
155
+ ) ) ;
156
+ }
157
+ if !matches ! ( self . vector. v, VectorKind :: Vecf32 ) {
158
+ return Err ( ValidationError :: new (
159
+ "inverted_index is not support for vectors that are not vector" ,
160
+ ) ) ;
161
+ }
162
+ }
159
163
}
160
164
Ok ( ( ) )
161
165
}
@@ -289,6 +293,7 @@ pub enum IndexingOptions {
289
293
Ivf ( IvfIndexingOptions ) ,
290
294
Hnsw ( HnswIndexingOptions ) ,
291
295
InvertedIndex ( InvertedIndexingOptions ) ,
296
+ Rabitq ( RabitqIndexingOptions ) ,
292
297
}
293
298
294
299
impl IndexingOptions {
@@ -310,6 +315,12 @@ impl IndexingOptions {
310
315
} ;
311
316
x
312
317
}
318
+ pub fn unwrap_rabitq ( self ) -> RabitqIndexingOptions {
319
+ let IndexingOptions :: Rabitq ( x) = self else {
320
+ unreachable ! ( )
321
+ } ;
322
+ x
323
+ }
313
324
}
314
325
315
326
impl Default for IndexingOptions {
@@ -324,7 +335,8 @@ impl Validate for IndexingOptions {
324
335
Self :: Flat ( x) => x. validate ( ) ,
325
336
Self :: Ivf ( x) => x. validate ( ) ,
326
337
Self :: Hnsw ( x) => x. validate ( ) ,
327
- Self :: InvertedIndex ( _) => Ok ( ( ) ) ,
338
+ Self :: InvertedIndex ( x) => x. validate ( ) ,
339
+ Self :: Rabitq ( x) => x. validate ( ) ,
328
340
}
329
341
}
330
342
}
@@ -428,15 +440,35 @@ impl Default for HnswIndexingOptions {
428
440
}
429
441
}
430
442
443
+ #[ derive( Debug , Clone , Serialize , Deserialize , Validate ) ]
444
+ #[ serde( deny_unknown_fields) ]
445
+ pub struct RabitqIndexingOptions {
446
+ #[ serde( default = "RabitqIndexingOptions::default_nlist" ) ]
447
+ #[ validate( range( min = 1 , max = 1_000_000 ) ) ]
448
+ pub nlist : u32 ,
449
+ }
450
+
451
+ impl RabitqIndexingOptions {
452
+ fn default_nlist ( ) -> u32 {
453
+ 1000
454
+ }
455
+ }
456
+
457
+ impl Default for RabitqIndexingOptions {
458
+ fn default ( ) -> Self {
459
+ Self {
460
+ nlist : Self :: default_nlist ( ) ,
461
+ }
462
+ }
463
+ }
464
+
431
465
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
432
466
#[ serde( deny_unknown_fields) ]
433
467
#[ serde( rename_all = "snake_case" ) ]
434
468
pub enum QuantizationOptions {
435
469
Trivial ( TrivialQuantizationOptions ) ,
436
470
Scalar ( ScalarQuantizationOptions ) ,
437
471
Product ( ProductQuantizationOptions ) ,
438
- #[ serde( rename = "rabitq" ) ]
439
- RaBitQ ( RaBitQuantizationOptions ) ,
440
472
}
441
473
442
474
impl Validate for QuantizationOptions {
@@ -445,7 +477,6 @@ impl Validate for QuantizationOptions {
445
477
Self :: Trivial ( x) => x. validate ( ) ,
446
478
Self :: Scalar ( x) => x. validate ( ) ,
447
479
Self :: Product ( x) => x. validate ( ) ,
448
- Self :: RaBitQ ( x) => x. validate ( ) ,
449
480
}
450
481
}
451
482
}
@@ -466,16 +497,6 @@ impl Default for TrivialQuantizationOptions {
466
497
}
467
498
}
468
499
469
- #[ derive( Debug , Clone , Serialize , Deserialize , Validate ) ]
470
- #[ serde( deny_unknown_fields) ]
471
- pub struct RaBitQuantizationOptions { }
472
-
473
- impl Default for RaBitQuantizationOptions {
474
- fn default ( ) -> Self {
475
- Self { }
476
- }
477
- }
478
-
479
500
#[ derive( Debug , Clone , Serialize , Deserialize , Validate ) ]
480
501
#[ serde( deny_unknown_fields) ]
481
502
#[ validate( schema( function = "Self::validate_self" ) ) ]
@@ -558,6 +579,9 @@ pub struct SearchOptions {
558
579
#[ validate( range( min = 1 , max = 65535 ) ) ]
559
580
pub hnsw_ef_search : u32 ,
560
581
#[ validate( range( min = 1 , max = 65535 ) ) ]
582
+ pub rabitq_nprobe : u32 ,
583
+ pub rabitq_fast_scan : bool ,
584
+ #[ validate( range( min = 1 , max = 65535 ) ) ]
561
585
pub diskann_ef_search : u32 ,
562
586
}
563
587
0 commit comments