Chan Lee commited on
Commit
c37d32d
1 Parent(s): 0ed1e45

MentalBERT output

Browse files
Files changed (1) hide show
  1. app.py +40 -10
app.py CHANGED
@@ -6,7 +6,8 @@ vs_examples = [
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"
9
- vs_desc = "Enter text to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). The three provided examples have true labels 'vaccine critical', 'neutral', 'vaccine supportive' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the VS2 dataset description in our paper (link provided in the corresponding Hugging Face repository)."
 
10
 
11
  hm_examples = [
12
  ["Serious as a heart attack question/thought Riddle me this. Why, oh why, does cold brew coffee get warm after sitting to long. Taste terrible. And Hot coffee get literally COLD after sitting too long. Tastes terrible. Like what. Why don't cold stay cold and hot only get warm?"],
@@ -14,7 +15,8 @@ hm_examples = [
14
  ["The older we get the less likely we are to view a sudden massive heart attack as a tragedy than a stroke of good luck."],
15
  ["My son is not feeling well today."]]
16
  hm_title = "Health Mention Task"
17
- hm_desc = "Enter text to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). The three provided examples have true labels 'Figurative/Hyperbolic Health Mentions', 'Non-personal Health Mentions', 'Personal Health Mentions' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the RHMD dataset description in our paper (link provided in the corresponding Hugging Face repository)."
 
18
 
19
  dep_examples = [
20
  ["Nothing major, some underage drinking, a little pot, but I wasn't a bad kid. Furthermore, I feel like I matured well and have gone on to be successful for my age (24) IMO. I've also had positive experiences with police. The resource officer at my high school was a really good guy and almost like a mentor to me. When I was 17 I was arrested when police raided a friends house because they were tipped off that there was to be some under-aged drinking. Furthermore, I told him before we got really serious that I have anxiety and depression, and if he can’t handle that then I’ll understand if we end things. But *he* chose to stay with me and help me if I wanted it. Honestly I’m just tired of defending myself to him after this fight. I shouldn’t have to. And he kept threatening to break up; then why don’t you do it?"],
@@ -30,7 +32,8 @@ covid_examples = [
30
  ["The latest Boarding Pass! #budget2020 #coronavirus"]
31
  ]
32
  covid_title = "COVID Category Task"
33
- covid_desc = "Enter covid-related tweets to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). The two provided examples have true labels 'news', 'personal narrative' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the Covid category dataset description in our paper (link provided in the corresponding Hugging Face repository)."
 
34
 
35
  # 2nd example looks like the most risk
36
  suicide_examples = [
@@ -47,14 +50,16 @@ stress_examples = [
47
  ["My daughter's father I was with for 5 years on and off. He was not abusive the first year, however when he became so I left and found out two weeks later I was pregnant. Of course he begged and pleaded for a second chance, and I believed that my daughter deserved me to at least give it a shot. I came back and surprise surprise it was worse than it ever was. I stuck it out until he disappeared for the eleventeenth time on a drunken bender, I checked my Facebook to find some scumbag girl who was dating one of his best friends was posting horrific, nasty, way out shit about me."]
48
  ]
49
  stress_title = "Stress Detection Task"
50
- stress_desc = "Enter text to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). The two provided examples have true labels 'no stress', 'stress' respectively (NOTE: you may have to click submit again to generate the correct label)."# For more details, please refer to the Dreaddit dataset description in our paper (link provided in the corresponding Hugging Face repository)."
 
51
 
52
  other_examples = [
53
  ["@anxietyfighter suffered social anxiety for 4 yrs when i had my first panic attack,got worse when i went to uni, so have just started paxil"],
54
  ["@JessBarrett227 Taking someone off 150mg off Seroquel, mixing it with Olanzapine in 2 wks causes psychosis - a proper assess was not done. "]
55
  ]
56
  other_title = "Adverse Drug Reaction Task"
57
- other_desc = "Enter text to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). The two provided examples have true labels 'no adverse drug reaction', 'adverse drug reaction' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the SMM4H T1 dataset description in our paper (link provided in the corresponding Hugging Face repository)."
 
58
 
59
  # def make_interfaces(folder):
60
  # predictor_bert = ktrain.load_predictor(folder + "bert")
@@ -104,7 +109,12 @@ def vs_PHSBERT(text):
104
  vs_bert_io = Interface(fn=vs_BERT, inputs="text", outputs="text")
105
  vs_mental_io = Interface(fn=vs_MentalBERT, inputs="text", outputs="text")
106
  vs_phs_io = Interface(fn=vs_PHSBERT, inputs="text", outputs="text")
107
- vs = Parallel(vs_bert_io, vs_mental_io, vs_phs_io,
 
 
 
 
 
108
  examples=vs_examples,
109
  title=vs_title,
110
  description=vs_desc,
@@ -138,7 +148,12 @@ def hm_PHSBERT(text):
138
  hm_bert_io = Interface(fn=hm_BERT, inputs="text", outputs="text")
139
  hm_mental_io = Interface(fn=hm_MentalBERT, inputs="text", outputs="text")
140
  hm_phs_io = Interface(fn=hm_PHSBERT, inputs="text", outputs="text")
141
- hm = Parallel(hm_bert_io, hm_mental_io, hm_phs_io,
 
 
 
 
 
142
  examples=hm_examples,
143
  title=hm_title,
144
  description=hm_desc,
@@ -168,7 +183,12 @@ def covid_PHSBERT(text):
168
  covid_bert_io = Interface(fn=covid_BERT, inputs="text", outputs="text")
169
  covid_mental_io = Interface(fn=covid_MentalBERT, inputs="text", outputs="text")
170
  covid_phs_io = Interface(fn=covid_PHSBERT, inputs="text", outputs="text")
171
- covid = Parallel(covid_bert_io, covid_mental_io, covid_phs_io,
 
 
 
 
 
172
  examples=covid_examples,
173
  title=covid_title,
174
  description=covid_desc,
@@ -198,7 +218,12 @@ def stress_PHSBERT(text):
198
  stress_bert_io = Interface(fn=stress_BERT, inputs="text", outputs="text")
199
  stress_mental_io = Interface(fn=stress_MentalBERT, inputs="text", outputs="text")
200
  stress_phs_io = Interface(fn=stress_PHSBERT, inputs="text", outputs="text")
201
- stress = Parallel(stress_bert_io, stress_mental_io, stress_phs_io,
 
 
 
 
 
202
  examples=stress_examples,
203
  title=stress_title,
204
  description=stress_desc,
@@ -228,7 +253,12 @@ def other_PHSBERT(text):
228
  other_bert_io = Interface(fn=other_BERT, inputs="text", outputs="text")
229
  other_mental_io = Interface(fn=other_MentalBERT, inputs="text", outputs="text")
230
  other_phs_io = Interface(fn=other_PHSBERT, inputs="text", outputs="text")
231
- other = Parallel(other_bert_io, other_mental_io, other_phs_io,
 
 
 
 
 
232
  examples=other_examples,
233
  title=other_title,
234
  description=other_desc,
 
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"
9
+ # vs_desc = "Enter text to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). The three provided examples have true labels 'vaccine critical', 'neutral', 'vaccine supportive' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the VS2 dataset description in our paper (link provided in the corresponding Hugging Face repository)."
10
+ vs_desc = "Enter text to generate labels from 2 models (BERT, PHS-BERT). The three provided examples have true labels 'vaccine critical', 'neutral', 'vaccine supportive' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the VS2 dataset description in our paper (link provided in the corresponding Hugging Face repository)."
11
 
12
  hm_examples = [
13
  ["Serious as a heart attack question/thought Riddle me this. Why, oh why, does cold brew coffee get warm after sitting to long. Taste terrible. And Hot coffee get literally COLD after sitting too long. Tastes terrible. Like what. Why don't cold stay cold and hot only get warm?"],
 
15
  ["The older we get the less likely we are to view a sudden massive heart attack as a tragedy than a stroke of good luck."],
16
  ["My son is not feeling well today."]]
17
  hm_title = "Health Mention Task"
18
+ # hm_desc = "Enter text to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). The three provided examples have true labels 'Figurative/Hyperbolic Health Mentions', 'Non-personal Health Mentions', 'Personal Health Mentions' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the RHMD dataset description in our paper (link provided in the corresponding Hugging Face repository)."
19
+ hm_desc = "Enter text to generate labels from 2 models (BERT, PHS-BERT). The three provided examples have true labels 'Figurative/Hyperbolic Health Mentions', 'Non-personal Health Mentions', 'Personal Health Mentions' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the RHMD dataset description in our paper (link provided in the corresponding Hugging Face repository)."
20
 
21
  dep_examples = [
22
  ["Nothing major, some underage drinking, a little pot, but I wasn't a bad kid. Furthermore, I feel like I matured well and have gone on to be successful for my age (24) IMO. I've also had positive experiences with police. The resource officer at my high school was a really good guy and almost like a mentor to me. When I was 17 I was arrested when police raided a friends house because they were tipped off that there was to be some under-aged drinking. Furthermore, I told him before we got really serious that I have anxiety and depression, and if he can’t handle that then I’ll understand if we end things. But *he* chose to stay with me and help me if I wanted it. Honestly I’m just tired of defending myself to him after this fight. I shouldn’t have to. And he kept threatening to break up; then why don’t you do it?"],
 
32
  ["The latest Boarding Pass! #budget2020 #coronavirus"]
33
  ]
34
  covid_title = "COVID Category Task"
35
+ # covid_desc = "Enter covid-related tweets to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). The two provided examples have true labels 'news', 'personal narrative' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the Covid category dataset description in our paper (link provided in the corresponding Hugging Face repository)."
36
+ covid_desc = "Enter covid-related tweets to generate labels from 2 models (BERT, PHS-BERT). The two provided examples have true labels 'news', 'personal narrative' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the Covid category dataset description in our paper (link provided in the corresponding Hugging Face repository)."
37
 
38
  # 2nd example looks like the most risk
39
  suicide_examples = [
 
50
  ["My daughter's father I was with for 5 years on and off. He was not abusive the first year, however when he became so I left and found out two weeks later I was pregnant. Of course he begged and pleaded for a second chance, and I believed that my daughter deserved me to at least give it a shot. I came back and surprise surprise it was worse than it ever was. I stuck it out until he disappeared for the eleventeenth time on a drunken bender, I checked my Facebook to find some scumbag girl who was dating one of his best friends was posting horrific, nasty, way out shit about me."]
51
  ]
52
  stress_title = "Stress Detection Task"
53
+ # stress_desc = "Enter text to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). The two provided examples have true labels 'no stress', 'stress' respectively (NOTE: you may have to click submit again to generate the correct label)."# For more details, please refer to the Dreaddit dataset description in our paper (link provided in the corresponding Hugging Face repository)."
54
+ stress_desc = "Enter text to generate labels from 2 models (BERT, PHS-BERT). The two provided examples have true labels 'no stress', 'stress' respectively (NOTE: you may have to click submit again to generate the correct label)."# For more details, please refer to the Dreaddit dataset description in our paper (link provided in the corresponding Hugging Face repository)."
55
 
56
  other_examples = [
57
  ["@anxietyfighter suffered social anxiety for 4 yrs when i had my first panic attack,got worse when i went to uni, so have just started paxil"],
58
  ["@JessBarrett227 Taking someone off 150mg off Seroquel, mixing it with Olanzapine in 2 wks causes psychosis - a proper assess was not done. "]
59
  ]
60
  other_title = "Adverse Drug Reaction Task"
61
+ # other_desc = "Enter text to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). The two provided examples have true labels 'no adverse drug reaction', 'adverse drug reaction' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the SMM4H T1 dataset description in our paper (link provided in the corresponding Hugging Face repository)."
62
+ other_desc = "Enter text to generate labels from 2 models (BERT, PHS-BERT). The two provided examples have true labels 'no adverse drug reaction', 'adverse drug reaction' respectively (NOTE: you may have to click submit again to generate the correct labels)."# For more details, please refer to the SMM4H T1 dataset description in our paper (link provided in the corresponding Hugging Face repository)."
63
 
64
  # def make_interfaces(folder):
65
  # predictor_bert = ktrain.load_predictor(folder + "bert")
 
109
  vs_bert_io = Interface(fn=vs_BERT, inputs="text", outputs="text")
110
  vs_mental_io = Interface(fn=vs_MentalBERT, inputs="text", outputs="text")
111
  vs_phs_io = Interface(fn=vs_PHSBERT, inputs="text", outputs="text")
112
+ # vs = Parallel(vs_bert_io, vs_mental_io, vs_phs_io,
113
+ # examples=vs_examples,
114
+ # title=vs_title,
115
+ # description=vs_desc,
116
+ # theme="peach")
117
+ vs = Parallel(vs_bert_io, vs_phs_io,
118
  examples=vs_examples,
119
  title=vs_title,
120
  description=vs_desc,
 
148
  hm_bert_io = Interface(fn=hm_BERT, inputs="text", outputs="text")
149
  hm_mental_io = Interface(fn=hm_MentalBERT, inputs="text", outputs="text")
150
  hm_phs_io = Interface(fn=hm_PHSBERT, inputs="text", outputs="text")
151
+ # hm = Parallel(hm_bert_io, hm_mental_io, hm_phs_io,
152
+ # examples=hm_examples,
153
+ # title=hm_title,
154
+ # description=hm_desc,
155
+ # theme="peach")
156
+ hm = Parallel(hm_bert_io, hm_phs_io,
157
  examples=hm_examples,
158
  title=hm_title,
159
  description=hm_desc,
 
183
  covid_bert_io = Interface(fn=covid_BERT, inputs="text", outputs="text")
184
  covid_mental_io = Interface(fn=covid_MentalBERT, inputs="text", outputs="text")
185
  covid_phs_io = Interface(fn=covid_PHSBERT, inputs="text", outputs="text")
186
+ # covid = Parallel(covid_bert_io, covid_mental_io, covid_phs_io,
187
+ # examples=covid_examples,
188
+ # title=covid_title,
189
+ # description=covid_desc,
190
+ # theme="peach")
191
+ covid = Parallel(covid_bert_io, covid_phs_io,
192
  examples=covid_examples,
193
  title=covid_title,
194
  description=covid_desc,
 
218
  stress_bert_io = Interface(fn=stress_BERT, inputs="text", outputs="text")
219
  stress_mental_io = Interface(fn=stress_MentalBERT, inputs="text", outputs="text")
220
  stress_phs_io = Interface(fn=stress_PHSBERT, inputs="text", outputs="text")
221
+ # stress = Parallel(stress_bert_io, stress_mental_io, stress_phs_io,
222
+ # examples=stress_examples,
223
+ # title=stress_title,
224
+ # description=stress_desc,
225
+ # theme="peach")
226
+ stress = Parallel(stress_bert_io, stress_phs_io,
227
  examples=stress_examples,
228
  title=stress_title,
229
  description=stress_desc,
 
253
  other_bert_io = Interface(fn=other_BERT, inputs="text", outputs="text")
254
  other_mental_io = Interface(fn=other_MentalBERT, inputs="text", outputs="text")
255
  other_phs_io = Interface(fn=other_PHSBERT, inputs="text", outputs="text")
256
+ # other = Parallel(other_bert_io, other_mental_io, other_phs_io,
257
+ # examples=other_examples,
258
+ # title=other_title,
259
+ # description=other_desc,
260
+ # theme="peach")
261
+ other = Parallel(other_bert_io, other_phs_io,
262
  examples=other_examples,
263
  title=other_title,
264
  description=other_desc,