run480 commited on
Commit
0ef8da0
·
verified ·
1 Parent(s): 8a39d2b

Update app.py

Browse files

Select next word at random from the probability distribution.

Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -178,7 +178,9 @@ def generate(starting_text):
178
 
179
  # The num_beams parameter does a beam search: it returns the sequences that have the highest probability, and then, when it comes time to
180
  # choose, it picks the one that has the highest probability.
181
- gpt2_tensors = mdl.generate(tkn_ids, max_length=100, no_repeat_ngram_size=True, num_beams=3)
 
 
182
  response=""
183
  #response = gpt2_tensors
184
  for i, x in enumerate(gpt2_tensors):
 
178
 
179
  # The num_beams parameter does a beam search: it returns the sequences that have the highest probability, and then, when it comes time to
180
  # choose, it picks the one that has the highest probability.
181
+
182
+ # The do_sample parameter select the next word at random from the probability distribution.
183
+ gpt2_tensors = mdl.generate(tkn_ids, max_length=100, no_repeat_ngram_size=True, num_beams=3, do_sample=True)
184
  response=""
185
  #response = gpt2_tensors
186
  for i, x in enumerate(gpt2_tensors):