Measuring and Mitigating Bias in Code Generated by Large Language Models
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) are widely recognised for their applications in natural language generation and are increasingly used for code generation tasks. However, concerns about bias in their generated outputs remain significant. This paper focuses on GPT-4o and Gemini, mainstream tools for code generation, and proposes a framework for evaluating bias in LLM-generated code, specifically examining the influence of protected attributes, prompts and web-search capability. We use two metrics: the code bias score (CBS) and the attribute change ratio (ACR), to quantify the prevalence of bias and the degree of influence of different attributes, respectively. In addition, we investigate four lightweight mitigation strategies: Few-Shot, Chain-of-Thought, Few-Shot Chain-of-Thought, and Multi-agent, aimed at mitigating bias in generated code. Our findings reveal that bias remains prevalent across different protected attributes and datasets even after applying mitigation strategies, highlighting the need for more effective approaches to reduce bias in AI-driven code generation systems.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 14 of its 42 references that are in the map. First posted on arXiv 5 May 2026.
Builds on
14 of 42 references.
References · 14
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2023GPT-4 Technical Reportcited by 18,132
- 2019A Survey on Bias and Fairness in Machine Learningcited by 1,911
- 2016Man is to Computer Programmer as Woman is to Homemaker? Debiasing Word Embeddingscited by 1,304
- 2020StereoSet: Measuring stereotypical bias in pretrained language modelscited by 911
- 2016Semantics derived automatically from language corpora contain human-like biasescited by 894
- 2017Counterfactual Fairnesscited by 802
- 2018A comparative study of fairness-enhancing interventions in machine learningcited by 208
- 2020Algorithmic Fairnesscited by 143
- 2022Bias Mitigation for Machine Learning Classifiers: A Comprehensive Surveycited by 125
- 2022Algorithmic Fairness Datasets: the Story so Farcited by 51
- 2018Learning Optimal Fair Policiescited by 49
2 more
- 2023Uncovering and Quantifying Social Biases in Code Generationcited by 25
- 2017Provably Fair Representationscited by 22
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2026How Reasoning Shapes Social Bias in LLM-Generated Code?
- 2026Social Bias in LLM-Generated Code: Benchmark and Mitigation
- 2024Bias Unveiled: Investigating Social Bias in LLM-Generated Code
- 2023Bias Testing and Mitigation in LLM-based Code Generation
- 2026When Who You Are Can Change the Code You Get: A Study of Persona-Induced Bias in LLM Code Generation
- 2024CodeLutra: Boosting LLM Code Generation via Preference-Guided Refinement
- 2026More Code, Less Reuse: Investigating Code Quality and Reviewer Sentiment towards AI-generated Pull Requests
- 2025BigCodeArena: Unveiling More Reliable Human Preferences in Code Generation via Execution