apply_dry_penalty

Function apply_dry_penalty 

Source
pub fn apply_dry_penalty(
    logits: &mut [f32],
    history: &[u32],
    multiplier: f32,
    base: f32,
    allowed_length: u32,
    breakers: &[u32],
)
Expand description

2026-09-25: DRY (“don’t repeat yourself”) penalty. No-op for an empty history or multiplier == 0.0.

For each earlier position i, match_lengths[i] is the number of tokens that the history ending at i shares with the end of the whole history, counted backwards and stopping after a breaker (0 when history[i] is a breaker). When that length len exceeds allowed_length, the logit of history[i + len] is reduced by multiplier * base^(len - allowed_length).