min_p times the probability of the most likely token.
To sample with it, set min_p in SamplingParams.
When the samples feed an RL loss, also pass the cut-off to the trainer, as described in Match the cut-off in RL losses.
Sample with min-p
To sample with a min-p cut-off, setmin_p in SamplingParams:
Relative probability threshold, in
[0, 1]. With min_p=0.1, a token stays only if its probability is at least 10% of the top token’s probability. 0 turns off the cut-off.Why use min-p
The min-p threshold scales with the probability of the top token, so the cut-off adapts to the model’s confidence at each step:
A higher temperature flattens the distribution and moves probability mass into the long tail of unlikely tokens.
Top-p (
top_p) keeps the most likely tokens until their combined probability reaches top_p.
On a flat distribution, reaching that total takes many tokens, so top-p keeps much of the tail.
Min-p instead compares each token with the top token.
A tail token stays only if its probability reaches min_p times the top token’s, however many other tail tokens there are.
To get more diverse samples with fewer incoherent tokens, raise temperature and set min_p between 0.05 and 0.1.
Match the cut-off in RL losses
The RL lossesimportance_sampling, ppo, cispo, dppo, and dro compare the trainer’s logprobs with the sampler’s logprobs.
The sampler’s logprobs come from the cut-off distribution.
If the trainer scores the full vocabulary instead, each importance ratio exp(new_logprobs - old_logprobs) equals 1 minus the probability mass that the cut-off removed, even when the weights match.
To score each target token over the same tokens the sampler kept, add the cut-off to loss_fn_inputs with one value per position:
SamplingParams, pass the matching input below.
Each input has shape [L], aligned with target_tokens.
- Set each cut-off input on every
Datumin the batch or on none of them. The trainer rejects a batch that sets an input on only some datums. - If you sample at a temperature other than 1, also pass a
temperaturesinput with the sampling temperature at each position. The trainer applies the cut-off to the temperature-scaled distribution, as the sampler does. - Don’t sample with
top_pwhen the samples feed an RL loss. Usemin_palone or withtop_k. The sampler’s top-p implementation can keep less thantop_pof the probability mass. The trainer’s top-p then keeps tokens the sampler couldn’t draw, which pushes the importance ratios below 1. cross_entropy,dpo, andforward_backward_custom()reject cut-off inputs.
Check the cut-off match
With cut-off inputs, the RL losses reportmismatch_cutoff_forced_rate in fb.metrics.
It’s the share of sampled tokens that the trainer’s cut-off would have removed.
The trainer keeps those tokens, because the sampler drew them.
The rate stays well under 1% when the inputs match SamplingParams.
A higher rate means the inputs differ from the settings that produced the samples.
Next steps
- Sampling settings: Set the other
SamplingParamsfields. - Loss functions: Look up the inputs and configuration for each RL loss.
- Check whether an RL run is learning: Monitor the KL divergence between the sampler and trainer.