Spaces:
Runtime error
Runtime error
Commit
·
98b120b
1
Parent(s):
ef67f84
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ from DecompX.src.modeling_bert import BertForSequenceClassification
|
|
| 12 |
from DecompX.src.modeling_roberta import RobertaForSequenceClassification
|
| 13 |
|
| 14 |
plt.style.use("ggplot")
|
| 15 |
-
MODELS = ["WillHeld/roberta-base-sst2"]
|
| 16 |
|
| 17 |
def plot_clf(tokens, logits, label_names, title="", file_name=None):
|
| 18 |
print(tokens)
|
|
@@ -140,7 +140,7 @@ def run_decompx(text, model):
|
|
| 140 |
elif "bert" in MODEL:
|
| 141 |
model = BertForSequenceClassification.from_pretrained(MODEL)
|
| 142 |
else:
|
| 143 |
-
raise Exception(f"Not
|
| 144 |
# RUN DECOMPX
|
| 145 |
with torch.no_grad():
|
| 146 |
model.eval()
|
|
@@ -185,10 +185,13 @@ demo = gr.Interface(
|
|
| 185 |
gr.components.Dropdown(label="Model", choices=MODELS),
|
| 186 |
],
|
| 187 |
outputs=["plot", "html"],
|
| 188 |
-
examples=[
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
| 190 |
title="DecompX Demo",
|
| 191 |
-
description="This
|
| 192 |
)
|
| 193 |
|
| 194 |
demo.launch()
|
|
|
|
| 12 |
from DecompX.src.modeling_roberta import RobertaForSequenceClassification
|
| 13 |
|
| 14 |
plt.style.use("ggplot")
|
| 15 |
+
MODELS = ['TehranNLP-org/bert-base-uncased-cls-sst2', 'TehranNLP-org/bert-large-sst2', "WillHeld/roberta-base-sst2"]
|
| 16 |
|
| 17 |
def plot_clf(tokens, logits, label_names, title="", file_name=None):
|
| 18 |
print(tokens)
|
|
|
|
| 140 |
elif "bert" in MODEL:
|
| 141 |
model = BertForSequenceClassification.from_pretrained(MODEL)
|
| 142 |
else:
|
| 143 |
+
raise Exception(f"Not implented model: {MODEL}")
|
| 144 |
# RUN DECOMPX
|
| 145 |
with torch.no_grad():
|
| 146 |
model.eval()
|
|
|
|
| 185 |
gr.components.Dropdown(label="Model", choices=MODELS),
|
| 186 |
],
|
| 187 |
outputs=["plot", "html"],
|
| 188 |
+
examples=[
|
| 189 |
+
["a good piece of work more often than not.", "TehranNLP-org/bert-base-uncased-cls-sst2"],
|
| 190 |
+
["A deep and meaningful film.", "TehranNLP-org/bert-large-sst2"],
|
| 191 |
+
],
|
| 192 |
+
cache_examples=True,
|
| 193 |
title="DecompX Demo",
|
| 194 |
+
description="This is a demo for the ACL 2023 paper [DecompX](https://github.com/mohsenfayyaz/DecompX/)"
|
| 195 |
)
|
| 196 |
|
| 197 |
demo.launch()
|