Sampling pipeline: (1) model सभी vocabulary tokens के लिए logits produce करता है, (2) temperature scaling logits को T से divide करता है, (3) top-k filtering केवल k highest logits रखता है (बाकी को −∞ set करता है), (4) top-p filtering tokens का smallest set रखता है जिनकी cumulative probability p exceed करती है, (5) softmax filtered logits को probabilities में convert करता है, (6) इस distribution से randomly एक token sample किया जाता है। Steps 3 और 4 optional हैं और combine किए जा सकते हैं।
Factual/code tasks के लिए: temperature 0 (या बहुत low), कोई top-p/top-k नहीं। आप most likely tokens चाहते हैं। Creative writing के लिए: temperature 0.7–1.0, top-p 0.9–0.95। आप incoherence के बिना diversity चाहते हैं। Brainstorming के लिए: temperature 1.0+, wider top-p। आप surprising, unexpected connections चाहते हैं। Key insight: कोई universal best setting नहीं है। Different tasks को different sampling strategies चाहिए, और optimal parameters model से model भी vary करते हैं।
Advanced strategies में शामिल हैं: beam search (कई candidate sequences maintain करें, overall best चुनें — translation के लिए अच्छा, open-ended generation के लिए कम useful), contrastive decoding (उन tokens को boost करें जहां large model small model से outperform करता है), और min-p sampling (dynamic threshold जो top token की probability के fraction से ऊपर probability वाले tokens रखता है)। ये techniques simple sampling की specific failure modes, जैसे repetition loops या degenerate outputs, को address करती हैं।