Min-p cuts at a share of the top token
A newer filter, min-p, sets its cut from the top token's probability.
probs = row.softmax(dim=-1)
cut = 0.1 * probs.max()
print(round(cut.item(), 4))
print([w for w, q in zip(words, probs[0]) if q >= cut])
0.0605
['mat', 'floor', 'sofa']
Here the bars are the model's own probabilities, and the line is the cutoff.
- Tokens kept
- 3 of 6
- Cutoff
- 0.0605
- Top token
- 0.67
- Entropy
- 1.20 bits
Min-p keeps every token whose probability is at least times the top token's:
is token 's probability, is the top token's, and is the base you pick. A sure model raises the cutoff, and an unsure one lowers it. Switch the prompts above: the line always sits at a tenth of the top bar, so the sure prompt keeps 1 token and the torn one keeps all 6.
- Nguyen et al. proposed it, and tested of 0.05 and 0.1.
- Hugging Face and vLLM both expose it as
min_p, and they don't even agree on where it goes. Hugging Face applies it after top-p, vLLM before top-k and top-p. - Know the mechanism, and don't oversell it. A 2025 re-analysis by Schaeffer et al. found that the original evidence "fails to support claims that min-p improves quality, diversity, or a trade-off between quality and diversity."
In the editor, rows holds the scores for two prompts, and keep_min_p(logits, base) already has the probabilities. Set cut: base times each row's top probability, as a (B, 1) column. Return the logits with -inf wherever a token's probability is below its row's cut.