pub struct PagedMarkovModel { /* private fields */ }Expand description
Memory-paged Markov model for shell command prediction.
Uses aprender’s bundle module to store n-gram data on disk and load segments on-demand, enabling handling of large shell histories without exhausting RAM.
Implementations§
Source§impl PagedMarkovModel
impl PagedMarkovModel
Sourcepub fn new(n: usize, memory_limit_mb: usize) -> Self
pub fn new(n: usize, memory_limit_mb: usize) -> Self
Create a new paged model with given n-gram size and memory limit.
§Arguments
n- N-gram size (2-5)memory_limit_mb- Maximum memory usage in megabytes
Sourcepub fn memory_limit(&self) -> usize
pub fn memory_limit(&self) -> usize
Get memory limit in bytes.
Sourcepub fn load(path: &Path, memory_limit_mb: usize) -> Result<Self>
pub fn load(path: &Path, memory_limit_mb: usize) -> Result<Self>
Load model from a paged bundle file with memory limit.
Sourcepub fn suggest(&mut self, prefix: &str, count: usize) -> Vec<(String, f32)>
pub fn suggest(&mut self, prefix: &str, count: usize) -> Vec<(String, f32)>
Suggest completions for a prefix.
Sourcepub fn stats(&self) -> PagedModelStats
pub fn stats(&self) -> PagedModelStats
Get model statistics.
Sourcepub fn paging_stats(&self) -> Option<PagingStats>
pub fn paging_stats(&self) -> Option<PagingStats>
Get paging statistics from the bundle.
Sourcepub fn prefetch_hint(&mut self, prefix: &str)
pub fn prefetch_hint(&mut self, prefix: &str)
Hint that a segment will be needed soon (for prefetching).
Sourcepub fn total_commands(&self) -> usize
pub fn total_commands(&self) -> usize
Total commands trained on.
Sourcepub fn ngram_size(&self) -> usize
pub fn ngram_size(&self) -> usize
N-gram size.
Sourcepub fn vocab_size(&self) -> usize
pub fn vocab_size(&self) -> usize
Vocabulary size.
Auto Trait Implementations§
impl Freeze for PagedMarkovModel
impl RefUnwindSafe for PagedMarkovModel
impl Send for PagedMarkovModel
impl Sync for PagedMarkovModel
impl Unpin for PagedMarkovModel
impl UnwindSafe for PagedMarkovModel
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more