Implement the locally typical filter from Meister et al. 2022.
Signature: def typical_sample_filter(probs: np.ndarray, mass: float) -> np.ndarray
H = -sum(p * log(p)) (use a small epsilon to avoid log(0))|−log(p_i) − H| — how far its surprisal is from the average surprisalmassReturn the new probability vector.
Math
Asked at
import numpy as np
def typical_sample_filter(...):
pass
Premium problem
Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.
Already premium?