Saved in:
Bibliographic Details
Main Authors: Chen, Yuxi, Tang, Yutian, Storer, Timothy
Format: Preprint
Published: 2026
Subjects:
Online Access:https://arxiv.org/abs/2606.00049
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916067836690432
author Chen, Yuxi
Tang, Yutian
Storer, Timothy
author_facet Chen, Yuxi
Tang, Yutian
Storer, Timothy
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2606_00049
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Measuring and Mitigating Bias in Code Generated by Large Language Models
Chen, Yuxi
Tang, Yutian
Storer, Timothy
Computers and Society
Artificial Intelligence
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.
title Measuring and Mitigating Bias in Code Generated by Large Language Models
topic Computers and Society
Artificial Intelligence
url https://arxiv.org/abs/2606.00049