Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,13 +18,13 @@ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xl", device_m
|
|
18 |
|
19 |
"""###Interface"""
|
20 |
|
21 |
-
def generate(input_text, minimum_length, maximum_length,
|
22 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
|
23 |
outputs = model.generate(input_ids,
|
24 |
min_length=minimum_length,
|
25 |
max_new_tokens=maximum_length,
|
26 |
length_penalty=1.4,
|
27 |
-
num_beams=
|
28 |
no_repeat_ngram_size=3,
|
29 |
temperature=temperature,
|
30 |
top_k=100,
|
@@ -36,12 +36,12 @@ def generate(input_text, minimum_length, maximum_length, beam_amount, temperatur
|
|
36 |
|
37 |
title = "Flan-T5-XL Inference on GRADIO GUI"
|
38 |
|
39 |
-
def inference(input_text, minimum_length, maximum_length,
|
40 |
-
return generate(input_text, minimum_length, maximum_length,
|
41 |
|
42 |
gr.Interface(
|
43 |
fn=inference,
|
44 |
-
inputs=[gr.Textbox(lines=4), gr.Slider(0, 300), gr.Slider(100, 2000
|
45 |
outputs=[
|
46 |
gr.Textbox(lines=2, label="Flan-T5-XL Inference")
|
47 |
],
|
|
|
18 |
|
19 |
"""###Interface"""
|
20 |
|
21 |
+
def generate(input_text, minimum_length, maximum_length, temperature, repetition_penalty):
|
22 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
|
23 |
outputs = model.generate(input_ids,
|
24 |
min_length=minimum_length,
|
25 |
max_new_tokens=maximum_length,
|
26 |
length_penalty=1.4,
|
27 |
+
num_beams=6,
|
28 |
no_repeat_ngram_size=3,
|
29 |
temperature=temperature,
|
30 |
top_k=100,
|
|
|
36 |
|
37 |
title = "Flan-T5-XL Inference on GRADIO GUI"
|
38 |
|
39 |
+
def inference(input_text, minimum_length, maximum_length, temperature, repetition_penalty):
|
40 |
+
return generate(input_text, minimum_length, maximum_length, temperature, repetition_penalty)
|
41 |
|
42 |
gr.Interface(
|
43 |
fn=inference,
|
44 |
+
inputs=[gr.Textbox(lines=4), gr.Slider(0, 300, value=20), gr.Slider(100, 2000, value=1000), gr.Slider(1, 3, step=0.1, value=2.1)],
|
45 |
outputs=[
|
46 |
gr.Textbox(lines=2, label="Flan-T5-XL Inference")
|
47 |
],
|