diskann/graph/config/defaults.rs
1/*
2 * Copyright (c) Microsoft Corporation.
3 * Licensed under the MIT license.
4 */
5
6use std::num::{NonZeroU16, NonZeroU32};
7
8use super::IntraBatchCandidates;
9
10/// A relatively large value to allow a good collection of candidates to be passed to
11/// pruning. Since pruning has quadratic complexity in the number of candidates, a default
12/// value of 750 provides plenty of room for new candidates without leading to excessive
13/// prune times.
14pub const MAX_OCCLUSION_SIZE: NonZeroU16 = NonZeroU16::new(750).unwrap();
15
16/// "Adjacency list saturation" after pruning involves packing the adjcancy list until it
17/// reaches exactly the configured target degree.
18///
19/// This can be useful in situations where the length of adjacency lists is fixed by the
20/// backend data provider.
21///
22/// The `false` default is because this generally slows down index construction.
23pub const SATURATE_AFTER_PRUNE: bool = false;
24
25/// Allow the maximum graph degree to exceed the target degree by up to 1.3x. This provides
26/// an empirically good balance between minimal backedge prunes and memory overhead.
27pub const GRAPH_SLACK_FACTOR: f32 = 1.3;
28
29/// The default occlusion factor for pruning. This is an empirically good value across a
30/// range of datasets and metrics.
31pub const ALPHA: f32 = 1.2;
32
33/// Conservatively defaults to sequential execution.
34pub const MAX_MINIBATCH_PARALLELISM: NonZeroU32 = NonZeroU32::new(1).unwrap();
35
36/// Conservatively consider all candidates within a batch.
37pub const INTRA_BATCH_CANDIDATES: IntraBatchCandidates = IntraBatchCandidates::All;
38
39/// Default beta factor for filtered search.
40/// Values < 1.0 bias the search toward vectors matching the filter.
41pub const FILTER_BETA: f32 = 0.5;