pub struct CompressionPredictor { /* private fields */ }Expand description
Compression quality predictor using linear regression with sigmoid output.
Implementations§
Source§impl CompressionPredictor
impl CompressionPredictor
Sourcepub fn from_weights(weights: CompressionModelWeights) -> Self
pub fn from_weights(weights: CompressionModelWeights) -> Self
Create a model from saved weights.
Sourcepub fn sample_count(&self) -> u64
pub fn sample_count(&self) -> u64
Return the number of training samples used.
Sourcepub fn is_cold_start(&self, min_samples: u64) -> bool
pub fn is_cold_start(&self, min_samples: u64) -> bool
Return true if the model has fewer than min_samples training samples.
During cold start, select_ratio returns None and the caller falls back
to default compression behavior.
Sourcepub fn predict(&self, features: &CompressionFeatures) -> f32
pub fn predict(&self, features: &CompressionFeatures) -> f32
Predict probe score for the given features. Range: [0.0, 1.0].
Uses sigmoid(w^T x + b) to bound predictions.
Sourcepub fn train(&mut self, samples: &[(CompressionFeatures, f32)])
pub fn train(&mut self, samples: &[(CompressionFeatures, f32)])
Train the model on a batch of (features, probe_score) pairs using MSE loss.
Runs EPOCHS gradient steps. sample_count is incremented by the batch size
once per train() call (not per epoch) to avoid over-counting.
Sourcepub fn select_ratio(
&self,
floor: f32,
candidate_ratios: &[f32],
message_count: f32,
avg_message_length: f32,
tool_output_fraction: f32,
) -> Option<f32>
pub fn select_ratio( &self, floor: f32, candidate_ratios: &[f32], message_count: f32, avg_message_length: f32, tool_output_fraction: f32, ) -> Option<f32>
Find the most aggressive compression ratio that keeps predicted score >= floor.
Iterates candidate_ratios from lowest (most aggressive) to highest (least aggressive).
Returns the first ratio whose predicted quality clears floor, or None if no
candidate passes (caller should fall back to default behavior).
§Panics
Does not panic; returns None on empty candidate list.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CompressionPredictor
impl RefUnwindSafe for CompressionPredictor
impl Send for CompressionPredictor
impl Sync for CompressionPredictor
impl Unpin for CompressionPredictor
impl UnsafeUnpin for CompressionPredictor
impl UnwindSafe for CompressionPredictor
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request