Spaces:
Runtime error
Runtime error
Update app.py
Browse filesSpecify temperature parameter
app.py
CHANGED
@@ -180,7 +180,14 @@ def generate(starting_text):
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
response=""
|
185 |
#response = gpt2_tensors
|
186 |
for i, x in enumerate(gpt2_tensors):
|
|
|
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 |
+
|
184 |
+
# The temperature parameter controls the level of greed that the generative model exhibits.
|
185 |
+
# If the temperature is low, the probabilities of sample classes other than the one with the highest log probability will be low.
|
186 |
+
# As a result, the model will probably output the text that is most correct, but it will be rather monotonous and contain only a small amount of variation.
|
187 |
+
# If the temperature is high, the model has a greater chance of outputting different words than those with the highest probability.
|
188 |
+
# The generated text will feature a greater variety of topics, but there is also an increased likelihood that it will generate nonsense text and
|
189 |
+
# contain grammatical errors.
|
190 |
+
gpt2_tensors = mdl.generate(tkn_ids, max_length=100, no_repeat_ngram_size=True, num_beams=3, do_sample=True, temperature=1.5)
|
191 |
response=""
|
192 |
#response = gpt2_tensors
|
193 |
for i, x in enumerate(gpt2_tensors):
|