Spaces:
Running
Running
Commit
·
1469e49
1
Parent(s):
cce4feb
Added conf params to NER
Browse files
app.py
CHANGED
@@ -83,13 +83,13 @@ def pos(input, model_choice="turna_pos_imst"):
|
|
83 |
return pos_boun(input)[0]["generated_text"]
|
84 |
|
85 |
@spaces.GPU
|
86 |
-
def ner(input, model_choice
|
87 |
if model_choice=="turna_ner_wikiann":
|
88 |
ner_wikiann = pipeline(model="boun-tabi-LMG/turna_ner_wikiann", device=0)
|
89 |
-
return ner_wikiann(input)[0]["generated_text"]
|
90 |
else:
|
91 |
ner_model = pipeline(model="boun-tabi-LMG/turna_ner_milliyet", device=0)
|
92 |
-
return ner_model(input)[0]["generated_text"]
|
93 |
|
94 |
|
95 |
@spaces.GPU
|
@@ -121,7 +121,7 @@ def generate_title(input, model_choice, max_new_tokens, length_penalty, no_repea
|
|
121 |
def categorize(input):
|
122 |
ttc = pipeline(model="boun-tabi-LMG/turna_classification_ttc4900", device=0)
|
123 |
|
124 |
-
return ttc(input)[0]["generated_text"]
|
125 |
|
126 |
@spaces.GPU
|
127 |
def turna(input, max_new_tokens, length_penalty,
|
@@ -201,12 +201,23 @@ with gr.Blocks(theme="abidlabs/Lime") as demo:
|
|
201 |
with gr.Row():
|
202 |
with gr.Column():
|
203 |
ner_choice = gr.Radio(choices = ["turna_ner_wikiann", "turna_ner_milliyet"], label ="Model", value="turna_ner_wikiann")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
ner_input = gr.Textbox(label="NER Input")
|
205 |
ner_submit = gr.Button()
|
206 |
ner_output = gr.Textbox(label="NER Output")
|
207 |
|
208 |
-
ner_submit.click(ner, inputs=[ner_input, ner_choice], outputs=ner_output)
|
209 |
-
ner_examples = gr.Examples(examples = ner_example, inputs = [ner_input, ner_choice], outputs=ner_output, fn=ner)
|
210 |
with gr.Tab("Paraphrase"):
|
211 |
gr.Markdown("TURNA fine-tuned on paraphrasing. Enter text to paraphrase and pick the model.")
|
212 |
with gr.Column():
|
|
|
83 |
return pos_boun(input)[0]["generated_text"]
|
84 |
|
85 |
@spaces.GPU
|
86 |
+
def ner(input, model_choice, max_new_tokens, length_penalty, no_repeat_ngram_size):
|
87 |
if model_choice=="turna_ner_wikiann":
|
88 |
ner_wikiann = pipeline(model="boun-tabi-LMG/turna_ner_wikiann", device=0)
|
89 |
+
return ner_wikiann(input, max_new_tokens = max_new_tokens, length_penalty=length_penalty, no_repeat_ngram_size=no_repeat_ngram_size)[0]["generated_text"]
|
90 |
else:
|
91 |
ner_model = pipeline(model="boun-tabi-LMG/turna_ner_milliyet", device=0)
|
92 |
+
return ner_model(input, max_new_tokens = max_new_tokens, length_penalty=length_penalty, no_repeat_ngram_size=no_repeat_ngram_size)[0]["generated_text"]
|
93 |
|
94 |
|
95 |
@spaces.GPU
|
|
|
121 |
def categorize(input):
|
122 |
ttc = pipeline(model="boun-tabi-LMG/turna_classification_ttc4900", device=0)
|
123 |
|
124 |
+
return ttc(input, max_new_tokens = 8)[0]["generated_text"]
|
125 |
|
126 |
@spaces.GPU
|
127 |
def turna(input, max_new_tokens, length_penalty,
|
|
|
201 |
with gr.Row():
|
202 |
with gr.Column():
|
203 |
ner_choice = gr.Radio(choices = ["turna_ner_wikiann", "turna_ner_milliyet"], label ="Model", value="turna_ner_wikiann")
|
204 |
+
with gr.Accordion("Advanced Generation Parameters"):
|
205 |
+
max_new_tokens = gr.Slider(label = "Maximum length",
|
206 |
+
minimum = 0,
|
207 |
+
maximum = 64,
|
208 |
+
value = 64)
|
209 |
+
length_penalty = gr.Slider(label = "Length penalty",
|
210 |
+
minimum = -10,
|
211 |
+
maximum = 10,
|
212 |
+
value=2.0)
|
213 |
+
no_repeat_ngram_size =gr.Slider(label="No Repeat N-Gram Size", minimum=0,value=3,)
|
214 |
+
with gr.Column():
|
215 |
ner_input = gr.Textbox(label="NER Input")
|
216 |
ner_submit = gr.Button()
|
217 |
ner_output = gr.Textbox(label="NER Output")
|
218 |
|
219 |
+
ner_submit.click(ner, inputs=[ner_input, ner_choice, max_new_tokens, length_penalty, no_repeat_ngram_size], outputs=ner_output)
|
220 |
+
ner_examples = gr.Examples(examples = ner_example, inputs = [ner_input, ner_choice, max_new_tokens, length_penalty, no_repeat_ngram_size], outputs=ner_output, fn=ner)
|
221 |
with gr.Tab("Paraphrase"):
|
222 |
gr.Markdown("TURNA fine-tuned on paraphrasing. Enter text to paraphrase and pick the model.")
|
223 |
with gr.Column():
|