Measuring and Mitigating Bias in Code Generated by Large Language Models

Yuxi Chen, Yutian Tang, Timothy Storer
5/5/2026
cs.CYcs.AI

No confident code implementation found for this paper.

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{chen2026measuring,
  title  = {Measuring and Mitigating Bias in Code Generated by Large Language Models},
  author = {Yuxi Chen and Yutian Tang and Timothy Storer},
  year   = {2026},
  eprint = {2606.00049},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2606.00049v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2606.00049.svg)](https://codeofpaper.com/paper/2606.00049)

Discussion