Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
import torch
|
| 4 |
-
from openprompt.plms import load_plm
|
| 5 |
-
from openprompt import PromptDataLoader
|
| 6 |
-
from openprompt.prompts import ManualVerbalizer
|
| 7 |
-
from openprompt.prompts import ManualTemplate
|
| 8 |
-
from openprompt.data_utils import InputExample
|
| 9 |
-
from openprompt import PromptForClassification
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
def sentiment_analysis(sentence, template, positive, neutral, negative):
|
| 13 |
-
model_name = "CCCC/ARCH_tuned_bert"
|
| 14 |
template = template.replace('[SENTENCE]', '{"placeholder":"text_a"}')
|
| 15 |
template = template.replace('[MASK]', '{"mask"}')
|
| 16 |
classes = ['positive', 'neutral', 'negative']
|
|
@@ -67,10 +56,12 @@ def sentiment_analysis(sentence, template, positive, neutral, negative):
|
|
| 67 |
demo = gr.Interface(fn=sentiment_analysis,
|
| 68 |
inputs = [gr.Textbox(placeholder="Enter sentence here.",label="sentence"),
|
| 69 |
gr.Textbox(placeholder="Your template must have a [SENTENCE] token and a [MASK] token.",label="template"),
|
|
|
|
| 70 |
gr.Textbox(placeholder="Separate words with Spaces.",label="positive label words"),
|
| 71 |
gr.Textbox(placeholder="Separate words with Spaces.",label="neutral label words"),
|
| 72 |
gr.Textbox(placeholder="Separate words with Spaces.",label="negative label words")
|
| 73 |
],
|
| 74 |
-
outputs="text"
|
|
|
|
| 75 |
|
| 76 |
-
demo.launch()
|
|
|
|
| 1 |
+
def sentiment_analysis(sentence, template, model_name, positive, neutral, negative):
|
| 2 |
+
model_name = model_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
template = template.replace('[SENTENCE]', '{"placeholder":"text_a"}')
|
| 4 |
template = template.replace('[MASK]', '{"mask"}')
|
| 5 |
classes = ['positive', 'neutral', 'negative']
|
|
|
|
| 56 |
demo = gr.Interface(fn=sentiment_analysis,
|
| 57 |
inputs = [gr.Textbox(placeholder="Enter sentence here.",label="sentence"),
|
| 58 |
gr.Textbox(placeholder="Your template must have a [SENTENCE] token and a [MASK] token.",label="template"),
|
| 59 |
+
gr.Radio(choices=["ARCH_tuned_robert","FNCH_tuned_robert","AREN_tuned_robert","FNEN_tuned_robert","bert-base-uncased"], label="model choics"),
|
| 60 |
gr.Textbox(placeholder="Separate words with Spaces.",label="positive label words"),
|
| 61 |
gr.Textbox(placeholder="Separate words with Spaces.",label="neutral label words"),
|
| 62 |
gr.Textbox(placeholder="Separate words with Spaces.",label="negative label words")
|
| 63 |
],
|
| 64 |
+
outputs="text",
|
| 65 |
+
)
|
| 66 |
|
| 67 |
+
demo.launch()
|