@@ -110,10 +110,14 @@ impl IndexOptions {
110
110
) -> Result < ( ) , ValidationError > {
111
111
match quantization {
112
112
None => Ok ( ( ) ) ,
113
- Some ( QuantizationOptions :: Scalar ( _) | QuantizationOptions :: Product ( _) ) => {
113
+ Some (
114
+ QuantizationOptions :: Scalar ( _)
115
+ | QuantizationOptions :: Product ( _)
116
+ | QuantizationOptions :: Rabitq ( _) ,
117
+ ) => {
114
118
if !matches ! ( self . vector. v, VectorKind :: Vecf32 | VectorKind :: Vecf16 ) {
115
119
return Err ( ValidationError :: new (
116
- "scalar quantization or product quantization is not support for vectors that are not dense vectors" ,
120
+ "quantization is not support for vectors that are not dense vectors" ,
117
121
) ) ;
118
122
}
119
123
Ok ( ( ) )
@@ -148,18 +152,6 @@ impl IndexOptions {
148
152
) ) ;
149
153
}
150
154
}
151
- IndexingOptions :: Rabitq ( _) => {
152
- if !matches ! ( self . vector. d, DistanceKind :: L2 | DistanceKind :: Dot ) {
153
- return Err ( ValidationError :: new (
154
- "rabitq is not support for distance that is not l2 or dot" ,
155
- ) ) ;
156
- }
157
- if !matches ! ( self . vector. v, VectorKind :: Vecf32 ) {
158
- return Err ( ValidationError :: new (
159
- "rabitq is not support for vectors that are not vector" ,
160
- ) ) ;
161
- }
162
- }
163
155
}
164
156
Ok ( ( ) )
165
157
}
@@ -293,7 +285,6 @@ pub enum IndexingOptions {
293
285
Ivf ( IvfIndexingOptions ) ,
294
286
Hnsw ( HnswIndexingOptions ) ,
295
287
InvertedIndex ( InvertedIndexingOptions ) ,
296
- Rabitq ( RabitqIndexingOptions ) ,
297
288
}
298
289
299
290
impl IndexingOptions {
@@ -315,12 +306,6 @@ impl IndexingOptions {
315
306
} ;
316
307
x
317
308
}
318
- pub fn unwrap_rabitq ( self ) -> RabitqIndexingOptions {
319
- let IndexingOptions :: Rabitq ( x) = self else {
320
- unreachable ! ( )
321
- } ;
322
- x
323
- }
324
309
}
325
310
326
311
impl Default for IndexingOptions {
@@ -336,7 +321,6 @@ impl Validate for IndexingOptions {
336
321
Self :: Ivf ( x) => x. validate ( ) ,
337
322
Self :: Hnsw ( x) => x. validate ( ) ,
338
323
Self :: InvertedIndex ( x) => x. validate ( ) ,
339
- Self :: Rabitq ( x) => x. validate ( ) ,
340
324
}
341
325
}
342
326
}
@@ -440,53 +424,21 @@ impl Default for HnswIndexingOptions {
440
424
}
441
425
}
442
426
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
- #[ serde( default = "RabitqIndexingOptions::default_spherical_centroids" ) ]
450
- pub spherical_centroids : bool ,
451
- #[ serde( default = "RabitqIndexingOptions::default_residual_quantization" ) ]
452
- pub residual_quantization : bool ,
453
- }
454
-
455
- impl RabitqIndexingOptions {
456
- fn default_nlist ( ) -> u32 {
457
- 1000
458
- }
459
- fn default_spherical_centroids ( ) -> bool {
460
- false
461
- }
462
- fn default_residual_quantization ( ) -> bool {
463
- false
464
- }
465
- }
466
-
467
- impl Default for RabitqIndexingOptions {
468
- fn default ( ) -> Self {
469
- Self {
470
- nlist : Self :: default_nlist ( ) ,
471
- spherical_centroids : Self :: default_spherical_centroids ( ) ,
472
- residual_quantization : Self :: default_residual_quantization ( ) ,
473
- }
474
- }
475
- }
476
-
477
427
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
478
428
#[ serde( deny_unknown_fields) ]
479
429
#[ serde( rename_all = "snake_case" ) ]
480
430
pub enum QuantizationOptions {
481
431
Scalar ( ScalarQuantizationOptions ) ,
482
432
Product ( ProductQuantizationOptions ) ,
433
+ Rabitq ( RabitqQuantizationOptions ) ,
483
434
}
484
435
485
436
impl Validate for QuantizationOptions {
486
437
fn validate ( & self ) -> Result < ( ) , validator:: ValidationErrors > {
487
438
match self {
488
439
Self :: Scalar ( x) => x. validate ( ) ,
489
440
Self :: Product ( x) => x. validate ( ) ,
441
+ Self :: Rabitq ( x) => x. validate ( ) ,
490
442
}
491
443
}
492
444
}
@@ -554,6 +506,18 @@ impl Default for ProductQuantizationOptions {
554
506
}
555
507
}
556
508
509
+ #[ derive( Debug , Clone , Serialize , Deserialize , Validate ) ]
510
+ #[ serde( deny_unknown_fields) ]
511
+ pub struct RabitqQuantizationOptions { }
512
+
513
+ impl RabitqQuantizationOptions { }
514
+
515
+ impl Default for RabitqQuantizationOptions {
516
+ fn default ( ) -> Self {
517
+ Self { }
518
+ }
519
+ }
520
+
557
521
#[ derive( Debug , Clone , Serialize , Deserialize , Validate , Alter ) ]
558
522
#[ serde( deny_unknown_fields) ]
559
523
pub struct SearchOptions {
@@ -567,23 +531,14 @@ pub struct SearchOptions {
567
531
pub pq_rerank_size : u32 ,
568
532
#[ serde( default = "SearchOptions::default_pq_fast_scan" ) ]
569
533
pub pq_fast_scan : bool ,
534
+ #[ serde( default = "SearchOptions::default_rq_fast_scan" ) ]
535
+ pub rq_fast_scan : bool ,
570
536
#[ serde( default = "SearchOptions::default_ivf_nprobe" ) ]
571
537
#[ validate( range( min = 1 , max = 65535 ) ) ]
572
538
pub ivf_nprobe : u32 ,
573
539
#[ serde( default = "SearchOptions::default_hnsw_ef_search" ) ]
574
540
#[ validate( range( min = 1 , max = 65535 ) ) ]
575
541
pub hnsw_ef_search : u32 ,
576
- #[ serde( default = "SearchOptions::default_rabitq_nprobe" ) ]
577
- #[ validate( range( min = 1 , max = 65535 ) ) ]
578
- pub rabitq_nprobe : u32 ,
579
- #[ serde( default = "SearchOptions::default_rabitq_epsilon" ) ]
580
- #[ validate( range( min = 1.0 , max = 4.0 ) ) ]
581
- pub rabitq_epsilon : f32 ,
582
- #[ serde( default = "SearchOptions::default_rabitq_fast_scan" ) ]
583
- pub rabitq_fast_scan : bool ,
584
- #[ serde( default = "SearchOptions::default_diskann_ef_search" ) ]
585
- #[ validate( range( min = 1 , max = 65535 ) ) ]
586
- pub diskann_ef_search : u32 ,
587
542
}
588
543
589
544
impl SearchOptions {
@@ -599,24 +554,15 @@ impl SearchOptions {
599
554
pub const fn default_pq_fast_scan ( ) -> bool {
600
555
false
601
556
}
557
+ pub const fn default_rq_fast_scan ( ) -> bool {
558
+ true
559
+ }
602
560
pub const fn default_ivf_nprobe ( ) -> u32 {
603
561
10
604
562
}
605
563
pub const fn default_hnsw_ef_search ( ) -> u32 {
606
564
100
607
565
}
608
- pub const fn default_rabitq_nprobe ( ) -> u32 {
609
- 10
610
- }
611
- pub const fn default_rabitq_epsilon ( ) -> f32 {
612
- 1.9
613
- }
614
- pub const fn default_rabitq_fast_scan ( ) -> bool {
615
- true
616
- }
617
- pub const fn default_diskann_ef_search ( ) -> u32 {
618
- 100
619
- }
620
566
}
621
567
622
568
impl Default for SearchOptions {
@@ -626,12 +572,9 @@ impl Default for SearchOptions {
626
572
sq_fast_scan : Self :: default_sq_fast_scan ( ) ,
627
573
pq_rerank_size : Self :: default_pq_rerank_size ( ) ,
628
574
pq_fast_scan : Self :: default_pq_fast_scan ( ) ,
575
+ rq_fast_scan : Self :: default_rq_fast_scan ( ) ,
629
576
ivf_nprobe : Self :: default_ivf_nprobe ( ) ,
630
577
hnsw_ef_search : Self :: default_hnsw_ef_search ( ) ,
631
- rabitq_nprobe : Self :: default_rabitq_nprobe ( ) ,
632
- rabitq_epsilon : Self :: default_rabitq_epsilon ( ) ,
633
- rabitq_fast_scan : Self :: default_rabitq_fast_scan ( ) ,
634
- diskann_ef_search : Self :: default_diskann_ef_search ( ) ,
635
578
}
636
579
}
637
580
}
0 commit comments