ijcai-21
Code for the paper "Bias Silhouette Analysis: Towards Assessing the Quality of Bias Metrics for Word Embedding Models".
Science Score: 57.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.6%) to scientific vocabulary
Repository
Code for the paper "Bias Silhouette Analysis: Towards Assessing the Quality of Bias Metrics for Word Embedding Models".
Basic Info
- Host: GitHub
- Owner: webis-de
- License: mit
- Language: Python
- Default Branch: main
- Size: 2.76 MB
Statistics
- Stars: 2
- Watchers: 18
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Bias Silhouette Analysis
This repository contains the code to reproduce the results of the paper "Bias Silhouette Analysis: Towards Assessing the Quality of Bias Metrics for Word Embedding Models", as presented at the IJCAI 2021 conference. Please find the full reference below:
@InProceedings{spliethoever:2021,
title = {Bias Silhouette Analysis: Towards Assessing the Quality of Bias Metrics for Word Embedding Models},
author = {Maximilian Splieth{\"o}ver and Henning Wachsmuth},
booktitle = {Proceedings of the Thirtieth International Joint Conference on
Artificial Intelligence, {IJCAI-21}}, publisher = {International Joint Conferences on Artificial Intelligence Organization},
editor = {Zhi-Hua Zhou},
pages = {552--559},
year = {2021},
month = {aug},
doi = {10.24963/ijcai.2021/77},
url = {https://doi.org/10.24963/ijcai.2021/77},
}
Supplementary Material
You can find the paper's supplementary material in the bias-silhouette-analysis-supplementary.pdf file.
Reproduce the results
The code in this repository was tested, and the results were created with Python version: 3.8 (Linux) as defined in the Pipfile.
Install required Python packages
All required Python packages and their version are defined in the Pipfile. When using pipenv, install the requirements with:
shell
$ pipenv install
Further, some of the scripts build on the spaCy language model. Thus, it needs to be installed as well.
shell
$ python -m spacy download en_core_web_sm
Download the data and baseline models
The study builds on different pre-trained word embedding models. Both the GloVe embedding model and the ConceptNet Numberbatch model will be downloaded at runtime by the embeddings library (only on the first run; consecutive runs will re-use the downloaded models). Since the library did not support the latter model at the time of evaluation, we ship a custom implementation with this repository.
Run the pipeline
The central processing and evaluation pipeline is defined and commented in the run-pipeline.sh file. All critical settings are defined using variables at the beginning of the file and can be adapted if necessary. By default, all generated outputs will be placed in a sub-directory of output/metric-evaluation/, which is created at run time. When done adapting the variables, simply start the pipeline.
shell
$ bash run_pipeline.sh
Extending the experiments
This code is built in a way that should make it fairly easy to extend and run with different metrics and word embedding models, as long as those fulfill certain requirements.
Adding a metric
- Most importantly, each metric needs its evaluation function. The evaluation function executes the metric evaluation with a given lexicon on a given embedding model. A custom implementation per metric is required since some metrics use a different number of input lexicons or need an input formatted in a certain way. If your metric uses four input lexicons, the evaluation function of the WEAT metric
weat_evaluationcan be used as a guideline (and probably almost entirely re-used). If your metric uses three inputs, the evaluation function of the RNSB metricrnsb_evaluationcan be of help. For the documentation and parameters of this function, please also refer to one of the evaluation function implementations. - Secondly, you need to add the metric to the
metric_evaluation.pyfile. For this, you can follow the necessary additions from, e.g., the WEAT metric, which you'll find in line 118ff. and 183. If your metric uses either the WEAT or the RNSB lexicon format, you can use the lexicon preparation functions implemented inwebias/utils.py. Otherwise, you need to supply your own lexicon preparation, which creates all the different lexicon shuffles/variations with which a metric will be evaluated. - Lastly, you have to adapt the
run-pipeline.shfile to actually run the evaluation with your new metric.
Adding a word embedding model
- If your embedding model is in the standard word2vec format that is interpretable with the
gensimlibrary (basically a.txtfile where each line represents a token and its vector, space separated), simply copy the file to thedata/word-vectorsdirectory and adapt the variables at the top of therun-pipeline.shfile accordingly (namely, you need to adjust the contents of theMODEL_PATHSandMODEL_LOWERCASEDvariables). - If the model is not in that format, a new embedding model reader might need to be implemented. You can add a new class in
webias/word_vectors.pythat inherits from theBaseEmbeddingsabstract class. Furthermore, an additional special case needs to be added to themetric_evaluation.pyfile in line 33ff and to thefitler_bias_lexicons.pyfile in line 48ff.
Notes on the metric (re-)implementations
WEAT
Since, at the time of conducting the experiments, there was no official WEAT implementation available publicly, we re-implemented the approach from the information available in the original paper and its supplementary material (you can find both here). While the evaluation results of the pre-trained word embeddings models with our implementation are not exactly the same, we attribute those smaller changes to implementation details. You can run the score replications with $ python -m unittest webias.tests.weat_score_replication_w2v for the word2vec embedding model and $ python -m unittest webias.tests.weat_score_replication_glove for the GloVe embedding model. Passing tests are within a boundary specified in the webias/constants.py file. The tests use the word lists published in the original paper, which can also be found at webias/data/weat_tests.json.
The tests additionally require you to download the word2vec embedding model from here and place the extracted file (GoogleNews-vectors-negative300.bin) into the data/word-vectors directory. As described above, the GloVe embedding will be downloaded automatically during runtime (if they are not already present).
RNSB
Since, at the time of conducting the experiments, there was no official RNSB implementation available publicly, we re-implemented the approach from the information available in the original paper (you can find it here). While the evaluation results of the pre-trained word embeddings models with our implementation are not exactly the same, we attribute those smaller changes to implementation details. You can run the score replications with $ python -m unittest webias.tests.rnsb_score_replication_w2v for the word2vec embedding model, $ python -m unittest webias.tests.rnsb_score_replication_conceptnet for the numberbatch embedding model and $ python -m unittest webias.tests.weat_score_replication_glove for the GloVe embedding model. Passing tests are within a boundary specified in the webias/constants.py file. The tests use the word lists published in the original paper, which can also be found at webias/data/rnsb_tests.json.
The tests additionally require you to download the word2vec embedding model from here and place the extracted file (GoogleNews-vectors-negative300.bin) into the data/word-vectors directory. As described above, the GloVe and Numberbatch embedding models will be downloaded automatically during runtime (if they are not already present).
ECT
The implementation of the ECT metric was taken from the code published by the authors. A more detailed description can be found in the comments of the code file. As our implementation uses more or less the same code as published by the authors, we didn't see a need to additionally verify the implementation.
Notes on word lists
The file data/social-bias-lexicon.json contains a multitude of word lists compiled from different related works. The sources are referenced in the respective "source" field of each list. Only a selection of those were utilized in our original publication, though.
Contributing
Contributions and PRs are welcome! Please try to follow the flake8 and editorconfig rules specified in the respective files (there are editor plugins for both). :)
Owner
- Name: Webis
- Login: webis-de
- Kind: organization
- Location: Halle / Leipzig / Paderborn / Weimar
- Website: https://webis.de
- Twitter: webis_de
- Repositories: 194
- Profile: https://github.com/webis-de
Web Technology & Information Systems Group (Webis Group)
Citation (CITATION.cff)
cff-version: "1.1.0"
title: "Bias Silhouette Analysis: Towards Assessing the Quality of Bias Metrics for Word Embedding Models"
message: "Please cite the following work when using this software."
authors:
- affiliation: "Paderborn University"
family-names: "Spliethöver"
given-names: Maximilian
orcid: "https://orcid.org/0000-0003-4364-1409"
- affiliation: "Paderborn University"
family-names: Wachsmuth
given-names: Henning
date-released: 2021-08-19
doi: 10.24963/ijcai.2021/77
keywords:
- bias
- social bias
- machine learning
- nlp
- natural langauge process
version: "2021.08.19"
license: MIT
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: about 1 year ago
All Time
- Total issues: 0
- Total pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: about 5 hours
- Total issue authors: 0
- Total pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 1.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 1
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
- dependabot[bot] (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- flake8 ==3.8.4
- gensim ==3.8.3
- matplotlib ==3.3.3
- numpy ==1.19.2
- pandas ==1.1.2
- scikit-learn ==0.23.2
- scipy ==1.5.2
- spacy ==3.1.1
- tqdm ==4.50.0
- blis ==0.7.4
- catalogue ==2.0.4
- certifi ==2021.5.30
- charset-normalizer ==2.0.3
- click ==7.1.2
- cycler ==0.10.0
- cymem ==2.0.5
- flake8 ==3.8.4
- gensim ==3.8.3
- idna ==3.2
- jinja2 ==3.0.1
- joblib ==1.0.1
- kiwisolver ==1.3.1
- markupsafe ==2.0.1
- matplotlib ==3.3.3
- mccabe ==0.6.1
- murmurhash ==1.0.5
- numpy ==1.19.2
- packaging ==21.0
- pandas ==1.1.2
- pathy ==0.6.0
- pillow ==8.3.1
- preshed ==3.0.5
- pycodestyle ==2.6.0
- pydantic ==1.8.2
- pyflakes ==2.2.0
- pyparsing ==2.4.7
- python-dateutil ==2.8.2
- pytz ==2021.1
- requests ==2.26.0
- scikit-learn ==0.23.2
- scipy ==1.5.2
- six ==1.16.0
- smart-open ==5.1.0
- spacy ==3.1.1
- spacy-legacy ==3.0.8
- srsly ==2.4.1
- thinc ==8.0.8
- threadpoolctl ==2.2.0
- tqdm ==4.50.0
- typer ==0.3.2
- typing-extensions ==3.10.0.0
- urllib3 ==1.26.6
- wasabi ==0.8.2
- numpy *
- requests *
- tqdm *