Let be the next-token distribution at a decoding step, obtained by soft-maxing the model logits . Let be the set of token IDs we want to discourage.
We modulate the discouragement using the model’s uncertainty at the decoding step, to preserve fluency. When the model is certain about what should be produced next, we intervene softly, when it is uncertain, we apply the maximum intervention strength.
We use Shannon entropy :
and we use it to define a smooth gating coefficient :
where
is the threshold, is a softness parameter, is the logistic function.
To discourage, we intervene in logit space. i.e.:
where the penalty term is controlled by , and is a vector that shapes where the penalty lands over the vocabulary.
Building
Uniform
Unnormalized uniform
topk red
unnorm topk
p_renorm
the effeect is that the total penalty is conserved over and allocated more towards those red tokens that the model currently prefers.
In all normalized modes (uniform, top-KKK, ppp-renormalized), ∑iri=1\sum_i r_i = 1∑iri=1 over the selected subset, ensuring that λ\lambdaλ is interpreted as the total penalty magnitude.
In contrast, the unnormalized top-KKK variant applies the full penalty independently to each selected token, yielding stronger targeted suppression.