Oskar van der Wal commited on
Commit
b916b1c
Β·
unverified Β·
2 Parent(s): 7094807 0308d70

Merge pull request #3 from clclab/feature/blocks

Browse files
Files changed (4) hide show
  1. README.md +1 -1
  2. app.py +17 -13
  3. description.md +5 -0
  4. notice.md +6 -0
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🌍
4
  colorFrom: yellow
5
  colorTo: indigo
6
  sdk: gradio
7
- sdk_version: 3.0.24
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: yellow
5
  colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 3.3
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -68,18 +68,22 @@ dataset = CrowSPairsDataset()
68
 
69
  bias_type_sel = gradio.Dropdown(label="Bias Type", choices=dataset.bias_types())
70
 
71
- iface = gradio.Interface(
72
- fn=run,
73
- inputs=bias_type_sel,
74
- outputs="html",
75
- title="Detecting stereotypes in the GPT-2 language model using CrowS-Pairs",
76
- description="""GPT-2 is a language model which can score how likely it is that some text is a valid English sentence: not only grammaticality, but also the 'meaning' of the sentence is part of this score.
77
- CrowS-Pairs is a dataset with pairs of more and less stereotypical examples for different social groups (e.g., gender and nationality stereotypes).
78
- We sample 10 random pairs from CrowS-Pairs and show whether the stereotypical example gets a higher score ('is more likely').
79
- If GPT-2 systematically prefers the stereotypical examples, it has probably learnt these stereotypes from the training data.
80
- **DISCLAIMER: How to measure bias in language models is not trivial and an active area of research.
81
- CrowS-Pairs is only one bias benchmark, and here you can probably find some examples that are nonsensical, with typos, or containing stereotypes that are only relevant in the American cultural context.**
82
- """,
83
- )
 
 
 
 
84
 
85
  iface.launch()
 
68
 
69
  bias_type_sel = gradio.Dropdown(label="Bias Type", choices=dataset.bias_types())
70
 
71
+ with open("description.md") as fh:
72
+ desc = fh.read()
73
+
74
+ with open("notice.md") as fh:
75
+ notice = fh.read()
76
+
77
+ with gradio.Blocks() as iface:
78
+ gradio.Markdown(desc)
79
+ with gradio.Row(equal_height=True):
80
+ with gradio.Column(scale=4):
81
+ inp = gradio.Dropdown(label="Bias Type", choices=dataset.bias_types())
82
+ with gradio.Column(scale=1):
83
+ but = gradio.Button("Sample")
84
+ out = gradio.HTML()
85
+ but.click(run, inp, out)
86
+ with gradio.Accordion("A note about explainability models"):
87
+ gradio.Markdown(notice)
88
 
89
  iface.launch()
description.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Detecting stereotypes in the GPT-2 language model using CrowS-Pairs
2
+
3
+ GPT-2 is a language model which can score how likely it is that some text is a valid English sentence: not only grammaticality, but also the 'meaning' of the sentence is part of this score. CrowS-Pairs is a dataset with pairs of more and less stereotypical examples for different social groups (e.g., gender and nationality stereotypes). We sample 10 random pairs from CrowS-Pairs and show whether the stereotypical example gets a higher score ('is more likely'). If GPT-2 systematically prefers the stereotypical examples, it has probably learnt these stereotypes from the training data.
4
+
5
+ The colors indicate whether the $${\color{blue}stereotypical}$$ or the $${\color{pink}less stereotypical}$$ example gets the higher score.
notice.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # Measuring bias in language models is hard!
2
+ How to measure bias in language models is not trivial and still an active area of research.
3
+ First of all, what is bias? As you may have noticed, stereotypes may change across languages and cultures.
4
+ What is problematic in the USA, may not be relevant in the Netherlands---each cultural context requires its own careful evaluation.
5
+ Furthermore, defining good ways to measure it is also difficult.
6
+ For example, [Blodgett et al. (2021)](https://aclanthology.org/2021.acl-long.81/) find that typos, nonsensical examples, and other mistakes threatens the validity of CrowS-Pairs.