pub trait SafetySteerer {
// Required methods
fn adjust(&self, recent_tokens: &[u32]) -> LogitAdjustment;
fn mode(&self) -> SafetyMode;
// Provided method
fn adjust_with_logits(
&self,
recent_tokens: &[u32],
_base_logits: &[i32],
) -> LogitAdjustment { ... }
}Expand description
Per-step safety intervention. The runtime applies this after the grammar mask and before sampling.
Required Methods§
fn adjust(&self, recent_tokens: &[u32]) -> LogitAdjustment
fn mode(&self) -> SafetyMode
Provided Methods§
Sourcefn adjust_with_logits(
&self,
recent_tokens: &[u32],
_base_logits: &[i32],
) -> LogitAdjustment
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).
The default ignores the logits and delegates to adjust,
so token-only steerers (hard bans, heuristics) need no change. Model-backed
steerers (e.g. ContrastiveSteerer) override this to use the base
distribution. The runtime calls this inside the early-token
soft-steering window and plain adjust outside it, so a
model-backed adjustment costs nothing once the window closes.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".