Skip to content

Commit

Permalink
typos before pushing to crates.io
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-pierreBoth committed Dec 20, 2024
1 parent 7ba4a86 commit b2e1469
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ The nearest neighbour of the point is searched in lookup tables from the upper l

The parameter of the exponential law to sample point levels is set to `ln(max_nb_connection)/scale`.
By default *scale* is set to 1. It is possible to reduce the *scale* parameter and thus reduce the number of levels used (See Hnsw::modify_level_scale) without increasing max_nb_connection.
This often provide beter recalls without increasing *max_nb_connection* which increase memory usage. (See examples)
This often provide better recalls without increasing *max_nb_connection* and thus spare memory usage. (See examples)


The main parameters occuring in constructing the graph or in searching are:
Expand Down
8 changes: 4 additions & 4 deletions src/hnsw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,10 @@ impl<'b, T: Clone + Send + Sync, D: Distance<T> + Send + Sync> Hnsw<'b, T, D> {
self.datamap_opt
}

/// By default the levels are sampled using an exponential law of parameter ln(max_nb_conn)
/// so the probability of having more than l levels decrease as exp(-l * ln(max_nb_conn))
/// Reducing the scale change the parameter of the exponential to ln(max_nb_conn)/scale.
/// This reduce the number of levels generated and can provide better precision, reduce memory but with some more cpu used
/// By default the levels are sampled using an exponential law of parameter **ln(max_nb_conn)**
/// so the probability of having more than l levels decrease as **exp(-l * ln(max_nb_conn))**.
/// Reducing the scale change the parameter of the exponential to **ln(max_nb_conn)/scale**.
/// This reduce the number of levels generated and can provide better precision, reduce memory with marginally more cpu used.
/// The factor must between 0.2 and 1.
pub fn modify_level_scale(&mut self, scale_modification: f64) {
//
Expand Down
7 changes: 5 additions & 2 deletions src/hnswio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ impl HnswIo {
}

/// same as preceding, avoids the call to [set_options](Self::set_options())
pub fn new_with_options(directory: &Path, basename: String, options: ReloadOptions) -> Self {
pub fn new_with_options(directory: &Path, basename: &str, options: ReloadOptions) -> Self {
HnswIo {
dir: directory.to_path_buf(),
basename,
basename: basename.to_string(),
options,
datamap: None,
nb_point_loaded: Arc::new(AtomicUsize::new(0)),
Expand Down Expand Up @@ -446,6 +446,7 @@ impl HnswIo {
let data_in = &mut init.datafile;
let graph_in = &mut init.graphfile;
let description = init.descr;
info!("format version : {}", description.format_version);
// In datafile , we must read MAGICDATAP and dimension and check
let mut it_slice = [0u8; std::mem::size_of::<u32>()];
data_in.read_exact(&mut it_slice)?;
Expand Down Expand Up @@ -495,6 +496,7 @@ impl HnswIo {
if datamap_res.is_err() {
error!("load_hnsw could not initialize mmap")
} else {
info!("reload using mmap");
self.datamap = Some(datamap_res.unwrap());
}
}
Expand Down Expand Up @@ -981,6 +983,7 @@ pub fn load_description(io_in: &mut dyn Read) -> Result<Description> {
let mut it_slice = [0u8; std::mem::size_of::<f64>()];
io_in.read_exact(&mut it_slice)?;
descr.level_scale = f64::from_ne_bytes(it_slice);
info!(" level scale : {:.2e}", descr.level_scale);
}
//
let mut it_slice = [0u8; std::mem::size_of::<u8>()];
Expand Down

0 comments on commit b2e1469

Please sign in to comment.