pub struct ContrastiveSteerer<E>where
E: ExpertLogits,{ /* private fields */ }Expand description
SafetyMode::SecDecoding (or model-backed Lightweight) steerer (ADR-013): a
hard-ban layer applied every step plus contrastive soft steering from
an ExpertLogits source applied only when the runtime supplies base logits
(i.e. inside the early-token window). With no expert divergence it reduces to
the hard-ban behaviour of LightweightFilter; with no bans and a flat
expert it is a no-op.
Implementations§
Source§impl<E> ContrastiveSteerer<E>where
E: ExpertLogits,
impl<E> ContrastiveSteerer<E>where
E: ExpertLogits,
Sourcepub fn new(
expert: E,
banned: Vec<u32>,
alpha_milli: i32,
top_k: usize,
mode: SafetyMode,
) -> ContrastiveSteerer<E>
pub fn new( expert: E, banned: Vec<u32>, alpha_milli: i32, top_k: usize, mode: SafetyMode, ) -> ContrastiveSteerer<E>
mode is the tier label reported to telemetry (Lightweight for a LoRA
expert, SecDecoding for a contrastive base+expert pair).
Trait Implementations§
Source§impl<E> SafetySteerer for ContrastiveSteerer<E>where
E: ExpertLogits,
impl<E> SafetySteerer for ContrastiveSteerer<E>where
E: ExpertLogits,
Source§fn adjust(&self, _recent: &[u32]) -> LogitAdjustment
fn adjust(&self, _recent: &[u32]) -> LogitAdjustment
Out-of-window / token-only path: hard bans only (no expert forward).
Source§fn adjust_with_logits(
&self,
recent: &[u32],
base_logits: &[i32],
) -> LogitAdjustment
fn adjust_with_logits( &self, recent: &[u32], base_logits: &[i32], ) -> LogitAdjustment
In-window path: hard bans plus contrastive soft steering. Bans are
listed first, so a token that is both banned and steered keeps the hard
ban (delta_for returns the first match).