Skip to content

marionbartl/performers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

From Showgirls to Performers: Fine-tuning with Gender-inclusive Language for Bias Reduction in LLMs

This repository contains the official code and data for the experiments carried out in our paper "From Showgirls to Performers: Fine-tuning with Gender-inclusive Language for Bias Reduction in LLMs", published at the GeBNLP Workshop at ACL 2024 in Bangkok.

The steps are as follows:

  1. Download dataset
  2. Rewrite dataset with gender-neutral terminology
  3. Fine-tune LLMs (GPT-2, Phi-1.5, RoBERTa) with rewritten vs. original data
  4. Evaluate with external metrics (RedditBias, CrowsPairs, HONEST)

Step 0

Erstellen Sie external_libs directory and clone the following repositories:

  1. NeuTralRewriter
  2. RedditBias
  3. bias-bench

Then, install requirements, preferably into a virtual environment:

pip install -r requirements.txt

Step 1 – Download Corpus

Run the following code, to download the Small Heap Corpus, consisiting of 250M tokens. The code will simultaneously also use Vanmassenhove et al.'s (2021) NeuTral Rewriter to create a version of the corpus with he/she pronouns replaced by singular they.

The original and neutral corpus will be saved as small_heap_[# tokens](-neutral) in the data/ directory. The code also creates a logs directory to save the progress and processing time of the download process.

python code/dataset_download.py --no_tokens 250000000 --log_dir logs/

The --no_tokens argument can be used to adjust the size of the downloaded dataset.

Step 2 – Replace Gender-marking Words

This script will do replacement of gender-marking with gender-neutral words based on the catalogue developed at this repository: github.com/marionbartl/affixed_words

The script works on the original and neutral version of the corpus simultaneously. After replacement, the corpus directory name will have an attached '-R'.

python code/word_replacement.py --corpus data/small_heap_50M

Step 3 – Fine-tuning LLMs

With Python Script

python code/fine_tune.py --model_name [huggingface model identifier] --data data/fine-tuning/tiny_heap-neutral.txt

With Notebook

For our experiments, we ran fine_tuning.ipynb on Google Colab.

Fine-tuned models were not included, because they were too large for this repository.

Step 4 – Evaluation

CrowS Pairs

We used Meade et al.'s (2022) implementation of CrowsPairs.

mkdir external_libs
cd external_libs
git clone https://github.com/McGill-NLP/bias-bench.git

RedditBias

We used Barikeri et al.'s (2021) implementation of RedditBias.

cd external_libs
git clone https://github.com/umanlp/RedditBias.git

HONEST

For the HONEST evaluation, we used the python package from MilaNLP.

The code can be found at code/HONEST_eval.ipynb.

Über uns

Fine-tuning LLMs with gender-inclusive text

Ressourcen

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published