apply_lz_penalty

Function apply_lz_penalty 

Source
pub fn apply_lz_penalty(logits: &mut [f32], history: &[u32], penalty: f32)
Expand description

2026-09-25: LZ penalty over the last LZ_WINDOW (256) tokens of history.

For each token in that window and each n-gram length 3, 4 and 5, count the earlier n-grams that equal the last n-1 tokens followed by that token, and subtract penalty * (ngram_len - 2) * count from its logit. Token ids at or above logits.len() are skipped.