pub struct NgramDims {
pub vocab_size: u64,
pub ratio: u64,
pub neighbor_num: usize,
pub split_num: usize,
pub eos_token_id: u32,
pub hidden_size: usize,
}Expand description
The n-gram trio + derived dims, extracted from ModelConfig.
Fields§
§vocab_size: u64§ratio: u64§neighbor_num: usizeLargest n-gram size N (>= 2).
split_num: usizeHash splits K per n-gram size.
eos_token_id: u32Implementations§
Source§impl NgramDims
impl NgramDims
pub fn from_config(c: &ModelConfig) -> Option<Self>
pub fn num_tables(&self) -> usize
Sourcepub fn table_dim(&self) -> usize
pub fn table_dim(&self) -> usize
Per-table embedding dim = hidden / num_tables (validated at parse).
Sourcepub fn table_rows(&self, index: usize) -> u64
pub fn table_rows(&self, index: usize) -> u64
Row count of table index: ratio*vocab + 2*index + 1 — the
consecutive odd offsets give the K tables of one n-gram size
distinct (near-coprime) sizes so a collision in one split is
independent of the others.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NgramDims
impl RefUnwindSafe for NgramDims
impl Send for NgramDims
impl Sync for NgramDims
impl Unpin for NgramDims
impl UnwindSafe for NgramDims
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more