pub struct GenerationState {
pub step: usize,
pub recent_tokens: Vec<u32>,
pub recent_entropies: Vec<f32>,
pub repetition_count: usize,
}Expand description
Current generation state for adaptive decisions.
Fields§
§step: usizeCurrent decoding step (0-indexed).
recent_tokens: Vec<u32>Last N generated tokens (ring-buffer style; most recent last).
recent_entropies: Vec<f32>Shannon entropy (in nats) at each recent step.
repetition_count: usizeNumber of consecutive steps where repeated n-grams were detected.
Implementations§
Source§impl GenerationState
impl GenerationState
Sourcepub fn update(&mut self, token: u32, entropy: f32)
pub fn update(&mut self, token: u32, entropy: f32)
Record a newly generated token and the entropy at this step.
Sourcepub fn recent_repetition_rate(&self, window: usize) -> f32
pub fn recent_repetition_rate(&self, window: usize) -> f32
Fraction of the last window tokens that are identical to the immediately
preceding token (simple unigram repetition rate).
Sourcepub fn mean_recent_entropy(&self, window: usize) -> f32
pub fn mean_recent_entropy(&self, window: usize) -> f32
Mean entropy over the last window steps.
Trait Implementations§
Source§impl Clone for GenerationState
impl Clone for GenerationState
Source§fn clone(&self) -> GenerationState
fn clone(&self) -> GenerationState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GenerationState
impl Debug for GenerationState
Auto Trait Implementations§
impl Freeze for GenerationState
impl RefUnwindSafe for GenerationState
impl Send for GenerationState
impl Sync for GenerationState
impl Unpin for GenerationState
impl UnsafeUnpin for GenerationState
impl UnwindSafe for GenerationState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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