Spaces:
Running
Running
yirmibesogluz
commited on
Commit
·
496bd7a
1
Parent(s):
9d25f83
Added max length to paraphrase
Browse files
app.py
CHANGED
@@ -93,14 +93,14 @@ def ner(input, model_choice="turna_ner_wikiann"):
|
|
93 |
|
94 |
|
95 |
@spaces.GPU
|
96 |
-
def paraphrase(input, model_choice
|
97 |
if model_choice=="turna_paraphrasing_tatoeba":
|
98 |
paraphrasing = pipeline(model="boun-tabi-LMG/turna_paraphrasing_tatoeba", device=0)
|
99 |
-
return paraphrasing(input)[0]["generated_text"]
|
100 |
else:
|
101 |
paraphrasing_sub = pipeline(model="boun-tabi-LMG/turna_paraphrasing_opensubtitles", device=0)
|
102 |
|
103 |
-
return paraphrasing_sub(input)[0]["generated_text"]
|
104 |
|
105 |
@spaces.GPU
|
106 |
def summarize(input, model_choice, max_new_tokens, length_penalty, no_repeat_ngram_size):
|
@@ -205,12 +205,18 @@ with gr.Blocks(theme="abidlabs/Lime") as demo:
|
|
205 |
with gr.Row():
|
206 |
with gr.Column():
|
207 |
paraphrasing_choice = gr.Radio(choices = ["turna_paraphrasing_tatoeba", "turna_paraphrasing_opensubtitles"], label ="Model", value="turna_paraphrasing_tatoeba")
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
paraphrasing_input = gr.Textbox(label = "Paraphrasing Input")
|
209 |
paraphrasing_submit = gr.Button()
|
210 |
paraphrasing_output = gr.Text(label="Paraphrasing Output")
|
211 |
|
212 |
-
paraphrasing_submit.click(paraphrase, inputs=[paraphrasing_input, paraphrasing_choice], outputs=paraphrasing_output)
|
213 |
-
paraphrase_examples = gr.Examples(examples = long_text, inputs = [paraphrasing_input, paraphrasing_choice], outputs=paraphrasing_output, fn=paraphrase)
|
214 |
with gr.Tab("Summarization"):
|
215 |
gr.Markdown("TURNA fine-tuned on summarization. Enter text to summarize and pick the model.")
|
216 |
with gr.Column():
|
|
|
93 |
|
94 |
|
95 |
@spaces.GPU
|
96 |
+
def paraphrase(input, model_choice, max_new_tokens):
|
97 |
if model_choice=="turna_paraphrasing_tatoeba":
|
98 |
paraphrasing = pipeline(model="boun-tabi-LMG/turna_paraphrasing_tatoeba", device=0)
|
99 |
+
return paraphrasing(input, max_new_tokens = max_new_tokens)[0]["generated_text"]
|
100 |
else:
|
101 |
paraphrasing_sub = pipeline(model="boun-tabi-LMG/turna_paraphrasing_opensubtitles", device=0)
|
102 |
|
103 |
+
return paraphrasing_sub(input, max_new_tokens = max_new_tokens)[0]["generated_text"]
|
104 |
|
105 |
@spaces.GPU
|
106 |
def summarize(input, model_choice, max_new_tokens, length_penalty, no_repeat_ngram_size):
|
|
|
205 |
with gr.Row():
|
206 |
with gr.Column():
|
207 |
paraphrasing_choice = gr.Radio(choices = ["turna_paraphrasing_tatoeba", "turna_paraphrasing_opensubtitles"], label ="Model", value="turna_paraphrasing_tatoeba")
|
208 |
+
with gr.Accordion("Advanced Generation Parameters"):
|
209 |
+
max_new_tokens = gr.Slider(label = "Maximum length",
|
210 |
+
minimum = 0,
|
211 |
+
maximum = 20,
|
212 |
+
value = 20)
|
213 |
+
with gr.Column():
|
214 |
paraphrasing_input = gr.Textbox(label = "Paraphrasing Input")
|
215 |
paraphrasing_submit = gr.Button()
|
216 |
paraphrasing_output = gr.Text(label="Paraphrasing Output")
|
217 |
|
218 |
+
paraphrasing_submit.click(paraphrase, inputs=[paraphrasing_input, paraphrasing_choice, max_new_tokens], outputs=paraphrasing_output)
|
219 |
+
paraphrase_examples = gr.Examples(examples = long_text, inputs = [paraphrasing_input, paraphrasing_choice, max_new_tokens], outputs=paraphrasing_output, fn=paraphrase)
|
220 |
with gr.Tab("Summarization"):
|
221 |
gr.Markdown("TURNA fine-tuned on summarization. Enter text to summarize and pick the model.")
|
222 |
with gr.Column():
|