偏见揭示:调查LLM生成代码中的社会偏见
Bias Unveiled: Investigating Social Bias in LLM-Generated Code
AI总结:
针对LLM生成代码中社会偏见的评估空白,提出公平性框架Solar自动生成测试用例量化并缓解偏见,实验表明与Solar对话可使偏见减少高达90%。
摘要:
大型语言模型(LLMs)显著推进了自动代码生成领域。然而,在评估LLM生成的代码中可能存在的社会偏见方面,存在显著的研究空白。为了解决这个问题,我们提出了一个新颖的公平性框架,即Solar,用于评估和缓解LLM生成代码的社会偏见。具体来说,Solar能够自动生成测试用例,以定量揭示LLM自动生成代码的社会偏见。为了量化生成代码中社会偏见的严重程度,我们开发了一个涵盖多种社会问题的数据集。我们将Solar和精心制作的数据集应用于四个最先进的LLM进行代码生成。我们的评估显示,所有被测LLM生成的代码中都存在严重的偏见。此外,我们探索了几种缓解偏见的提示策略,包括思维链(CoT)提示、将积极角色扮演与CoT提示结合,以及与Solar对话。我们的实验表明,与Solar对话可以有效减少LLM生成代码中的社会偏见,减少幅度高达90%。最后,我们公开了代码和数据,该框架具有高度可扩展性,可用于评估新的社会问题。
英文摘要:
Large language models (LLMs) have significantly advanced the field of automated code generation. However, a notable research gap exists in evaluating social biases that may be present in the code produced by LLMs. To solve this issue, we propose a novel fairness framework, i.e., Solar, to assess and mitigate the social biases of LLM-generated code. Specifically, Solar can automatically generate test cases for quantitatively uncovering social biases of the auto-generated code by LLMs. To quantify the severity of social biases in generated code, we develop a dataset that covers a diverse set of social problems. We applied Solar and the crafted dataset to four state-of-the-art LLMs for code generation. Our evaluation reveals severe bias in the LLM-generated code from all the subject LLMs. Furthermore, we explore several prompting strategies for mitigating bias, including Chain-of-Thought (CoT) prompting, combining positive role-playing with CoT prompting and dialogue with Solar. Our experiments show that dialogue with Solar can effectively reduce social bias in LLM-generated code by up to 90%. Last, we make the code and data publicly available is highly extensible to evaluate new social problems.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。