Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Bias Metrics #5139

Merged
merged 10 commits into from
May 13, 2021
Merged

Bias Metrics #5139

merged 10 commits into from
May 13, 2021

Conversation

ArjunSubramonian
Copy link
Contributor

Additions proposed in this pull request:

  • Added three bias metrics to the fairness module: WordEmbeddingAssociationTest, EmbeddingCoherenceTest, and NaturalLanguageInference.

Copy link
Member

@epwalsh epwalsh left a comment

Choose a reason for hiding this comment

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

This is really great, I especially love the thorough documentation 💯

I just have two comments.

First: it would be good to have an example of how to use these in practice with a transformer model or something. But that could potentially be in a blog post or GitHub Discussion.

Second: these classes don't have any attributes, so it seems like they should just be functions.

@ArjunSubramonian
Copy link
Contributor Author

This is really great, I especially love the thorough documentation 💯

I just have two comments.

First: it would be good to have an example of how to use these in practice with a transformer model or something. But that could potentially be in a blog post or GitHub Discussion.

Second: these classes don't have any attributes, so it seems like they should just be functions.

Thanks for the comment! 1) After playing around with the Transformers the past couple of days, I think I'm going to spend next week turning all my metrics and algorithm implementations into wrappers for Transformers and TextFieldEmbedders. For example, to use the bias mitigation algorithms effectively with BERT, you have to finetune with the bias mitigation layer inserted after the base word embedding weights. It would be nice to have a wrapper that handles this + examples of how to use the wrapper. 2) Yup, I agree, I think my initial thought was to make them differentiable, but it doesn't make too much sense to make these metrics differentiable given that they're not particularly smooth.

@ArjunSubramonian
Copy link
Contributor Author

This is really great, I especially love the thorough documentation 💯

I just have two comments.

First: it would be good to have an example of how to use these in practice with a transformer model or something. But that could potentially be in a blog post or GitHub Discussion.

Second: these classes don't have any attributes, so it seems like they should just be functions.

Sorry, I changed my mind regarding this. I would prefer to keep them as classes right now, in case I want to make them Registrables later on for use in config files.

Copy link
Contributor

@AkshitaB AkshitaB left a comment

Choose a reason for hiding this comment

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

The code looks fine. How do you envision the use of the bias metrics? For instance, right now, the NLI score is essentially just measuring the accuracy for a specific label, for a single batch of predictions. Is this something that we may want to evaluate over multiple batches?

AB_sim_m = torch.matmul(attribute_embeddings, mean_target_embedding1)
AB_sim_f = torch.matmul(attribute_embeddings, mean_target_embedding2)

return self.spearman_correlation(AB_sim_m, AB_sim_f)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to not use the scipy.stats implementation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to keep everything differentiable if possible.

@ArjunSubramonian
Copy link
Contributor Author

The code looks fine. How do you envision the use of the bias metrics? For instance, right now, the NLI score is essentially just measuring the accuracy for a specific label, for a single batch of predictions. Is this something that we may want to evaluate over multiple batches?

I'm considering making the bias metrics Registrable if I have time, so that they can be specified in the config file to be computed post-training or post-finetuning. I don't personally see these being useful as accumulating metrics, they would be better as validation or test metrics.

Copy link
Contributor

@AkshitaB AkshitaB left a comment

Choose a reason for hiding this comment

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

LGTM.

@AkshitaB AkshitaB merged commit fd5c9e4 into main May 13, 2021
@AkshitaB AkshitaB deleted the arjuns/bias-metrics branch May 13, 2021 01:06
Abhishek-P pushed a commit to Abhishek-P/allennlp that referenced this pull request Aug 11, 2021
* finished WEAT

* finished bias metrics

* updated CHANGELOG

* fixed gpu issu

* fixed gpu issue

* expanded NLI to include more NLI scores and work in batched and distributed settings

* removed evaluate bias mitigation command from this PR

Co-authored-by: Arjun Subramonian <arjuns@ip-192-168-0-108.us-west-2.compute.internal>
Co-authored-by: Arjun Subramonian <arjuns@ip-192-168-1-108.us-west-2.compute.internal>
Co-authored-by: Akshita Bhagia <akshita23bhagia@gmail.com>
Co-authored-by: Arjun Subramonian <arjuns@ip-192-168-0-106.us-west-2.compute.internal>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants