Skip to main content
Min-p sampling drops every token whose probability is less than 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, set min_p in SamplingParams:
number
default:0
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.
The sampler applies the cut-off to the temperature-scaled distribution and renormalizes over the tokens that remain. Each logprob in the response is the token’s log-probability under this renormalized distribution, which the rest of this page calls the cut-off distribution.

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 losses importance_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:
For each cut-off that you set in SamplingParams, pass the matching input below. Each input has shape [L], aligned with target_tokens.
TensorData
float32 values in [0, 1]. 0 keeps every token at that position.
TensorData
Integer values. 0 or a negative value keeps every token at that position.
TensorData
float32 values in (0, 1]. 1 keeps every token at that position.
  • Set each cut-off input on every Datum in 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 temperatures input 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_p when the samples feed an RL loss. Use min_p alone or with top_k. The sampler’s top-p implementation can keep less than top_p of 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, and forward_backward_custom() reject cut-off inputs.

Check the cut-off match

With cut-off inputs, the RL losses report mismatch_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