Spaces:
Runtime error
Runtime error
Update app.py
Browse filesSelect next word at random from the probability distribution.
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 |
-
|
|
|
|
|
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):
|