Zubnet AIसीखेंWiki › Sampling
मूल तत्व

Sampling

इसे भी कहा जाता है: Decoding Strategy, Top-p, Top-k
Model की predicted probability distribution से अगला token generate करने के लिए select करने की प्रक्रिया। Greedy decoding हमेशा most likely token चुनता है। Random sampling probabilities के proportional में चुनता है। Temperature, top-p (nucleus), और top-k ऐसे controls हैं जो selection की randomness और diversity adjust करते हैं। Sampling strategy output quality, creativity, और consistency को dramatically affect करती है।

यह क्यों मायने रखता है

Sampling parameters LLM behavior control करने के सबसे accessible knobs हैं। Deterministic code generation के लिए Temperature 0। Creative writing के लिए Temperature 0.7। अच्छे balance के लिए Top-p 0.9। ये magic numbers नहीं हैं — ये सीधे control करते हैं कि model प्रत्येक step पर कौन से tokens consider करता है। Sampling को समझने से आपको अपने specific use case के लिए outputs tune करने में मदद मिलती है।

गहन अध्ययन

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 किए जा सकते हैं।

Parameters चुनना

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 करते हैं।

Simple Sampling से परे

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 करती हैं।

संबंधित अवधारणाएँ

← सभी शब्द
← SambaNova Sarvam AI →