Spaces:
Sleeping
Sleeping
yirmibesogluz
commited on
Commit
•
ca68a3c
1
Parent(s):
1469e49
Added conf params to POS
Browse files
app.py
CHANGED
@@ -74,13 +74,13 @@ def sentiment_analysis(input, model_choice="turna_classification_17bintweet_sent
|
|
74 |
return sentiment_model(input, max_new_tokens = 4)[0]["generated_text"]
|
75 |
|
76 |
@spaces.GPU
|
77 |
-
def pos(input, model_choice
|
78 |
if model_choice=="turna_pos_imst":
|
79 |
pos_imst = pipeline(model="boun-tabi-LMG/turna_pos_imst", device=0)
|
80 |
-
return pos_imst(input)[0]["generated_text"]
|
81 |
else:
|
82 |
pos_boun = pipeline(model="boun-tabi-LMG/turna_pos_boun", device=0)
|
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):
|
@@ -188,12 +188,22 @@ with gr.Blocks(theme="abidlabs/Lime") as demo:
|
|
188 |
with gr.Row():
|
189 |
with gr.Column():
|
190 |
pos_choice = gr.Radio(choices = ["turna_pos_imst", "turna_pos_boun"], label ="Model", value="turna_pos_imst")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
pos_input = gr.Textbox(label="POS Input")
|
192 |
-
|
193 |
pos_submit = gr.Button()
|
194 |
pos_output = gr.Textbox(label="POS Output")
|
195 |
-
pos_submit.click(pos, inputs=[pos_input, pos_choice], outputs=pos_output)
|
196 |
-
pos_examples = gr.Examples(examples = ner_example, inputs = [pos_input, pos_choice], outputs=pos_output, fn=pos)
|
197 |
|
198 |
with gr.Tab("NER"):
|
199 |
gr.Markdown("TURNA fine-tuned on named entity recognition. Enter text to parse named entities and pick the model.")
|
|
|
74 |
return sentiment_model(input, max_new_tokens = 4)[0]["generated_text"]
|
75 |
|
76 |
@spaces.GPU
|
77 |
+
def pos(input, model_choice, max_new_tokens, length_penalty, no_repeat_ngram_size):
|
78 |
if model_choice=="turna_pos_imst":
|
79 |
pos_imst = pipeline(model="boun-tabi-LMG/turna_pos_imst", device=0)
|
80 |
+
return pos_imst(input, max_new_tokens = max_new_tokens, length_penalty=length_penalty, no_repeat_ngram_size=no_repeat_ngram_size)[0]["generated_text"]
|
81 |
else:
|
82 |
pos_boun = pipeline(model="boun-tabi-LMG/turna_pos_boun", device=0)
|
83 |
+
return pos_boun(input, max_new_tokens = max_new_tokens, length_penalty=length_penalty, no_repeat_ngram_size=no_repeat_ngram_size)[0]["generated_text"]
|
84 |
|
85 |
@spaces.GPU
|
86 |
def ner(input, model_choice, max_new_tokens, length_penalty, no_repeat_ngram_size):
|
|
|
188 |
with gr.Row():
|
189 |
with gr.Column():
|
190 |
pos_choice = gr.Radio(choices = ["turna_pos_imst", "turna_pos_boun"], label ="Model", value="turna_pos_imst")
|
191 |
+
with gr.Accordion("Advanced Generation Parameters"):
|
192 |
+
max_new_tokens = gr.Slider(label = "Maximum length",
|
193 |
+
minimum = 0,
|
194 |
+
maximum = 64,
|
195 |
+
value = 64)
|
196 |
+
length_penalty = gr.Slider(label = "Length penalty",
|
197 |
+
minimum = -10,
|
198 |
+
maximum = 10,
|
199 |
+
value=2.0)
|
200 |
+
no_repeat_ngram_size =gr.Slider(label="No Repeat N-Gram Size", minimum=0,value=3,)
|
201 |
+
with gr.Column():
|
202 |
pos_input = gr.Textbox(label="POS Input")
|
|
|
203 |
pos_submit = gr.Button()
|
204 |
pos_output = gr.Textbox(label="POS Output")
|
205 |
+
pos_submit.click(pos, inputs=[pos_input, pos_choice, max_new_tokens, length_penalty, no_repeat_ngram_size], outputs=pos_output)
|
206 |
+
pos_examples = gr.Examples(examples = ner_example, inputs = [pos_input, pos_choice, max_new_tokens, length_penalty, no_repeat_ngram_size], outputs=pos_output, fn=pos)
|
207 |
|
208 |
with gr.Tab("NER"):
|
209 |
gr.Markdown("TURNA fine-tuned on named entity recognition. Enter text to parse named entities and pick the model.")
|