Spaces:
Sleeping
Sleeping
un-index
commited on
Commit
·
9ef03c3
1
Parent(s):
64680d3
app.py
CHANGED
|
@@ -25,7 +25,7 @@ import gradio as gr
|
|
| 25 |
temperature = gr.inputs.Slider(
|
| 26 |
minimum=0, maximum=1.5, default=0.8, label="temperature")
|
| 27 |
top_p = gr.inputs.Slider(minimum=0, maximum=1.0,
|
| 28 |
-
default=0.9, label="
|
| 29 |
|
| 30 |
# gradio checkbutton
|
| 31 |
|
|
@@ -63,11 +63,13 @@ def f(context, temperature, top_p, max_length, model_idx):
|
|
| 63 |
return response['text']
|
| 64 |
else:
|
| 65 |
# use GPT-2
|
| 66 |
-
#
|
| 67 |
set_seed(randint(1, 2**31))
|
| 68 |
# return sequences specifies how many to return
|
| 69 |
json = generator(context, max_length=max_length, top_p=top_p, temperature=temperature, num_return_sequences=1)
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
# args found in the source: https://github.com/huggingface/transformers/blob/27b3031de2fb8195dec9bc2093e3e70bdb1c4bff/src/transformers/generation_tf_utils.py#L348-L376
|
| 72 |
|
| 73 |
except Exception as e:
|
|
|
|
| 25 |
temperature = gr.inputs.Slider(
|
| 26 |
minimum=0, maximum=1.5, default=0.8, label="temperature")
|
| 27 |
top_p = gr.inputs.Slider(minimum=0, maximum=1.0,
|
| 28 |
+
default=0.9, label="top_p")
|
| 29 |
|
| 30 |
# gradio checkbutton
|
| 31 |
|
|
|
|
| 63 |
return response['text']
|
| 64 |
else:
|
| 65 |
# use GPT-2
|
| 66 |
+
# # could easily use the inference API in /gptinference.py but don't know if it supports length>250
|
| 67 |
set_seed(randint(1, 2**31))
|
| 68 |
# return sequences specifies how many to return
|
| 69 |
json = generator(context, max_length=max_length, top_p=top_p, temperature=temperature, num_return_sequences=1)
|
| 70 |
+
print(json)
|
| 71 |
+
return json#['generated_text']
|
| 72 |
+
|
| 73 |
# args found in the source: https://github.com/huggingface/transformers/blob/27b3031de2fb8195dec9bc2093e3e70bdb1c4bff/src/transformers/generation_tf_utils.py#L348-L376
|
| 74 |
|
| 75 |
except Exception as e:
|