MCPcopy Create free account
hub / github.com/ml-explore/mlx-examples / sample

Function sample

t5/t5.py:432–436  ·  view source on GitHub ↗
(logits)

Source from the content-addressed store, hash-verified

430
431def generate(prompt: str, model: T5, tokenizer: Tokenizer, temp: Optional[float] = 0.0):
432 def sample(logits):
433 if temp == 0:
434 return mx.argmax(logits, axis=-1)
435 else:
436 return mx.random.categorical(logits * (1 / temp))
437
438 prompt = tokenizer.encode(prompt)
439 decoder_inputs = mx.array([tokenizer.decoder_start_id])

Callers 1

generateFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected