arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.00602cs.SEcs.PL
收藏

从有效性到效率:揭示基于大型语言模型的代码生成中的语言偏见

From Effectiveness to Efficiency: Uncovering Linguistic Bias in Large Language Model-based Code Generation

Weipeng Jiang, Xuanqi Gao, Juan Zhai, Shiqing Ma, Xiaoyu Zhang, Ziyan Lei, Chao Shen

AI总结:

本文通过英语和中文视角调查LLM代码生成中的语言偏见,提出了包含52个Python问题的统一评估框架,并在八种流行LCGMs及GPT-3.5-Turbo和GPT-4上进行了首次实证研究,发现LLM在代码生成中普遍存在语言偏见。

摘要:

大型语言模型(LLMs)在代码生成方面展现出了令人瞩目的能力。尽管现有的基准测试评估了LLM生成代码的正确性和效率,但潜在的语言偏见——即代码质量会因用于描述编程任务的自然语言不同而有所差异——仍未得到充分探索。在本文中,我们旨在通过英语和中文的视角来调查这种语言偏见。为了便于调查,我们提出了一个统一的评估框架,该框架包含一个包含52个Python编程问题的精选数据集(带有平行的双语任务描述)、自动正确性验证,以及基于运行时复杂度估计的效率量化工具。基于该框架,我们在八种流行的LCGMs以及GPT-3.5-Turbo和GPT-4上,对LLM生成代码中的语言偏见进行了首次实证研究。我们观察到,这些LCGM生成的代码在平均12%的双语编程任务上表现出不同的正确性,其中39%还表现出不同的效率。我们的研究结果表明,LLMs在代码生成中普遍存在语言偏见。

英文摘要:

Large Language Models (LLMs) have demonstrated promising capabilities for code generation. While existing benchmarks evaluate the correctness and efficiency of LLM-generated code, the potential linguistic bias - where code quality varies based on the natural language used to describe programming tasks - remains underexplored. In this paper, we aim to investigate this linguistic bias through the lens of English and Chinese. To facilitate our investigation, we present a unified evaluation framework comprising a curated dataset of 52 Python programming questions with parallel bilingual task descriptions, automated correctness verification, and efficiency quantification tools based on runtime complexity estimation. Based on this framework, we conduct the first empirical study towards the linguistic bias in LLM-generated code on eight popular LCGMs, as well as GPT-3.5-Turbo and GPT-4. We observe that these LCGM-generated code show different correctness on an average of 12% bilingual programming tasks, where 39% also exhibits diverse efficiency. Our findings indicate that LLMs commonly exhibit linguistic bias for code generation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑