Bias Testing and Mitigation in LLM-based Code Generation
The University of Hong Kong(香港大学);King’s College London(伦敦国王学院);Shanghai Jiao Tong University(上海交通大学);Singapore Management University(新加坡管理大学);Tianjin University(天津大学)
Dong Huang, Jie M. Zhang, Qingwen Bu, Xiaofei Xie, Junjie Chen, Heming Cui
As the adoption of LLMs becomes more widespread in software coding ecosystems, a pressing issue has emerged: does the generated code contain social bias and unfairness, such as those related to age, gender, and race? This issue concerns the integrity, fairness, and ethical foundation of software applications that depend on the code generated by these models but are underexplored in the literature. This paper presents a novel bias testing framework that is specifically designed for code generation tasks. Based on this framework, we conduct an extensive empirical study on the biases in code generated by five widely studied LLMs (i.e., PALM-2-CodeChat-bison, Claude-instant-1, GPT-3.5-turbo, GPT-4-turbo, and GPT-4). Our findings reveal that biases are prevalent. For example, 13.47% to 49.10% of the codes generated by these LLMs have biased behaviors towards gender. Moreover, we study five bias mitigation prompt strategies that are commonly used in current code generation scenarios, i.e., zero-shot, one-shot, few-shot, and two Chain-of-Thought (CoT) prompts, with and without provided feedback-driven refinement. Our evaluation results illustrate that using direct prompt engineering strategies has limited effectiveness in mitigating bias, but our test execution feedback can help to reduce the ratio of code biases to a large extent (e.g., from 59.88% to 4.79% for GPT-4).
Simulating a Bias Mitigation Scenario in Large Language Models
Department of Computer Science, Bowling Green State University(计算机科学系,布恩维尔州立大学);School of Computing, University of Nebraska–Lincoln(计算学院,内布拉斯加-林肯大学);Department of Civil, Environmental, and Ocean Engineering, Stevens Institute of Technology(土木、环境与海洋工程系,史蒂文斯理工学院);Department of Computer Science, University of South Carolina(计算机科学系,南卡罗来纳大学);Artificial Intelligence Institute, University of South Carolina(人工智能研究院,南卡罗来纳大学)
Multi-Persona Thinking for Bias Mitigation in Large Language Models
Dept. Computing Science, Alberta Machine Intelligence Institute (Amii) University of Alberta, Canada(计算科学系,阿尔伯塔机器智能研究所(Amii),阿尔伯塔大学,加拿大);Canada CIFAR AI Chair, Amii(加拿大 CIFAR 人工智能主席,Amii)
Wisdom from Diversity: Bias Mitigation Through Hybrid Human-LLM Crowds
Machine Learning Group, Université Libre de Bruxelles(布鲁塞尔自由大学机器学习组);AI Lab, Vrije Universiteit Brussel(布鲁塞尔自由大学人工智能实验室);FARI, AI for the Common-Good Institute, ULB-VUB(ULB-VUB共同利益人工智能研究所);Center for Human-Compatible AI, UC Berkeley(伯克利人类兼容人工智能中心)
BiMa: Towards Biases Mitigation for Text-Video Retrieval via Scene Element Guidance
FPT Software AI Center(FPT软件AI中心);Aalborg University(奥尔堡大学);Pioneer Centre for AI(先锋人工智能中心);University of Liverpool(利物浦大学);AICV Lab, University of Arkansas(AICV实验室,阿肯色大学)