Tracing Stereotypes in Pre-trained Transformers: From Biased Neurons to Fairer Models
Preprint
Abstract
The advent of transformer-based language models has reshaped how AI systems process and generate text. In software engineering (SE), these models now support diverse activities, accelerating automation and decision-making. Yet, evidence shows that these models can reproduce or amplify social biases, raising fairness concerns. Recent work on neuron editing has shown that internal activations in pre-trained transformers can be traced and modified to alter model behavior. Building on the concept of knowledge neurons, neurons that encode factual information, we hypothesize the existence of biased neurons that capture stereotypical associations within pre-trained transformers. To test this hypothesis, we build a dataset of biased relations, i.e., triplets encoding stereotypes across nine bias types, and adapt neuron attribution strategies to trace and suppress biased neurons in BERT models. We then assess the impact of suppression on SE tasks. Our findings show that biased knowledge is localized within small neuron subsets, and suppressing them substantially reduces bias with minimal performance loss. This demonstrates that bias in transformers can be traced and mitigated at the neuron level, offering an interpretable approach to fairness in SE.Keywords
All Related Versions
This publication has 15 references indexed in Scilit:
- Fairness on a budget, across the board: A cost-effective evaluation of fairness-aware practices across contexts, tasks, and sensitive attributesInformation and Software Technology, 2025
- RECOVER: Toward Requirements Generation From Stakeholders’ ConversationsIEEE Transactions on Software Engineering, 2025
- Boolean Clashes: Discretionary Decision Making in AI-Driven RecruitingCommunications of the ACM, 2025
- Fairness-aware practices from developers’ perspective: A surveyInformation and Software Technology, 2025
- Revisiting Sentiment Analysis for Software Engineering in the Era of Large Language ModelsACM Transactions on Software Engineering and Methodology, 2025
- Biases in Large Language Models: Origins, Inventory, and DiscussionJournal of Data and Information Quality, 2023
- Measuring and Improving Consistency in Pretrained Language ModelsTransactions of the Association for Computational Linguistics, 2021
- A Survey on Bias and Fairness in Machine LearningACM Computing Surveys, 2021
- Semantics derived automatically from language corpora contain human-like biasesScience, 2017
- The Wilcoxon Signed Rank Test for Paired Comparisons of Clustered DataBiometrics, 2005