arXiv:2604.21716cs.CLcs.SE2026-04ACL

用真实机器学习流程测试代码生成偏见,发现比传统方法高近30%。

From If-Statements to ML Pipelines: Revisiting Bias in Code-Generation

论文配图:From If-Statements to ML Pipelines: Revisiting Bias in Code-Generation
图 1 · 摘自论文原文
  • 用生成机器学习管道代替简单条件语句评估偏见
  • 敏感属性出现率达87.7%,远超条件句测试的59.2%
  • 该结果在多种提示和难度下均成立,适合关注实际部署风险的研究者

以往研究主要通过简单条件语句评估代码生成偏见,仅反映显式编码的偏见,且局限于极小范围的真实编程场景。本文通过更贴近实际的任务——生成机器学习(ML)管道,揭示了这一评估方式严重低估了真实偏见。测试代码专用与通用指令大模型后发现,生成的管道在特征选择中存在显著偏见:平均87.7%的案例包含敏感属性,尽管模型能正确排除无关特征(如信用评分中保留'种族'却剔除'最爱颜色')。该偏见程度远高于条件句测试中的59.2%。结果在不同提示缓解策略、属性数量及管道难度下均保持稳健。研究挑战了以简单条件句作为偏见评估代理的有效性,表明现有基准严重低估了实际应用中的偏见风险。

原文摘要 · Abstract (English)

Prior work evaluates code generation bias primarily through simple conditional statements, which represent only a narrow slice of real-world programming and reveal solely overt, explicitly encoded bias. We demonstrate that this approach dramatically underestimates bias in practice by examining a more realistic task: generating machine learning (ML) pipelines. Testing both code-specialized and general-instruction large language models, we find that generated pipelines exhibit significant bias during feature selection. Sensitive attributes appear in 87.7% of cases on average, despite models demonstrably excluding irrelevant features (e.g., including "race" while dropping "favorite color" for credit scoring). This bias is substantially more prevalent than that captured by conditional statements, where sensitive attributes appear in only 59.2% of cases. These findings are robust across prompt mitigation strategies, varying numbers of attributes, and different pipeline difficulty levels. Our results challenge simple conditionals as valid proxies for bias evaluation and suggest current benchmarks underestimate bias risk in practical deployments.

代码生成偏见检测ML管道

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。