Skip to main content

LightweightFilter

Struct LightweightFilter 

Source
pub struct LightweightFilter { /* private fields */ }
Expand description

SafetyMode::Lightweight — a training-free blacklist filter (real). Banned tokens receive a very large negative logit so they cannot be sampled.

Implementations§

Source§

impl LightweightFilter

Source

pub const HARD_BAN: i32 = -1_000_000

Source

pub fn new(banned: Vec<u32>) -> LightweightFilter

Trait Implementations§

Source§

impl SafetySteerer for LightweightFilter

Source§

fn adjust(&self, _recent: &[u32]) -> LogitAdjustment

Source§

fn mode(&self) -> SafetyMode

Source§

fn adjust_with_logits( &self, recent_tokens: &[u32], _base_logits: &[i32], ) -> LogitAdjustment

Logit-aware steering (ADR-013). Given the base model’s next-token logits for this step, return the adjustment to apply (still after the grammar mask, before sampling — the ADR-005 order is unchanged). Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.