yoonusajwardapiit commited on
Commit
64226ef
1 Parent(s): 837ecd8

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -0
app.py CHANGED
@@ -87,6 +87,7 @@ class BigramLanguageModel(nn.Module):
87
  logits = logits[:, -1, :] # Get the logits for the last token
88
  probs = nn.functional.softmax(logits, dim=-1)
89
  idx_next = torch.multinomial(probs, num_samples=1)
 
90
  idx = torch.cat((idx, idx_next), dim=1)
91
  return idx
92
 
 
87
  logits = logits[:, -1, :] # Get the logits for the last token
88
  probs = nn.functional.softmax(logits, dim=-1)
89
  idx_next = torch.multinomial(probs, num_samples=1)
90
+ idx_next = torch.clamp(idx_next, max=60) # Cap the generated index to max 60
91
  idx = torch.cat((idx, idx_next), dim=1)
92
  return idx
93