pub struct LogitBias { /* private fields */ }Expand description
Logit-bias stage — applies per-token additive biases and hard bans.
This stage must be positioned before temperature scaling, repetition penalty, and any filtering stages so that bans and biases influence all downstream steps uniformly.
Processing order (matches sampling::mod::apply_logit_bias_and_banned_tokens):
- Banned tokens →
f32::NEG_INFINITY(hard ban, cannot be overridden by bias). - Logit biases are added to surviving logits.
Implementations§
Source§impl LogitBias
impl LogitBias
Sourcepub fn new(biases: HashMap<u32, f32>, banned: Vec<u32>) -> Self
pub fn new(biases: HashMap<u32, f32>, banned: Vec<u32>) -> Self
Create a new logit-bias stage.
biases maps token IDs to additive values (positive = boost,
negative = suppress). banned is the list of tokens to hard-ban.
Sourcepub fn banned_only(banned: Vec<u32>) -> Self
pub fn banned_only(banned: Vec<u32>) -> Self
Create a stage with only hard-banned tokens and no biases.
Sourcepub fn biases_only(biases: HashMap<u32, f32>) -> Self
pub fn biases_only(biases: HashMap<u32, f32>) -> Self
Create a stage with only biases and no bans.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LogitBias
impl RefUnwindSafe for LogitBias
impl Send for LogitBias
impl Sync for LogitBias
impl Unpin for LogitBias
impl UnsafeUnpin for LogitBias
impl UnwindSafe for LogitBias
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> 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