//! A recognized word gets a dense index (one-based id times four plus the component); any other word a hash of
//! its stem, reduced and shifted, unlike `Qdrant/bm25`'s plain hash despite the model's README.
use cratemurmur_abs_hash;
use cratestem;
/// Sparse entries per recognized word, one per component of the `(19125, 512, 4)` head matrix.
pub const EMBEDDING_SIZE: u32 = 4;
const GAP: u32 = 32_000;
/// The reference's vocabulary size, 19124 real words plus the reserved unrecognized id 0; `SHIFT` is built from it.
pub const VOCAB_SIZE_INCLUDING_UNRECOGNIZED: u32 = 19_125;
/// `((vocab_size * embedding_size) // GAP + 2) * GAP` in the reference, 128000 here: the hashed range starts above
/// every dense index. Fixed, so `MiniCoilSparse::new` checks a loaded matrix against it.
pub const SHIFT: u32 = * GAP;
/// `INT32_MAX - shift` in the reference: the modulus the hashed value is reduced into before `SHIFT` is added.
const RANGE: u32 = i32MAX as u32 - SHIFT;
/// A recognized word's index from its one-based `word_id`, in `4..=76499` for this vocabulary.
/// `SHIFT + abs(murmur3_x86_32(stem(word))) % RANGE`; stems `word` itself, unlike `bm25_hash`.