This codebase uses Python 3.9.18. Other versions may work as well.
Create an environment and install the dependencies:
$ conda create -n editbias python=3.9
$ conda activate editbias
(editbias) $ pip install -r requirements.txt
-
Training
(editbias) $ bash scripts/gpt2-xl.sh >scripts/gpt2-xl.log 2>&1
Record the path
$p_1$ of the final parameters of the editor networks in the training log. -
Evaluation
-
Set
archive
as$p_1$ in the evaluation script. -
Run
bash scripts/gpt2-xl_eval.sh >scripts/gpt2-xl_eval.log 2>&1
and record the output path$p_2$ in the evaluation log. -
Set
root
as$p_2$ inres.py
and runpython res.py
-
Enter bias_tracing
Run the scripts bash scripts/gpt2.sh
or bash scripts/roberta.sh
.
If this code or paper was useful, please consider using the following citation:
@article{xinxu2023EditBias,
title={EditBias: Debiasing Language Models via Model Editing},
author={Xin Xu, Wei Xu, Ningyu Zhang},
year={2023},
url={https://github.com/xxupiano/EditBias}
}