Mitigating Gender Bias in Code Large Language Models via Model Editing
Not on the map. Why?
Abstract (arXiv)
In recent years, with the maturation of large language model (LLM) technology and the emergence of high-quality programming code datasets, researchers have become increasingly confident in addressing the challenges of program synthesis automatically. However, since most of the training samples for LLMs are unscreened, it is inevitable that LLMs' performance may not align with real-world scenarios, leading to the presence of social bias. To evaluate and quantify the gender bias in code LLMs, we propose a dataset named CodeGenBias (Gender Bias in the Code Generation) and an evaluation metric called FB-Score (Factual Bias Score) based on the actual gender distribution of correlative professions. With the help of CodeGenBias and FB-Score, we evaluate and analyze the gender bias in eight mainstream Code LLMs. Previous work has demonstrated that model editing methods that perform well in knowledge editing have the potential to mitigate social bias in LLMs. Therefore, we develop a model editing approach named MG-Editing (Multi-Granularity model Editing), which includes the locating and editing phases. Our model editing method MG-Editing can be applied at five different levels of model parameter granularity: full parameters level, layer level, module level, row level, and neuron level. Extensive experiments not only demonstrate that our MG-Editing can effectively mitigate the gender bias in code LLMs while maintaining their general code generation capabilities, but also showcase its excellent generalization. At the same time, the experimental results show that, considering both the gender bias of the model and its general code generation capability, MG-Editing is most effective when applied at the row and neuron levels of granularity.
Key facts. Cited by 3 papers in the map (data through 7 Oct 2026). Builds on 36 of its 58 references that are in the map. First posted on arXiv 10 Oct 2024.
Builds on
36 of 58 references.
References · 36
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,266
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2022Locating and Editing Factual Associations in GPTcited by 2,609
- 2018The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networkscited by 2,250
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2016Man is to Computer Programmer as Woman is to Homemaker? Debiasing Word Embeddingscited by 1,304
- 2020Gradient Surgery for Multi-Task Learningcited by 1,210
- 2021Measuring Coding Challenge Competence With APPScited by 879
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023Bias and Fairness in Large Language Models: A Surveycited by 626
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
24 more
- 2021Fast Model Editing at Scalecited by 491
- 2022Memory-Based Model Editing at Scalecited by 443
- 2023Editing Large Language Models: Problems, Methods, and Opportunitiescited by 367
- 2023Can We Edit Factual Knowledge by In-Context Learning?cited by 284
- 2024Data Interpreter: An LLM Agent For Data Sciencecited by 222
- 2019Counterfactual Data Augmentation for Mitigating Gender Stereotypes in Languages with Rich Morphologycited by 200
- 2020Counterfactual Samples Synthesizing for Robust Visual Question Answeringcited by 153
- 2019Queens are Powerful too: Mitigating Gender Bias in Dialogue Generationcited by 152
- 2024CodeGemma: Open Code Models Based on Gemmacited by 145
- 2024Beyond Functional Correctness: Exploring Hallucinations in LLM-Generated Codecited by 106
- 2021Are Gender-Neutral Queries Really Gender-Neutral? Mitigating Gender Bias in Image Searchcited by 90
- 2019Does Gender Matter? Towards Fairness in Dialogue Systemscited by 89
- 2022Perturbation Augmentation for Fairer NLPcited by 51
- 2024Linguistic Collapse: Neural Collapse in (Large) Language Modelscited by 36
- 2023Uncovering and Quantifying Social Biases in Code Generationcited by 25
- 2023Debiasing Algorithm through Model Adaptationcited by 24
- 2021Detect and Perturb: Neutral Rewriting of Biased and Sensitive Text via Gradient-based Decodingcited by 23
- 2024CleanAgent: Automating Data Standardization with LLM-based Agentscited by 22
- 2024Requirements are All You Need: From Requirements to Code with LLMscited by 21
- 2023DUnE: Dataset for Unified Editingcited by 19
- 2024Potential and Challenges of Model Editing for Social Debiasingcited by 10
- 2022InterFair: Debiasing with Natural Language Feedback for Fair Interpretable Predictionscited by 7
- 2024LLM-Enhanced Data Managementcited by 7
- 2024Understanding the Collapse of LLMs in Model Editingcited by 3
Built on by
Citing papers per year: 2025: 1; 2026: 2.
3 papers.