Spaces:
Sleeping
Sleeping
un-index
commited on
Commit
·
2389098
1
Parent(s):
571d832
app.py
CHANGED
|
@@ -123,7 +123,13 @@ def f(context, temperature, top_p, max_length, model_idx):
|
|
| 123 |
#
|
| 124 |
set_seed(randint(1, 2**31))
|
| 125 |
# return sequences specifies how many to return
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
# args found in the source: https://github.com/huggingface/transformers/blob/27b3031de2fb8195dec9bc2093e3e70bdb1c4bff/src/transformers/generation_tf_utils.py#L348-L376
|
| 128 |
|
| 129 |
# use fallback gpt-2 inference api for this as well
|
|
|
|
| 123 |
#
|
| 124 |
set_seed(randint(1, 2**31))
|
| 125 |
# return sequences specifies how many to return
|
| 126 |
+
|
| 127 |
+
try:
|
| 128 |
+
generated_text = generator(context, max_length=max_length, top_p=top_p, temperature=temperature, num_return_sequences=1)[0]['generated_text']
|
| 129 |
+
except:
|
| 130 |
+
generated_text = generator(context, max_length=max_length, top_p=top_p, temperature=temperature, num_return_sequences=1)[0]
|
| 131 |
+
|
| 132 |
+
return generated_text
|
| 133 |
# args found in the source: https://github.com/huggingface/transformers/blob/27b3031de2fb8195dec9bc2093e3e70bdb1c4bff/src/transformers/generation_tf_utils.py#L348-L376
|
| 134 |
|
| 135 |
# use fallback gpt-2 inference api for this as well
|