MCPcopy Create free account
hub / github.com/kyegomez/BitNet / top_k

Function top_k

bitnet/at.py:27–32  ·  view source on GitHub ↗
(logits, thres=0.9)

Source from the content-addressed store, hash-verified

25
26
27def top_k(logits, thres=0.9):
28 k = int((1 - thres) * logits.shape[-1])
29 val, ind = torch.topk(logits, k)
30 probs = torch.full_like(logits, float("-inf"))
31 probs.scatter_(1, ind, val)
32 return probs
33
34
35class AutoregressiveWrapper(nn.Module):

Callers 1

generateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected