TorchedUp
ProblemsPremium
TorchedUp
Min-P Sampling FilterEasy
ProblemsPremium

Min-P Filtering

Implement the min-p truncation filter for next-token sampling.

Signature: def min_p_filter(probs: np.ndarray, min_p: float) -> np.ndarray

  1. Compute threshold = min_p * probs.max()
  2. Zero out every probability strictly below the threshold
  3. Renormalize so the surviving probabilities sum to 1
  4. Return the new probability vector

Assume probs is already a valid distribution (non-negative, sums to 1).

Math

Asked at

Python (numpy)0/3 runs today

Test Results

○simple truncation and renormalize
○min_p=0 keeps everything
○flat distribution survives🔒 Premium
○filtered probabilities sum to 1
○output is non-negative
○idempotent: filter(filter(p)) = filter(p)
Advertisement