Spaces:
Runtime error
Runtime error
Chan Lee
commited on
Commit
•
ed4d1bb
1
Parent(s):
d6e50e0
- app.py +20 -20
- vs/bert/config.json +34 -0
- vs/bert/special_tokens_map.json +1 -0
- vs/bert/tf_model.h5 +3 -0
- vs/bert/tf_model.preproc +0 -0
- vs/bert/tokenizer_config.json +1 -0
- vs/bert/vocab.txt +0 -0
- vs/mentalbert/config.json +35 -0
- vs/mentalbert/special_tokens_map.json +1 -0
- vs/mentalbert/tf_model.h5 +3 -0
- vs/mentalbert/tf_model.preproc +0 -0
- vs/mentalbert/tokenizer_config.json +1 -0
- vs/mentalbert/vocab.txt +0 -0
- vs/phsbert/config.json +35 -0
- vs/phsbert/special_tokens_map.json +1 -0
- vs/phsbert/tf_model.h5 +3 -0
- vs/phsbert/tf_model.preproc +0 -0
- vs/phsbert/tokenizer_config.json +1 -0
- vs/phsbert/vocab.txt +0 -0
app.py
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
import ktrain
|
2 |
from gradio import Interface, Parallel, TabbedInterface
|
3 |
|
4 |
-
|
5 |
["I only get my kids the ones I got....I've turned down many so called 'vaccines'"],
|
6 |
["In child protective services, further providing for definitions, for immunity from liability"],
|
7 |
["Lol what? Measles is a real thing. Get vaccinated"]]
|
8 |
-
|
9 |
-
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
def
|
16 |
-
results =
|
17 |
return str(results)
|
18 |
|
19 |
-
def
|
20 |
-
results =
|
21 |
return str(results)
|
22 |
|
23 |
-
def
|
24 |
-
results =
|
25 |
return str(results)
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
vs = Parallel(
|
32 |
-
examples=
|
33 |
-
title=
|
34 |
-
description=
|
35 |
theme="peach")
|
36 |
|
37 |
def model(text):
|
@@ -53,4 +53,4 @@ interface_names = ["Vaccine Sentiment Task",
|
|
53 |
"Stress Task",
|
54 |
"Other Health Related Task"]
|
55 |
|
56 |
-
TabbedInterface(interfaces, interface_names).launch()
|
|
|
1 |
import ktrain
|
2 |
from gradio import Interface, Parallel, TabbedInterface
|
3 |
|
4 |
+
vs_examples = [
|
5 |
["I only get my kids the ones I got....I've turned down many so called 'vaccines'"],
|
6 |
["In child protective services, further providing for definitions, for immunity from liability"],
|
7 |
["Lol what? Measles is a real thing. Get vaccinated"]]
|
8 |
+
vs_title = "Vaccine Sentiment Task - VS2"
|
9 |
+
vs_desc = "Enter vaccine-related tweets to generate sentiment from 3 models (BERT, MentalBERT, PHS-BERT). Label 0='vaccine critical', 1='neutral', 2='vaccine supportive'. The three provided examples have true labels 0,1,2 respectively. For details about VS2, please refer to our paper (linked provided in the corresponding Hugging Face repository)."
|
10 |
|
11 |
+
vs_predictor_bert = ktrain.load_predictor('vs/bert')
|
12 |
+
vs_predictor_mental = ktrain.load_predictor('vs/mentalbert')
|
13 |
+
vs_predictor_phs = ktrain.load_predictor('vs/phsbert')
|
14 |
|
15 |
+
def vs_BERT(text):
|
16 |
+
results = vs_predictor_bert.predict(str(text))
|
17 |
return str(results)
|
18 |
|
19 |
+
def vs_MentalBERT(text):
|
20 |
+
` results = vs_predictor_mental.predict(str(text))
|
21 |
return str(results)
|
22 |
|
23 |
+
def vs_PHSBERT(text):
|
24 |
+
results = vs_predictor_phs.predict(str(text))
|
25 |
return str(results)
|
26 |
|
27 |
+
vs_bert_io = Interface(fn=vs_BERT, inputs="text", outputs="text")
|
28 |
+
vs_mental_io = Interface(fn=vs_MentalBERT, inputs="text", outputs="text")
|
29 |
+
vs_phs_io = Interface(fn=vs_PHSBERT, inputs="text", outputs="text")
|
30 |
|
31 |
+
vs = Parallel(vs_bert_io, vs_mental_io, vs_phs_io,
|
32 |
+
examples=vs_examples,
|
33 |
+
title=vs_title,
|
34 |
+
description=vs_desc,
|
35 |
theme="peach")
|
36 |
|
37 |
def model(text):
|
|
|
53 |
"Stress Task",
|
54 |
"Other Health Related Task"]
|
55 |
|
56 |
+
TabbedInterface(interfaces, interface_names).launch()
|
vs/bert/config.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "bert-base-uncased",
|
3 |
+
"architectures": [
|
4 |
+
"BertForMaskedLM"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"gradient_checkpointing": false,
|
8 |
+
"hidden_act": "gelu",
|
9 |
+
"hidden_dropout_prob": 0.1,
|
10 |
+
"hidden_size": 768,
|
11 |
+
"id2label": {
|
12 |
+
"0": "LABEL_0",
|
13 |
+
"1": "LABEL_1",
|
14 |
+
"2": "LABEL_2"
|
15 |
+
},
|
16 |
+
"initializer_range": 0.02,
|
17 |
+
"intermediate_size": 3072,
|
18 |
+
"label2id": {
|
19 |
+
"LABEL_0": 0,
|
20 |
+
"LABEL_1": 1,
|
21 |
+
"LABEL_2": 2
|
22 |
+
},
|
23 |
+
"layer_norm_eps": 1e-12,
|
24 |
+
"max_position_embeddings": 512,
|
25 |
+
"model_type": "bert",
|
26 |
+
"num_attention_heads": 12,
|
27 |
+
"num_hidden_layers": 12,
|
28 |
+
"pad_token_id": 0,
|
29 |
+
"position_embedding_type": "absolute",
|
30 |
+
"transformers_version": "4.3.3",
|
31 |
+
"type_vocab_size": 2,
|
32 |
+
"use_cache": true,
|
33 |
+
"vocab_size": 30522
|
34 |
+
}
|
vs/bert/special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
vs/bert/tf_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2934646a4e63cab5a21ccf9be03db89abc30340c6575523cf29f3e226781d7eb
|
3 |
+
size 438208876
|
vs/bert/tf_model.preproc
ADDED
Binary file (2.24 kB). View file
|
|
vs/bert/tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "model_max_length": 512, "name_or_path": "bert-base-uncased"}
|
vs/bert/vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
vs/mentalbert/config.json
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "mental/mental-bert-base-uncased",
|
3 |
+
"architectures": [
|
4 |
+
"BertForMaskedLM"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"gradient_checkpointing": false,
|
8 |
+
"hidden_act": "gelu",
|
9 |
+
"hidden_dropout_prob": 0.1,
|
10 |
+
"hidden_size": 768,
|
11 |
+
"id2label": {
|
12 |
+
"0": "LABEL_0",
|
13 |
+
"1": "LABEL_1",
|
14 |
+
"2": "LABEL_2"
|
15 |
+
},
|
16 |
+
"initializer_range": 0.02,
|
17 |
+
"intermediate_size": 3072,
|
18 |
+
"label2id": {
|
19 |
+
"LABEL_0": 0,
|
20 |
+
"LABEL_1": 1,
|
21 |
+
"LABEL_2": 2
|
22 |
+
},
|
23 |
+
"layer_norm_eps": 1e-12,
|
24 |
+
"max_position_embeddings": 512,
|
25 |
+
"model_type": "bert",
|
26 |
+
"num_attention_heads": 12,
|
27 |
+
"num_hidden_layers": 12,
|
28 |
+
"pad_token_id": 0,
|
29 |
+
"position_embedding_type": "absolute",
|
30 |
+
"torch_dtype": "float32",
|
31 |
+
"transformers_version": "4.3.3",
|
32 |
+
"type_vocab_size": 2,
|
33 |
+
"use_cache": true,
|
34 |
+
"vocab_size": 30522
|
35 |
+
}
|
vs/mentalbert/special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
vs/mentalbert/tf_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:acf08239b7cfbc73d117bfd5c1de52fe995055db0a53cd62ec250f9d9189c9ac
|
3 |
+
size 438208876
|
vs/mentalbert/tf_model.preproc
ADDED
Binary file (2.3 kB). View file
|
|
vs/mentalbert/tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "mental/mental-bert-base-uncased", "tokenizer_class": "BertTokenizer"}
|
vs/mentalbert/vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
vs/phsbert/config.json
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "publichealthsurveillance/PHS-BERT",
|
3 |
+
"architectures": [
|
4 |
+
"BertForMaskedLM"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"gradient_checkpointing": false,
|
8 |
+
"hidden_act": "gelu",
|
9 |
+
"hidden_dropout_prob": 0.1,
|
10 |
+
"hidden_size": 1024,
|
11 |
+
"id2label": {
|
12 |
+
"0": "LABEL_0",
|
13 |
+
"1": "LABEL_1",
|
14 |
+
"2": "LABEL_2"
|
15 |
+
},
|
16 |
+
"initializer_range": 0.02,
|
17 |
+
"intermediate_size": 4096,
|
18 |
+
"label2id": {
|
19 |
+
"LABEL_0": 0,
|
20 |
+
"LABEL_1": 1,
|
21 |
+
"LABEL_2": 2
|
22 |
+
},
|
23 |
+
"layer_norm_eps": 1e-12,
|
24 |
+
"max_position_embeddings": 512,
|
25 |
+
"model_type": "bert",
|
26 |
+
"num_attention_heads": 16,
|
27 |
+
"num_hidden_layers": 24,
|
28 |
+
"pad_token_id": 0,
|
29 |
+
"position_embedding_type": "absolute",
|
30 |
+
"total_flos": 2232610412725615392,
|
31 |
+
"transformers_version": "4.3.3",
|
32 |
+
"type_vocab_size": 2,
|
33 |
+
"use_cache": true,
|
34 |
+
"vocab_size": 30522
|
35 |
+
}
|
vs/phsbert/special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
vs/phsbert/tf_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eb80f58acee61b66be6469dd9ae943afa96caf25fc333bf67c0ebf2bac0a2f22
|
3 |
+
size 1341096820
|
vs/phsbert/tf_model.preproc
ADDED
Binary file (2.31 kB). View file
|
|
vs/phsbert/tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "special_tokens_map_file": null, "full_tokenizer_file": null, "name_or_path": "publichealthsurveillance/PHS-BERT", "do_basic_tokenize": true, "never_split": null}
|
vs/phsbert/vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|