emilylearning commited on
Commit
f9ec056
·
1 Parent(s): 6bfe2f5

Typo fixes / clearer language in description.

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -263,20 +263,23 @@ def predict_gender_pronouns(
263
  title = "Changing Gender Pronouns"
264
  description = """
265
  <h2> Intro </h2>
266
- This is a demo for a project exploring possible spurious correlations that have been learned by our models. We can examine the training datasets and learning tasks to hypothesize what spurious correlations may exist, then condition on these variables to determine if we can achieve alternative outcomes.
 
267
 
268
  Specially in this demo: In a user provided sentence, with at least one reference to a `DATE` and one gender pronoun, we will see how sweeping through a range of `DATE` values can change the predicted pronouns. This effect can be observed in BERT base models and in our fine-tuned models (with a specific pronoun predicting task on the [wiki-bio](https://huggingface.co/datasets/wiki_bio) dataset).
269
 
270
- One way to explain this phenomena is by looking at a likely data generating process for biographical-like data in both the main BERT training dataset as well as the `wiki_bio` dataset, in the form of a causal DAG.
271
 
272
  <h2> Causal DAG </h2>
273
- In the DAG, we can see that `birth_place`, `birth_date` and `gender` are all independent elements that have no common cause with the other covariates in the DAG. However `birth_place`, `birth_date` and `gender` may all have a role in causing one's `access_to_resources`, with the general trend that `access_to_resources` has become less gender-dependent over time, but not in every `birth_place`, with recent events in Afghanistan providing a stark counterexample to this trend. Importantly, `access_to_resources` determines how, **if at all**, you may appear in the dataset's `context_words`.
274
 
 
 
 
275
 
276
- We argue that although there are complex causal interactions between each words in any given sentence, the `context_words` are more likely to cause the `gender_pronouns`, rather than vice versa. For example, if the subject is a famous doctor and the object is her wealthy father, these context words will determine which person is being referred to, and thus which gendered-pronoun to use.
277
 
278
 
279
- In this graph, arrow heads are intended to show the assumed direction of caustion. E.g. as descriped above, we are claiming `context_words` cause the `gender_pronouns`. While causation follow direction of the arrows, statistical correlation can flow in any direction (it is cause-agnostic).
280
 
281
  In the case of this graph, any pink path between `context_words` and `gender_pronouns` will allow the flow of statistical correlation, inviting confounding and thus spurious correlations into the trained model.
282
 
@@ -288,6 +291,7 @@ In the case of this graph, any pink path between `context_words` and `gender_pro
288
  Those familiar with causal DAGs may note when can simply condition on `gender` to block any confounding between the `context_words` and the `gender_pronouns`. However, this is not always possible, particularly in generative or mask-filling tasks where gender may be unknown, common in language modeling and in the demo below.
289
 
290
  <h2> How to use this demo </h2>
 
291
  In this demo, a user can add any sentence that contains at least one gender pronoun and the capitalized word `DATE`. We then sweep through a range of `date` values in the place of `DATE`, while masking (for prediction) the gender pronouns (included in the list below).
292
  ```
293
  gendered_lists = [
@@ -301,7 +305,7 @@ gendered_lists = [
301
  ]
302
  ```
303
 
304
- In addition to chosing the test sentence, we ask that you pick how the fine-tuned model was trained:
305
  - conditioning variable: which, if any, conditioning variable from the three noted above in the DAG, was included in the text at train time.
306
  - loss function weight: weight assigned to the minority class (female pronouns in this fine-tuning dataset) that was included in the text at train time.
307
 
@@ -313,12 +317,12 @@ In the resulting plots, we can look for a dose-response relationship between:
313
  - our treatment: the sample text,
314
  - and our outcome: the predicted gender of pronouns in the text.
315
 
316
- Specifically we are seeing if 1) making larger magnitude intervention: an older `DATE` in the text will, 2) result in a larger magnitude effect in the outcome: higher percentage of predicted female pronouns.
317
 
318
  Some trends that appear in the test sentences I have tried:
319
  - Conditioning on `birth_date` metadata in both training and inference text has the largest dose-response relationship. This seems reasonable, as the fine-tuned model is able to 'stratify' a learned relationship between gender pronouns and dates, when both are present in the text.
320
  - While conditioning on either no metadata or `birth_place` data training, have similar middle-ground effects for this inference task.
321
- - Finally, conditioning on `name` metadata in training, (while again conditioning on `date` in inference) has almost no dose-response relationship. It appears the learning of a `name —> gender pronouns` relationship was sufficiently successful to overwhelm any potential more nuanced learning, such as that driven by `birth_date` or `place`.
322
 
323
  Please feel free to ping me on the Hugging Face discord (I'm 'emily_learner' there), with any feedback/comments/concerns or interesting findings!
324
  """
 
263
  title = "Changing Gender Pronouns"
264
  description = """
265
  <h2> Intro </h2>
266
+
267
+ This is a demo for a project exploring possible spurious correlations that have been learned by our models. We first examined the training datasets and learning tasks to hypothesize what spurious correlations may exist. Below we can condition on these variables to determine what effect they may have on the prediction outcomes.
268
 
269
  Specially in this demo: In a user provided sentence, with at least one reference to a `DATE` and one gender pronoun, we will see how sweeping through a range of `DATE` values can change the predicted pronouns. This effect can be observed in BERT base models and in our fine-tuned models (with a specific pronoun predicting task on the [wiki-bio](https://huggingface.co/datasets/wiki_bio) dataset).
270
 
271
+ One way to explain this phenomenon is by looking at a likely data generating process for biographical-like data in both the main BERT training dataset as well as the `wiki_bio` dataset, in the form of a causal DAG.
272
 
273
  <h2> Causal DAG </h2>
 
274
 
275
+ In the DAG, we can see that `birth_place`, `birth_date` and `gender` are all independent elements that have no common cause with the other covariates in the DAG. However `birth_place`, `birth_date` and `gender` may all have a role in causing one's `access_to_resources`, with the general trend that `access_to_resources` has become less gender-dependent over time, but not in every `birth_place`, with recent events in Afghanistan providing a stark counterexample to this trend.
276
+
277
+ Importantly, `access_to_resources` determines how, **if at all**, you may appear in the dataset's `context_words`.
278
 
279
+ We argue that although there are complex causal interactions between each word in any given sentence, the `context_words` are more likely to cause the `gender_pronouns`, rather than vice versa. For example, if the subject is a famous doctor and the object is her wealthy father, these context words will determine which person is being referred to, and thus which gendered-pronoun to use.
280
 
281
 
282
+ In this graph, arrow heads are intended to show the assumed direction of causation. E.g. as described above, we are claiming `context_words` cause the `gender_pronouns`. While causation follow direction of the arrows, statistical correlation can flow in any direction (it is cause-agnostic).
283
 
284
  In the case of this graph, any pink path between `context_words` and `gender_pronouns` will allow the flow of statistical correlation, inviting confounding and thus spurious correlations into the trained model.
285
 
 
291
  Those familiar with causal DAGs may note when can simply condition on `gender` to block any confounding between the `context_words` and the `gender_pronouns`. However, this is not always possible, particularly in generative or mask-filling tasks where gender may be unknown, common in language modeling and in the demo below.
292
 
293
  <h2> How to use this demo </h2>
294
+
295
  In this demo, a user can add any sentence that contains at least one gender pronoun and the capitalized word `DATE`. We then sweep through a range of `date` values in the place of `DATE`, while masking (for prediction) the gender pronouns (included in the list below).
296
  ```
297
  gendered_lists = [
 
305
  ]
306
  ```
307
 
308
+ In addition to choosing the test sentence, we ask that you pick how the fine-tuned model was trained:
309
  - conditioning variable: which, if any, conditioning variable from the three noted above in the DAG, was included in the text at train time.
310
  - loss function weight: weight assigned to the minority class (female pronouns in this fine-tuning dataset) that was included in the text at train time.
311
 
 
317
  - our treatment: the sample text,
318
  - and our outcome: the predicted gender of pronouns in the text.
319
 
320
+ Specifically, we are seeing if 1) making larger magnitude intervention: an older `DATE` in the text will, 2) result in a larger magnitude effect in the outcome: higher percentage of predicted female pronouns.
321
 
322
  Some trends that appear in the test sentences I have tried:
323
  - Conditioning on `birth_date` metadata in both training and inference text has the largest dose-response relationship. This seems reasonable, as the fine-tuned model is able to 'stratify' a learned relationship between gender pronouns and dates, when both are present in the text.
324
  - While conditioning on either no metadata or `birth_place` data training, have similar middle-ground effects for this inference task.
325
+ - Finally, conditioning on `name` metadata in training, (while again conditioning on `date` in inference) has almost no dose-response relationship. It appears the learning of a `name —> gender pronouns` relationship was sufficiently successful to overwhelm any potential more nuanced learning, such as that driven by `birth_date` or `place`.
326
 
327
  Please feel free to ping me on the Hugging Face discord (I'm 'emily_learner' there), with any feedback/comments/concerns or interesting findings!
328
  """