A Framework for Identifying, Categorizing, and Explaining Bias in AI-Generated Code
作者: Manaal Basha, Aimee M. Ribeiro, Gema Rodriguez-Perez
分类: cs.SE, cs.AI
发布日期: 2026-09-25
备注: Under Review at ACM TOSEM
💡 一句话要点
提出框架以识别、分类和解释AI生成代码中的偏见
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: AI生成代码 偏见识别 分类法框架 大型语言模型 代码审查 软件开发 伦理研究
📋 核心要点
- 现有研究对AI生成代码中的偏见缺乏系统性的识别和分类,导致偏见问题未得到充分重视。
- 论文提出了一种基于分类法的框架,通过扩展数据集并手动注释,建立了真实数据集以支持偏见检测。
- 实验结果显示,Gemini模型在偏见分类准确率上达到了80.14%,而开源模型Qwen3-coder的准确率为82.45%,均表现出较高的偏见检测能力。
📝 摘要(中文)
随着大型语言模型(LLMs)逐渐融入软件开发流程,AI生成代码中的无意偏见问题引发了广泛关注。尽管已有证据表明这些偏见的存在,但系统性识别、分类和解释的研究仍然有限。本研究探讨了AI生成代码中的偏见,并评估LLMs是否能够通过基于分类法的框架可靠地识别和解释这些偏见。我们扩展了现有的偏见AI生成Python代码数据集,并手动注释了带有偏见类别和人类撰写的理由的代码片段,以建立一个真实数据集。通过该数据集,我们评估了专有和开源LLMs作为自动偏见检测和解释系统的有效性。研究结果表明,LLMs能够有效支持代码偏见的识别和解释。
🔬 方法详解
问题定义:本研究旨在解决AI生成代码中潜在偏见的识别与解释问题。现有方法在系统性识别和分类偏见方面存在不足,导致偏见未得到有效处理。
核心思路:论文提出了一种基于分类法的框架,通过扩展数据集并进行手动注释,建立真实数据集,以支持对AI生成代码中偏见的检测和解释。
技术框架:整体架构包括数据集扩展、手动注释、模型评估和结果分析四个主要模块。首先扩展现有数据集,然后对代码片段进行偏见类别和人类理由的注释,接着评估不同LLMs的检测能力,最后分析模型生成的解释与人类理由的相似性。
关键创新:本研究的创新点在于系统性地识别和分类AI生成代码中的偏见,并通过建立真实数据集为模型评估提供基础。这一方法与现有研究的本质区别在于其系统性和数据驱动的特征。
关键设计:在实验中,使用了分类准确率、精确率和召回率等指标来评估模型性能,同时采用结构化的理由和代码识别相似性度量来分析模型生成的解释。
🖼️ 关键图片
📊 实验亮点
实验结果显示,Gemini模型在偏见分类准确率上达到了80.14%,精确率为84.0%,召回率为95.7%;而开源模型Qwen3-coder的准确率为82.45%,精确率为68.64%,召回率为80.22%。模型生成的解释与人类理由的相似性得分分别为80.4%和80.14%。
🎯 应用场景
该研究的潜在应用领域包括软件开发、代码审查和AI辅助编程工具。通过识别和解释代码中的偏见,开发者可以更好地理解和改进AI生成代码的质量,从而提高软件的可靠性和公平性。未来,该框架可能推动更广泛的AI伦理研究和实践。
📄 摘要(原文)
As Large Language Models (LLMs) become integrated into software development workflows, concerns regarding unintentional biases in AI-generated code. Although evidence suggests these biases exist, limited research has systematically identified, categorized, and explained them. This study investigates bias in AI-generated code and evaluates whether LLMs can reliably identify and explain it through a taxonomy-driven framework. We extended an existing dataset of biased AI-generated Python code and manually annotated snippets with bias categories and human-authored justifications to establish a ground-truth dataset. Using this dataset, we evaluated proprietary and open-source LLMs as automated bias detection and justification systems through ICL. Finally, we analyzed similarity between LLM-generated explanations and human-authored justifications using structured justification and code identification metrics. Our findings demonstrate that LLMs can effectively support code bias identification and explanation. Gemini achieved 80.14% classification accuracy, with 84.0% precision and 95.7% recall, while the best open-source alternative, Qwen3-coder, achieved 82.45% accuracy, 68.64% precision, and 80.22% recall. Additionally, the models achieved justification similarity scores of 80.4% and 80.14%, respectively, relative to human-authored reasoning, and code identification similarity scores of 86.0% and 87.82%. These results suggest that LLMs can detect biased logic in generated Python code and produce explanations that substantially align with expert interpretations.