Emily McMilin
commited on
Commit
·
652f191
1
Parent(s):
a1b7fc7
Text more brief. Update image w css attempt
Browse files
app.py
CHANGED
@@ -307,7 +307,7 @@ date_example = [
|
|
307 |
'DATE',
|
308 |
"False",
|
309 |
3,
|
310 |
-
'She was
|
311 |
]
|
312 |
|
313 |
|
@@ -354,10 +354,6 @@ with demo:
|
|
354 |
gr.Markdown("## Spurious Correlation Evaluation for Pre-trained and Fine-tuned LLMs")
|
355 |
gr.Markdown("Although genders are relatively evenly distributed across time, place and interests, there are also known gender disparities in terms of access to resources. Here we demonstrate that this access disparity can result in dataset selection bias, causing models to learn a surprising range of spurious associations.")
|
356 |
|
357 |
-
gr.Markdown("### Dose-response Relationship")
|
358 |
-
gr.Markdown("One intuitive way to see the impact that changing one variable may have upon another is to look for a dose-response relationship, in which a larger intervention in the treatment (the value in text form injected in the otherwise unchanged text sample) produces a larger response in the output (the softmax probability of a gendered pronoun).")
|
359 |
-
gr.Markdown("This dose-response plot requires a range of values along which we may see a spectrum of gender representation (or misrepresentation) in our datasets.")
|
360 |
-
|
361 |
gr.Markdown("## This Demo")
|
362 |
gr.Markdown("1) Click on one of the examples below (where we sweep through a spectrum of `places`, `date` and `subreddit` interest) to pre-populate the input fields.")
|
363 |
gr.Markdown("2) Check out the pre-populated fields as you scroll down to the ['Hit Submit...'] button!")
|
@@ -370,14 +366,14 @@ with demo:
|
|
370 |
date_gen = gr.Button('Click for date example inputs')
|
371 |
|
372 |
gr.Markdown(
|
373 |
-
"X-axis sorted by bottom 10 and top 10 [Global Gender Gap](https://www3.weforum.org/docs/WEF_GGGR_2021.pdf) ranked countries
|
374 |
place_gen = gr.Button('Click for country example inputs')
|
375 |
|
376 |
gr.Markdown(
|
377 |
-
"X-axis sorted in order of increasing self-identified female participation (see [bburky
|
378 |
subreddit_gen = gr.Button('Click for Subreddit example inputs')
|
379 |
|
380 |
-
gr.Markdown("Date example with your own model loaded! (
|
381 |
your_gen = gr.Button('Click for your model example inputs')
|
382 |
|
383 |
gr.Markdown("### Input fields")
|
@@ -404,9 +400,7 @@ with demo:
|
|
404 |
label="C) If you selected an 'add-your-own' model, put your models Hugging Face pipeline name here. We think it should work with any model that supports the fill-mask task.",
|
405 |
)
|
406 |
|
407 |
-
gr.Markdown(
|
408 |
-
"We are able to test the pre-trained LLMs without any modification to the models, as the gender-pronoun prediction task is simply a special case of the masked language modeling (MLM) task, with which all these models were pre-trained. Rather than random masking, the gender-pronoun prediction task masks only non-gender-neutral terms (listed in prior [Space](https://huggingface.co/spaces/emilylearning/causing_gender_pronouns_two)).")
|
409 |
-
gr.Markdown("For the pre-trained LLMs the final prediction is a softmax over the entire tokenizer's vocabulary, from which we sum up the portion of the probability mass from the top five prediction words that are gendered terms. D) Pick if you want to the predictions normalied to these gendered terms only.")
|
410 |
gr.Markdown("E) Also tell the demo what special token you will use in your input text, that you would like replaced with the spectrum of values you listed above, and F) the degree of polynomial fit used for high-lighting possible dose response trend ")
|
411 |
|
412 |
|
@@ -470,18 +464,35 @@ with demo:
|
|
470 |
outputs=[sample_text, female_fig, male_fig, df])
|
471 |
|
472 |
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
gr.Markdown("### What is Causing these Spurious Correlations?")
|
474 |
|
475 |
gr.Markdown("Spurious correlations are often considered undesirable, as they do not match our intuition about the real-world domain from which we derive samples for inference-time prediction.")
|
476 |
-
gr.Markdown("Selection of samples into datasets
|
|
|
|
|
|
|
|
|
|
|
477 |
|
478 |
gr.Markdown("### Data Generating Process")
|
479 |
gr.Markdown("To pick values below that are most likely to cause spurious correlations, it helps to make some assumptions about the training datasets' likely data generating process, and where selection bias may come in.")
|
480 |
|
481 |
gr.Markdown("A plausible data generating processes for both Wikipedia and Reddit sourced data is shown as a DAG below. These DAGs are prone to collider bias when conditioning on `access`. In other words, although in real life `place`, `date`, (subreddit) `interest` and gender are all unconditionally independent, when we condition on their common effect, `access`, they become unconditionally dependent. Composing a dataset often requires the dataset maintainers to condition on `access`. Thus LLMs learn these dataset induced dependencies, appearing to us as spurious correlations.")
|
|
|
482 |
gr.Markdown("""
|
|
|
|
|
|
|
|
|
|
|
483 |
<center>
|
484 |
-
<img src="https://www.dropbox.com/s/
|
485 |
alt="DAG of possible data generating process for datasets used in training some of our LLMs.">
|
486 |
</center>
|
487 |
""")
|
|
|
307 |
'DATE',
|
308 |
"False",
|
309 |
3,
|
310 |
+
'She was a teenager in DATE.'
|
311 |
]
|
312 |
|
313 |
|
|
|
354 |
gr.Markdown("## Spurious Correlation Evaluation for Pre-trained and Fine-tuned LLMs")
|
355 |
gr.Markdown("Although genders are relatively evenly distributed across time, place and interests, there are also known gender disparities in terms of access to resources. Here we demonstrate that this access disparity can result in dataset selection bias, causing models to learn a surprising range of spurious associations.")
|
356 |
|
|
|
|
|
|
|
|
|
357 |
gr.Markdown("## This Demo")
|
358 |
gr.Markdown("1) Click on one of the examples below (where we sweep through a spectrum of `places`, `date` and `subreddit` interest) to pre-populate the input fields.")
|
359 |
gr.Markdown("2) Check out the pre-populated fields as you scroll down to the ['Hit Submit...'] button!")
|
|
|
366 |
date_gen = gr.Button('Click for date example inputs')
|
367 |
|
368 |
gr.Markdown(
|
369 |
+
"X-axis sorted by bottom 10 and top 10 [Global Gender Gap](https://www3.weforum.org/docs/WEF_GGGR_2021.pdf) ranked countries:")
|
370 |
place_gen = gr.Button('Click for country example inputs')
|
371 |
|
372 |
gr.Markdown(
|
373 |
+
"X-axis sorted in order of increasing self-identified female participation (see [bburky](http://bburky.com/subredditgenderratios/)): ")
|
374 |
subreddit_gen = gr.Button('Click for Subreddit example inputs')
|
375 |
|
376 |
+
gr.Markdown("Date example with your own model loaded! (If first time, try another example, it can take a while to load new model.)")
|
377 |
your_gen = gr.Button('Click for your model example inputs')
|
378 |
|
379 |
gr.Markdown("### Input fields")
|
|
|
400 |
label="C) If you selected an 'add-your-own' model, put your models Hugging Face pipeline name here. We think it should work with any model that supports the fill-mask task.",
|
401 |
)
|
402 |
|
403 |
+
gr.Markdown("D) Pick if you want to the predictions normalied to these gendered terms only.")
|
|
|
|
|
404 |
gr.Markdown("E) Also tell the demo what special token you will use in your input text, that you would like replaced with the spectrum of values you listed above, and F) the degree of polynomial fit used for high-lighting possible dose response trend ")
|
405 |
|
406 |
|
|
|
464 |
outputs=[sample_text, female_fig, male_fig, df])
|
465 |
|
466 |
|
467 |
+
gr.Markdown("### How does this work?")
|
468 |
+
gr.Markdown("We are able to test the pre-trained LLMs without any modification to the models, as the gender-pronoun prediction task is simply a special case of the masked language modeling (MLM) task, with which all these models were pre-trained. Rather than random masking, the gender-pronoun prediction task masks only non-gender-neutral terms (listed in prior [Space](https://huggingface.co/spaces/emilylearning/causing_gender_pronouns_two)).")
|
469 |
+
gr.Markdown("For the pre-trained LLMs the final prediction is a softmax over the entire tokenizer's vocabulary, from which we sum up the portion of the probability mass from the top five prediction words that are gendered terms (and normalize or not, based on selected preference above.")
|
470 |
+
|
471 |
+
|
472 |
+
|
473 |
gr.Markdown("### What is Causing these Spurious Correlations?")
|
474 |
|
475 |
gr.Markdown("Spurious correlations are often considered undesirable, as they do not match our intuition about the real-world domain from which we derive samples for inference-time prediction.")
|
476 |
+
gr.Markdown("Selection of samples into datasets can be a zero-sum-game, with even our high quality datasets forced to trade off one for another, thus inducing selection bias into the learned associations of the model.")
|
477 |
+
|
478 |
+
gr.Markdown("### Dose-response Relationship")
|
479 |
+
gr.Markdown("One intuitive way to see the impact that changing one variable may have upon another is to look for a dose-response relationship, in which a larger intervention in the treatment (the value in text form injected in the otherwise unchanged text sample) produces a larger response in the output (the softmax probability of a gendered pronoun).")
|
480 |
+
gr.Markdown("This dose-response plot requires a range of values along which we may see a spectrum of gender representation (or misrepresentation) in our datasets.")
|
481 |
+
|
482 |
|
483 |
gr.Markdown("### Data Generating Process")
|
484 |
gr.Markdown("To pick values below that are most likely to cause spurious correlations, it helps to make some assumptions about the training datasets' likely data generating process, and where selection bias may come in.")
|
485 |
|
486 |
gr.Markdown("A plausible data generating processes for both Wikipedia and Reddit sourced data is shown as a DAG below. These DAGs are prone to collider bias when conditioning on `access`. In other words, although in real life `place`, `date`, (subreddit) `interest` and gender are all unconditionally independent, when we condition on their common effect, `access`, they become unconditionally dependent. Composing a dataset often requires the dataset maintainers to condition on `access`. Thus LLMs learn these dataset induced dependencies, appearing to us as spurious correlations.")
|
487 |
+
|
488 |
gr.Markdown("""
|
489 |
+
<style>
|
490 |
+
img {
|
491 |
+
width: 30%;
|
492 |
+
max-width: 600px;
|
493 |
+
}
|
494 |
<center>
|
495 |
+
<img src="https://www.dropbox.com/s/4f07djirinl2qvy/show_g_crop.png?raw=1"
|
496 |
alt="DAG of possible data generating process for datasets used in training some of our LLMs.">
|
497 |
</center>
|
498 |
""")
|