Spaces:
Runtime error
Runtime error
change defaults in corpus.
Browse files
corpus.py
CHANGED
@@ -5,7 +5,8 @@ from ferret import Benchmark
|
|
5 |
from torch.nn.functional import softmax
|
6 |
from copy import deepcopy
|
7 |
|
8 |
-
DEFAULT_MODEL = "
|
|
|
9 |
|
10 |
|
11 |
@st.cache()
|
@@ -58,12 +59,12 @@ def body():
|
|
58 |
|
59 |
samples_string = st.text_input(
|
60 |
"List of samples",
|
61 |
-
|
62 |
help="List of indices in the dataset, comma-separated.",
|
63 |
)
|
64 |
compute = st.button("Run")
|
65 |
|
66 |
-
samples = list(map(int, samples_string.split(",")))
|
67 |
|
68 |
if compute and model_name:
|
69 |
|
@@ -77,8 +78,12 @@ def body():
|
|
77 |
@st.cache(allow_output_mutation=True)
|
78 |
def compute_table(samples):
|
79 |
data = bench.load_dataset("hatexplain")
|
80 |
-
sample_evaluations = bench.evaluate_samples(
|
81 |
-
|
|
|
|
|
|
|
|
|
82 |
return table
|
83 |
|
84 |
table = compute_table(samples)
|
|
|
5 |
from torch.nn.functional import softmax
|
6 |
from copy import deepcopy
|
7 |
|
8 |
+
DEFAULT_MODEL = "Hate-speech-CNERG/bert-base-uncased-hatexplain"
|
9 |
+
DEFAULT_SAMPLES = "3,5,8,13,15,17,18,25,27,28"
|
10 |
|
11 |
|
12 |
@st.cache()
|
|
|
59 |
|
60 |
samples_string = st.text_input(
|
61 |
"List of samples",
|
62 |
+
DEFAULT_SAMPLES,
|
63 |
help="List of indices in the dataset, comma-separated.",
|
64 |
)
|
65 |
compute = st.button("Run")
|
66 |
|
67 |
+
samples = list(map(int, samples_string.replace(" ", "").split(",")))
|
68 |
|
69 |
if compute and model_name:
|
70 |
|
|
|
78 |
@st.cache(allow_output_mutation=True)
|
79 |
def compute_table(samples):
|
80 |
data = bench.load_dataset("hatexplain")
|
81 |
+
sample_evaluations = bench.evaluate_samples(
|
82 |
+
data, samples, target=class_labels.index(target)
|
83 |
+
)
|
84 |
+
table = bench.show_samples_evaluation_table(sample_evaluations).format(
|
85 |
+
"{:.2f}"
|
86 |
+
)
|
87 |
return table
|
88 |
|
89 |
table = compute_table(samples)
|