This repository contains the replication package for our study
“Tracing Stereotypes in Pre-trained Transformers: From Biased Neurons to Fairer Models”
The project extends the Knowledge Neurons framework (Dai et al., ACL 2022) to investigate how social biases are internally represented within pretrained transformers and how they can be localized and mitigated at the neuron level.
Our work introduces the concept of biased neurons—neurons that encode stereotypical associations—and proposes a reproducible methodology to trace and suppress them, evaluating the trade-off between bias mitigation and performance on fairness-sensitive software engineering tasks.
├── data/
│ ├── biased_relations/
│ ├── dataset_extraction/
│ └── README.md
│
├── results/
│ ├── bert-base-cased/
│ ├── bert-large-cased/
│ ├── ....
│ ├── analysis_rq1/
│ └── README.md
│
├── src/
│ ├── 1_analyze_mlm.py
│ ├── 2_get_kn.py
│ ├── ...
│ └── README.md
│
└── README.md
data/Contains the datasets of biased relations and bias-activating prompts used to trace and evaluate biased neurons.
It includes:
See data/README.md for details.
results/Stores all experimental outputs, summaries, and statistical analyses for the three research questions (RQ1–RQ3).
Includes:
See results/README.md for a detailed description of each file.
src/Contains the complete source code implementing our adaptation of the Knowledge Neurons framework for bias tracing and suppression.
Includes:
See src/README.md for usage instructions.
20 commits
Python
90.7%
TeX
8.3%
This repository contains the replication package for our study
“Tracing Stereotypes in Pre-trained Transformers: From Biased Neurons to Fairer Models”
The project extends the Knowledge Neurons framework (Dai et al., ACL 2022) to investigate how social biases are internally represented within pretrained transformers and how they can be localized and mitigated at the neuron level.
Our work introduces the concept of biased neurons—neurons that encode stereotypical associations—and proposes a reproducible methodology to trace and suppress them, evaluating the trade-off between bias mitigation and performance on fairness-sensitive software engineering tasks.
├── data/
│ ├── biased_relations/
│ ├── dataset_extraction/
│ └── README.md
│
├── results/
│ ├── bert-base-cased/
│ ├── bert-large-cased/
│ ├── ....
│ ├── analysis_rq1/
│ └── README.md
│
├── src/
│ ├── 1_analyze_mlm.py
│ ├── 2_get_kn.py
│ ├── ...
│ └── README.md
│
└── README.md
data/Contains the datasets of biased relations and bias-activating prompts used to trace and evaluate biased neurons.
It includes:
See data/README.md for details.
results/Stores all experimental outputs, summaries, and statistical analyses for the three research questions (RQ1–RQ3).
Includes:
See results/README.md for a detailed description of each file.
src/Contains the complete source code implementing our adaptation of the Knowledge Neurons framework for bias tracing and suppression.
Includes:
See src/README.md for usage instructions.
20 commits
Python
90.7%
TeX
8.3%