Spaces:
Runtime error
Runtime error
The app
Browse files- app.py +28 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
def fill_mask(stmt,model):
|
5 |
+
if model == 'bert':
|
6 |
+
debiased = 'Daniel-Saeedi/debiased-bert-base-uncased'
|
7 |
+
original = 'bert-base-uncased'
|
8 |
+
|
9 |
+
|
10 |
+
unmasker_1 = pipeline('fill-mask', model=debiased)
|
11 |
+
|
12 |
+
unmasker_2 = pipeline('fill-mask', model=original)
|
13 |
+
|
14 |
+
return unmasker_1(stmt), unmasker_2(stmt)
|
15 |
+
|
16 |
+
|
17 |
+
demo = gr.Interface(
|
18 |
+
fill_mask,
|
19 |
+
inputs = [
|
20 |
+
gr.Textbox(placeholder="Fill Mask"),
|
21 |
+
gr.Radio(choices=['bert'],value='bert')
|
22 |
+
],
|
23 |
+
outputs = [gr.Textbox(label="Debiased:"),gr.Textbox(label="Original"), gr.Markdown(
|
24 |
+
value="<h3>How the difference is measured?</h3> <p>abs(similarity(gendered_word1,occupation)-similarity(gendered_word2,occupation))</p>")],
|
25 |
+
description = '<a href="https://aclanthology.org/2020.acl-main.484/">Double-Hard Debias: Tailoring Word Embeddings for Gender Bias Mitigation</a>'
|
26 |
+
)
|
27 |
+
if __name__ == '__main__':
|
28 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
numpy
|
2 |
+
transformer
|