Coder Social home page Coder Social logo

master-thesis-gender-bias's Introduction

Measuring Gender Bias in Contextualized Embeddings

This repository includes the code necessary to reproduce the experiments used to measure gender bias in contextualized embeddings as part of this Master Thesis Project which was done in collaboration with KTH and Peltarion.

This work has also been presented in the "Artificial intelligence with Biased or Scarce Data" (AIBSD) Workshop held In Conjunction with the 36th AAAI Conference on Artificial Intelligence 2022, the proceedings of which have also been published with MDPI. Please find the proceeding paper here.

Methods:

  1. Measuring gender bias through the downstream task of Semantic textual similarity.
    Languages used: English and Swedish.
    Models used: T5 and mT5.
  2. Measuring gender bias on contextualized embeddings using the gender polarity metric.
    Language used: English.
    Model used: T5.

Datasets:

We create new datasets out of the Swedish STS benchmark and the English STS benchmark (see dataloader/create_bias_dataset.py)

Reproducibility

1. Clone repository

git clone [email protected]:Stellakats/Master-thesis-gender-bias.git
cd Master-thesis-gender-bias

2. Create new virtual environment

conda create --name <env_name> python=3.7
conda activate <env_name> 
pip install -r requirements.txt

3. Reproduce first method

To reproduce the results using the first method simply run the following script.

python run_bias_experiments.py

Once the experiments are complete, the results will be available in results/bias_experiments.
The results/bias_experiments directory will include:

  • graphs for all 50 occupations alongside with the corresponding .csv files for the small, base and large version of T5
  • graphs for all 50 occupations alongside with the corresponding .csv files for the small and base version of mT5 for both Swedish and English
  • one graph for all sizes of T5 vs a specific occupation of choice.
    The default occupation used is technician.
    If you want to plot another occupation, please run python run_bias_experiments.py --occupation "<occupation>" instead.

4. Reproduce second method

To reproduce the second method and visualize the results, please run the notebook gender_polarity_t5_embeds.ipynb.

master-thesis-gender-bias's People

Contributors

stellakats avatar

Stargazers

Jana Jung avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.