mirror of
https://github.com/karpathy/nanochat.git
synced 2026-04-16 13:58:38 +00:00
Merge d4d014010b into 41bb2eac32
This commit is contained in:
commit
681c8f9d6e
|
|
@ -440,7 +440,7 @@ class GPT(nn.Module):
|
|||
for _ in range(max_tokens):
|
||||
logits = self.forward(ids) # (B, T, vocab_size)
|
||||
logits = logits[:, -1, :] # (B, vocab_size)
|
||||
if top_k is not None:
|
||||
if top_k is not None and top_k > 0:
|
||||
v, _ = torch.topk(logits, min(top_k, logits.size(-1)))
|
||||
logits[logits < v[:, [-1]]] = -float('Inf')
|
||||
if temperature > 0:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user