Spaces:
Runtime error
Runtime error
Downloading models
Browse files
app.py
CHANGED
@@ -7,10 +7,26 @@ import gc
|
|
7 |
bert_debiased = pipeline('fill-mask', model='Daniel-Saeedi/Sent-Debias-bert-gender-debiased')
|
8 |
bert_original = pipeline('fill-mask', model='Daniel-Saeedi/Sent-Debias-bert-gender-debiased')
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
def fill_mask(stmt,model):
|
12 |
if model == 'bert':
|
13 |
-
return bert_debiased(stmt)
|
14 |
|
15 |
|
16 |
demo = gr.Interface(
|
@@ -19,7 +35,7 @@ demo = gr.Interface(
|
|
19 |
gr.Textbox(placeholder="Fill Mask"),
|
20 |
gr.Radio(choices=['bert'],value='bert')
|
21 |
],
|
22 |
-
outputs = [gr.
|
23 |
value="<h3>How the difference is measured?</h3> <p>abs(similarity(gendered_word1,occupation)-similarity(gendered_word2,occupation))</p>")],
|
24 |
description = '<a href="https://aclanthology.org/2020.acl-main.484/">Double-Hard Debias: Tailoring Word Embeddings for Gender Bias Mitigation</a>'
|
25 |
)
|
|
|
7 |
bert_debiased = pipeline('fill-mask', model='Daniel-Saeedi/Sent-Debias-bert-gender-debiased')
|
8 |
bert_original = pipeline('fill-mask', model='Daniel-Saeedi/Sent-Debias-bert-gender-debiased')
|
9 |
|
10 |
+
def make_slider(unmask):
|
11 |
+
total_score = 0
|
12 |
+
for word in unmask:
|
13 |
+
total_score += word['score']
|
14 |
+
|
15 |
+
factor = 1/total_score
|
16 |
+
|
17 |
+
html = '<div>'
|
18 |
+
|
19 |
+
for word in unmask:
|
20 |
+
html += '<h3>{}</h3><input type="range" disable value={}><br>'.format(word['token_str'],factor*word['score'])
|
21 |
+
|
22 |
+
html += '</div>'
|
23 |
+
return html
|
24 |
+
|
25 |
+
|
26 |
|
27 |
def fill_mask(stmt,model):
|
28 |
if model == 'bert':
|
29 |
+
return make_slider(bert_debiased(stmt))
|
30 |
|
31 |
|
32 |
demo = gr.Interface(
|
|
|
35 |
gr.Textbox(placeholder="Fill Mask"),
|
36 |
gr.Radio(choices=['bert'],value='bert')
|
37 |
],
|
38 |
+
outputs = [gr.Markdown(
|
39 |
value="<h3>How the difference is measured?</h3> <p>abs(similarity(gendered_word1,occupation)-similarity(gendered_word2,occupation))</p>")],
|
40 |
description = '<a href="https://aclanthology.org/2020.acl-main.484/">Double-Hard Debias: Tailoring Word Embeddings for Gender Bias Mitigation</a>'
|
41 |
)
|