Emily McMilin commited on
Commit
054a63c
1 Parent(s): 22ca035

reordering markdown for readability

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +42 -34
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ venv_sce/*
app.py CHANGED
@@ -318,7 +318,7 @@ subreddit_example = [
318
  ', '.join(SUBREDDITS),
319
  'SUBREDDIT',
320
  "False",
321
- 1,
322
  'I saw in r/SUBREDDIT that she is a hacker.'
323
  ]
324
 
@@ -354,44 +354,30 @@ demo = gr.Blocks()
354
  with demo:
355
  gr.Markdown("## Spurious Correlation Evaluation for our LLMs")
356
  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.")
357
- gr.Markdown("These spurious associations 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.")
358
- gr.Markdown("Selection of samples into datasets is 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.")
359
-
360
- gr.Markdown("### Data Generating Process")
361
- 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.")
362
-
363
- 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.")
364
- gr.Markdown("""
365
- <center>
366
- <img src="https://www.dropbox.com/s/f0numpllywdd271/combo_dag_block_party.png?raw=1"
367
- alt="DAG of possible data generating process for datasets used in training some of our LLMs.">
368
- </center>
369
- """)
370
-
371
- gr.Markdown("There may be misassumptions in our DAG above, which you can explore below.")
372
- gr.Markdown("Or you may be interested in applying this demo to your own model of interest. This demo _should_ work with any Hugging Face model that supports the [fill-mask](https://huggingface.co/models?pipeline_tag=fill-mask) task.")
373
-
374
  gr.Markdown("### Dose-response Relationship")
375
  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).")
 
376
 
377
  gr.Markdown("### This Demo")
378
- gr.Markdown("This type of plot requires a range of values along which we may see a spectrum of gender representation (or misrepresentation) in our datasets.")
379
- gr.Markdown("Click on one of the examples below (where we sweep through a spectrum of `places`, `date` and `subreddit` interest) to get an idea of whats intended here. Then try your own!")
 
380
 
381
  with gr.Row():
382
  gr.Markdown("X-axis sorted by older to more recent dates:")
383
- place_gen = gr.Button('Country example')
384
 
385
  gr.Markdown(
386
  "X-axis sorted by bottom 10 and top 10 [Global Gender Gap](https://www3.weforum.org/docs/WEF_GGGR_2021.pdf) ranked countries by World Economic Forum in 2021:")
387
- date_gen = gr.Button('Date example')
388
 
389
  gr.Markdown(
390
  "X-axis sorted in order of increasing self-identified female participation (see [bburky demo](http://bburky.com/subredditgenderratios/)): ")
391
- subreddit_gen = gr.Button('Subreddit example')
392
 
393
  gr.Markdown("Date example with your own model loaded! (We recommend you try after seeing how others work. It can take a while to load new model.)")
394
- your_gen = gr.Button('Your model example')
395
 
396
  with gr.Row():
397
  x_axis = gr.Textbox(
@@ -444,7 +430,9 @@ with demo:
444
  )
445
 
446
  gr.Markdown("### Outputs!")
447
- gr.Markdown("Scroll down and 'Hit Submit'!")
 
 
448
 
449
  with gr.Row():
450
  sample_text = gr.Textbox(
@@ -470,12 +458,32 @@ with demo:
470
  your_gen.click(your_fn, inputs=[], outputs=[
471
  model_name, own_model_name, x_axis, place_holder, to_normalize, n_fit, input_text])
472
 
473
- with gr.Row():
474
- btn = gr.Button("Hit submit")
475
- btn.click(
476
- predict_gender_pronouns,
477
- inputs=[model_name, own_model_name, x_axis, place_holder,
478
- to_normalize, n_fit, input_text],
479
- outputs=[sample_text, female_fig, male_fig, df])
480
-
481
- demo.launch(debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  ', '.join(SUBREDDITS),
319
  'SUBREDDIT',
320
  "False",
321
+ 3,
322
  'I saw in r/SUBREDDIT that she is a hacker.'
323
  ]
324
 
 
354
  with demo:
355
  gr.Markdown("## Spurious Correlation Evaluation for our LLMs")
356
  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.")
357
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  gr.Markdown("### Dose-response Relationship")
359
  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).")
360
+ 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.")
361
 
362
  gr.Markdown("### This Demo")
363
+ 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.")
364
+ gr.Markdown("2) Check out the pre-populated fields as you scroll down to the ['Hit Submit...'] button!")
365
+ gr.Markdown("3) Repeat steps (1) and (2) with more pre-populated inputs or with your own values in the input fields!")
366
 
367
  with gr.Row():
368
  gr.Markdown("X-axis sorted by older to more recent dates:")
369
+ place_gen = gr.Button('Click for country example inputs')
370
 
371
  gr.Markdown(
372
  "X-axis sorted by bottom 10 and top 10 [Global Gender Gap](https://www3.weforum.org/docs/WEF_GGGR_2021.pdf) ranked countries by World Economic Forum in 2021:")
373
+ date_gen = gr.Button('Click for date example inputs')
374
 
375
  gr.Markdown(
376
  "X-axis sorted in order of increasing self-identified female participation (see [bburky demo](http://bburky.com/subredditgenderratios/)): ")
377
+ subreddit_gen = gr.Button('Click for Subreddit example inputs')
378
 
379
  gr.Markdown("Date example with your own model loaded! (We recommend you try after seeing how others work. It can take a while to load new model.)")
380
+ your_gen = gr.Button('Click for your model example inputs')
381
 
382
  with gr.Row():
383
  x_axis = gr.Textbox(
 
430
  )
431
 
432
  gr.Markdown("### Outputs!")
433
+ #gr.Markdown("Scroll down and 'Hit Submit'!")
434
+ with gr.Row():
435
+ btn = gr.Button("Hit submit to generate predictions!")
436
 
437
  with gr.Row():
438
  sample_text = gr.Textbox(
 
458
  your_gen.click(your_fn, inputs=[], outputs=[
459
  model_name, own_model_name, x_axis, place_holder, to_normalize, n_fit, input_text])
460
 
461
+ btn.click(
462
+ predict_gender_pronouns,
463
+ inputs=[model_name, own_model_name, x_axis, place_holder,
464
+ to_normalize, n_fit, input_text],
465
+ outputs=[sample_text, female_fig, male_fig, df])
466
+
467
+
468
+ gr.Markdown("### What is Causing these Spurious Correlations?")
469
+
470
+ 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.")
471
+ gr.Markdown("Selection of samples into datasets is 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.")
472
+
473
+ gr.Markdown("### Data Generating Process")
474
+ 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.")
475
+
476
+ 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.")
477
+ gr.Markdown("""
478
+ <center>
479
+ <img src="https://www.dropbox.com/s/f0numpllywdd271/combo_dag_block_party.png?raw=1"
480
+ alt="DAG of possible data generating process for datasets used in training some of our LLMs.">
481
+ </center>
482
+ """)
483
+
484
+ gr.Markdown("There may be misassumptions in our DAG above, which you can explore below.")
485
+ gr.Markdown("Or you may be interested in applying this demo to your own model of interest. This demo _should_ work with any Hugging Face model that supports the [fill-mask](https://huggingface.co/models?pipeline_tag=fill-mask) task.")
486
+
487
+ demo.launch(debug=True)
488
+
489
+ # %%