MCPcopy
hub / github.com/huggingface/transformers / sample

Function sample

benchmark/benches/llama.py:157–160  ·  view source on GitHub ↗
(logits, temperature: float = 1.0, top_k: int | None = None)

Source from the content-addressed store, hash-verified

155 return probs
156
157 def sample(logits, temperature: float = 1.0, top_k: int | None = None):
158 probs = logits_to_probs(logits[0, -1], temperature, top_k)
159 idx_next = multinomial_sample_one_no_sync(probs)
160 return idx_next, probs
161
162 # First eager forward pass
163 logger.info("running first eager forward pass")

Callers 1

run_benchmarkFunction · 0.85

Calls 2

logits_to_probsFunction · 0.85

Tested by

no test coverage detected