Top-k sampling
Top-k sampling is a method used in generating text where only the top *k* most likely options are considered at each step. After identifying the top *k* probabilities from a word distribution as predicted by a model, a word is randomly selected from this narrowed pool. This ensures more control over randomness compared to complete probabilistic sampling, balancing coherence and creativity in outputs. It's often compared with nucleus sampling, where choices are determined dynamically based on cumulative probability.