Use constants as the hannoy default parameters

This commit is contained in:
Clément Renault
2025-07-29 17:16:13 +02:00
committed by Kerollmops
parent 94c1e458bd
commit c9b355369b

View File

@ -41,6 +41,10 @@ pub type Embedding = Vec<f32>;
pub const REQUEST_PARALLELISM: usize = 40; pub const REQUEST_PARALLELISM: usize = 40;
pub const MAX_COMPOSITE_DISTANCE: f32 = 0.01; pub const MAX_COMPOSITE_DISTANCE: f32 = 0.01;
const HANNOY_EF_CONSTRUCTION: usize = 48;
const HANNOY_M: usize = 16;
const HANNOY_M0: usize = 32;
pub struct HannoyWrapper { pub struct HannoyWrapper {
quantized: bool, quantized: bool,
embedder_index: u8, embedder_index: u8,
@ -147,7 +151,10 @@ impl HannoyWrapper {
if self.quantized { if self.quantized {
let writer = hannoy::Writer::new(self.quantized_db(), index, dimension); let writer = hannoy::Writer::new(self.quantized_db(), index, dimension);
if writer.need_build(wtxn)? { if writer.need_build(wtxn)? {
writer.builder(rng).ef_construction(48).build::<16, 32>(wtxn)? writer
.builder(rng)
.ef_construction(HANNOY_EF_CONSTRUCTION)
.build::<HANNOY_M, HANNOY_M0>(wtxn)?
} else if writer.is_empty(wtxn)? { } else if writer.is_empty(wtxn)? {
continue; continue;
} }
@ -173,8 +180,8 @@ impl HannoyWrapper {
.available_memory(hannoy_memory.unwrap_or(usize::MAX)) .available_memory(hannoy_memory.unwrap_or(usize::MAX))
// .progress(|step| progress.update_progress_from_hannoy(step)) // .progress(|step| progress.update_progress_from_hannoy(step))
// .cancel(cancel) // .cancel(cancel)
.ef_construction(48) .ef_construction(HANNOY_EF_CONSTRUCTION)
.build::<16, 32>(wtxn)?; .build::<HANNOY_M, HANNOY_M0>(wtxn)?;
} else if writer.is_empty(wtxn)? { } else if writer.is_empty(wtxn)? {
continue; continue;
} }