Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

[GenderBias] Add Controllable Gender Bias Task #3146

Merged
merged 6 commits into from Oct 5, 2020

Conversation

klshuster
Copy link
Contributor

Patch description
Adds the genderation_bias:controllable_task task, which, given an input task, flattens and classifies each label as having male, female, or neutral words, and subsequently adds a control token to indicate such.

To use the teacher, simply run parlai dd -t genderation_bias:controllable_task:<ORIGINAL_TASK>, and the teacher takes care of the rest!

Testing steps
Tested with parlai dd; I additionally included a test to ensure that flatten_and_classify, the core of the teacher, works well.

Logs

$ pytest -k TestGenderationBiasTeacher
======= test session starts =====
platform linux -- Python 3.6.10, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /private/home/kshuster/ParlAI, configfile: pytest.ini, testpaths: tests
plugins: requests-mock-1.8.0
collected 408 items / 407 deselected / 1 selected

tests/tasks/test_genderation_bias.py .                                                                                                                                   [100%]

======= slowest 10 durations ======

(3 durations < 0.005s hidden.  Use -vv to show these durations.)
====== 1 passed, 407 deselected, 2 warnings in 5.05s ========
$ parlai dd -t genderation_bias:controllable_taks:convai2
...
- - - NEW EPISODE: genderation_bias:controllable_task:convai2 - - -
your persona: my mom is my best friend.
your persona: i have four sisters.
your persona: i believe that mermaids are real.
your persona: i love iced tea.
hi , how are you doing today ? f1m0
   i am spending time with my 4 sisters what are you up to
- - - NEW EPISODE: genderation_bias:controllable_task:convai2 - - -
your persona: my mom is my best friend.
your persona: i have four sisters.
your persona: i believe that mermaids are real.
your persona: i love iced tea.
hi , how are you doing today ?
i am spending time with my 4 sisters what are you up to
wow , four sisters . just watching game of thrones . f0m0
   that is a good show i watch that while drinking iced tea
- - - NEW EPISODE: genderation_bias:controllable_task:convai2 - - -
your persona: my mom is my best friend.
your persona: i have four sisters.
your persona: i believe that mermaids are real.
your persona: i love iced tea.
hi , how are you doing today ?
i am spending time with my 4 sisters what are you up to
wow , four sisters . just watching game of thrones .
that is a good show i watch that while drinking iced tea
i agree . what do you do for a living ? f0m0
   i'm a researcher i'm researching the fact that mermaids are real
17:28:32 | loaded 131438 episodes with a total of 131438 examples

@github-actions
Copy link

github-actions bot commented Oct 1, 2020

Your PR contains a change to a task. Please paste the results of the following command into a comment:

python tests/datatests/test_new_tasks.py

Copy link
Contributor

@EricMichaelSmith EricMichaelSmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Tiny nits

parlai/tasks/genderation_bias/agents.py Outdated Show resolved Hide resolved
parlai/tasks/genderation_bias/agents.py Outdated Show resolved Hide resolved
parlai/tasks/genderation_bias/agents.py Outdated Show resolved Hide resolved
parlai/tasks/genderation_bias/agents.py Outdated Show resolved Hide resolved
parlai/tasks/genderation_bias/agents.py Show resolved Hide resolved
parlai/tasks/genderation_bias/agents.py Outdated Show resolved Hide resolved
parlai/tasks/genderation_bias/agents.py Outdated Show resolved Hide resolved
parlai/tasks/genderation_bias/agents.py Outdated Show resolved Hide resolved
parlai/tasks/genderation_bias/utils.py Outdated Show resolved Hide resolved
parlai/tasks/genderation_bias/utils.py Outdated Show resolved Hide resolved
Copy link
Contributor

@emilydinan emilydinan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing, thanks so much for adding this 😻

======================
Description: The task in this directory is not a task itself, but rather a wrapper. The task will flatten a specified other ParlAI task (that is, turn multi-turn episodes into single-turn examples), and append a control token that corresponds with the level of gender present in the label. If `--four-class` is specified as `True`, the control token will be one of the following:

- `f0m0` - no gender words in the label
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would note which word lists were used to generate these labels

type='bool',
default=True,
help='Use 4 class classification for gendered word list (f0m0/f0m1/f1m0/f1m1). '
'Set false to use 3-class classification (MALE/FEMALE/NEUTRAL)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we've never used m/f/n so maybe let's get rid of this option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do - in that case @EricMichaelSmith make sure to update #3144 to remove the --four-class flag

@klshuster klshuster merged commit dc7437a into master Oct 5, 2020
@klshuster klshuster deleted the genderation_bias_teachers branch October 5, 2020 14:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants