MCPcopy Create free account
hub / github.com/FunAudioLLM/ThinkSound / sample_top_k

Function sample_top_k

ThinkSound/models/utils.py:54–68  ·  view source on GitHub ↗

Sample next token from top K values along the last dimension of the input probs tensor. Args: probs (torch.Tensor): Input probabilities with token candidates on the last dimension. k (int): The k in “top-k”. Returns: torch.Tensor: Sampled tokens.

(probs: torch.Tensor, k: int)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers

nothing calls this directly

Calls 2

multinomialFunction · 0.85
sumMethod · 0.80

Tested by

no test coverage detected