potentialpaper

CodeBiasBench: Benchmarking social fairness of large language model generated code

Zenghao Si, Dong HUANG, Yuehai Wang, Junhao Dong, Piotr Koniusz

ICLR 2026 submission

Edit this page

Or clone it with git

The page gets its repository with its first edit, so start in the web editor.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

Abstract. Large language models (LLMs) are increasingly applied to tasks such as code completion, generation, debugging, and optimization. However, they may inherit social biases from their training data, potentially leading to unfair or discriminatory behavior in sensitive domains. Despite the growing use of LLMs in software development, there is still a lack of systematic fairness evaluation for code completion scenarios. Existing research primarily induces biases using pure natural language prompts or synthetic code snippets, which fail to capture the complexity of real-world code completion and are prone to triggering LLMs’ ethical safeguard mechanisms. Furthermore, current bias detection methods heavily rely on LLMs’ self-judgment, whose reliability remains uncertain. To address these challenges, we introduce CodeBiasBench, a benchmark specifically designed to evaluate fairness in code completion. CodeBiasBench provides over 5000 template-based tasks and includes two complementary subsets: the Sensitive subset, which retains minimal conditions related to sensitive attributes, and the Neutralized subset, which removes them entirely to avoid triggering safeguard mechanisms. This design enables us to observe both explicit and implicit disparities while maintaining task relevance. Additionally, we propose Contrastive Chain of Thought (CCoT), a novel detection method that performs contrastive reasoning between generated outputs under different sensitive-attribute conditions. CCoT focuses on identifying unwarranted disparities rather than mere sensitivity, thereby improving the robustness and accuracy of fairness evaluation. We conduct comprehensive experiments with CodeBiasBench and CCoT, revealing hidden correlations between task-relevant and sensitive features, and providing actionable insights for mitigating unfairness in LLM-based code generation.

Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.

Claim this paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

add · history

No versions are recorded yet: its preprint, the venues it went to and what they decided, the camera-ready. Missing a version?

We don't know of a submission of this paper to a venue with open reviews. Missing a submission?

Loading the discussion…