Skip to main content

IvfConfig

Struct IvfConfig 

Source
pub struct IvfConfig {
    pub n_list: usize,
    pub nprobe: usize,
    pub training_sample_size: usize,
    pub kmeans_iters: usize,
    pub seed: Option<u64>,
}
Expand description

Configuration for an IVF (Inverted File) index.

IVF partitions the vector space into n_list Voronoi cells via k-means. At query time, only the nprobe cells closest to the query are searched, making search cost roughly O(n_list + nprobe * N / n_list) instead of O(N). Higher nprobe yields higher recall at the cost of latency.

Defaults follow the FAISS convention of n_list ≈ sqrt(N) and nprobe = n_list / 16 for a ~0.95 recall@10 starting point.

Fields§

§n_list: usize

Number of Voronoi cells (centroids).

§nprobe: usize

Number of cells to probe per query.

§training_sample_size: usize

Upper bound on training-sample size used by k-means. The effective sample is min(training_sample_size, input.len()).

§kmeans_iters: usize

Maximum Lloyd iterations during training.

§seed: Option<u64>

Random seed for k-means++ initialisation. None ⇒ non-deterministic.

Implementations§

Source§

impl IvfConfig

Source

pub fn for_dataset_size(n: usize) -> Self

Heuristic n_list ≈ sqrt(N) clamped to a reasonable range.

Trait Implementations§

Source§

impl Clone for IvfConfig

Source§

fn clone(&self) -> IvfConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IvfConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IvfConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for IvfConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for IvfConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,