MCPcopy Create free account
hub / github.com/OpenMOSS/MOSS-TTS / softmax

Function softmax

moss_tts_delay/llama_cpp/sampling.py:87–91  ·  view source on GitHub ↗

Numerically stable softmax along last axis.

(logits: np.ndarray)

Source from the content-addressed store, hash-verified

85
86
87def softmax(logits: np.ndarray) -> np.ndarray:
88 """Numerically stable softmax along last axis."""
89 shifted = logits - logits.max(axis=-1, keepdims=True)
90 exp = np.exp(shifted)
91 return exp / exp.sum(axis=-1, keepdims=True)
92
93
94def multinomial(probs: np.ndarray) -> np.ndarray:

Callers 1

sample_tokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected