一句话:首个系统实证研究推理式代码生成中的社会偏见,并提出推理感知的去偏框架 ProbeDebias。
大语言模型被广泛用于代码生成,已有研究表明生成程序可能携带“代码偏见”,即在涉及敏感人口属性的代码逻辑中体现不公平或差别对待。已有工作只考察直接生成场景,而基于推理的代码生成(模型先产生中间推理轨迹再输出最终代码)中偏见如何表现尚不清楚。本文开展首个针对推理式代码生成中社会偏见的系统性实证研究:在覆盖三类以人为中心决策场景的真实偏见敏感编程任务上,评测了 9 个模型,涵盖标准 LLM 与大型推理模型(LRM)。结果给出四点发现:推理总体上降低了代码偏见率(平均从 0.64 降至 0.40),但改善程度高度依赖模型;推理并未稳定保持代码质量(平均从 0.72 降至 0.59);有偏的推理轨迹强烈预示有偏代码;仅调整生成配置不足以稳健地缓解偏见。基于此,作者提出 ProbeDebias——一种推理感知的去偏框架,先检测有偏的推理轨迹并在最终代码生成前对其重写,大量实验显示其取得 87.76 的效果(摘要在该数值处截断,未给出完整指标名称)。
Large language models (LLMs) are increasingly used for code generation, but recent studies have shown that generated programs can exhibit code bias, i.e., unfair or differential treatment encoded in code logic with respect to sensitive demographic attributes. Although prior work has investigated this problem in a direct generation setting, it remains unclear how bias behaves in reasoning-based code generation, where models produce intermediate reasoning traces before generating the final code. To bridge this gap, we conduct the first systematic empirical study of social bias in reasoning-based code generation. We evaluate 9 models spanning both standard LLMs and large reasoning models (LRMs) on realistic bias-sensitive coding tasks covering three human-centered decision scenarios. Our results reveal four main findings. First, reasoning generally reduces code bias, lowering the average bias rate from 0.64 to 0.40, but the improvement is highly model-dependent. Second, reasoning-based generation does not consistently preserve code quality, with the average quality dropping from 0.72 to 0.59. We further find that biased reasoning strongly predicts biased code, and that simply adjusting generation configurations is insufficient for robust bias mitigation. Motivated by these findings, we propose ProbeDebias, a reasoning-aware debiasing framework that detects biased reasoning traces and rewrites them before final code generation. Extensive experiments demonstrate that ProbeDebias achieves 87.76
@inproceedings{paperbot12192,
title = {How Reasoning Shapes Social Bias in LLM-Generated Code?},
author = {Weifeng Sun and Jieke Shi and Zhou Yang and Yuchen Chen and Hongyan Li and Meng Yan and David Lo},
booktitle = {ASE},
year = {2026},
doi = {10.1145/3832783.3834387}
}