MCPcopy Create free account
hub / github.com/cosdata/cosdata / generate_level_probs

Function generate_level_probs

src/models/common.rs:421–429  ·  view source on GitHub ↗

Returns inverse of probabilities for every HNSW level Note that the arg `num_levels` represents HNSW levels, hence level 0 gets implicitly added to the result i.e. if num_levels = 9, then the result will be a vector of size 10 with the last element corresponding to level 0, for which the inverse probability will be 0

(x: f64, num_levels: u8)

Source from the content-addressed store, hash-verified

419/// corresponding to level 0, for which the inverse probability will
420/// be 0
421pub fn generate_level_probs(x: f64, num_levels: u8) -> Vec<(f64, u8)> {
422 let mut result = Vec::new();
423 for n in (0..=num_levels).rev() {
424 let first_item = 1.0 - x.powi(-(n as i32));
425 let second_item = n;
426 result.push((first_item, second_item));
427 }
428 result
429}
430
431//typically skips is 1 while near
432#[allow(dead_code)]

Callers 3

pseudo_level_probsFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by 1