arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2404.19368cs.SE
收藏

探究大型代码模型在代码生成中的多语言偏差

Exploring Multi-Lingual Bias of Large Code Models in Code Generation

Chaozheng Wang, Zongjie Li, Cuiyun Gao, Wenxuan Wang, Ting Peng, Hailiang Huang, Yuetang Deng, Shuai Wang, Michael R. Lyu

AI总结:

本文通过构建首个多语言评估基准 X-HumanEval-X,系统探究了大型代码模型在代码生成中的多语言偏差,发现中文指令下 Pass@1 至少下降 13%,且不同编程语言间性能差距可达 20.9%。

摘要:

代码生成旨在根据自然语言(NL)规范合成代码并满足功能需求,这可以极大地提高开发效率。在大语言模型(LLMs)时代,大型代码模型(LCMs)最近被提出用于生成源代码。LCMs 可以为用自然语言描述的编程问题生成高度可行的解决方案。尽管具有有效性,我们观察到 LCMs 的生成性能存在明显的多语言偏差。具体而言,LCMs 在提供英文指令时表现出生成解决方案的熟练能力,但在面对语义等价的其他自然语言(如中文)指令时可能会表现不佳。此外,LCMs 生成代码的能力在不同的编程语言(PLs)(如 Python 和 C++)之间表现出差异。观察到的现象表明 LCMs 的生成能力中存在多语言偏差,而这一问题尚未被探索。 在本文中,我们旨在探究当前 LCMs 中存在的多语言偏差。首先,我们通过构建首个多语言评估基准 X-HumanEval-X 来启动我们的研究,使我们能够系统地评估当前 LCMs 中存在的多语言偏差程度。在我们对九个流行的 LCMs 进行的大规模实验中,我们观察到 LCMs 在代码生成中存在显著的多语言偏差,包括多自然语言和多编程语言偏差。具体而言,当使用中文指令时,LCMs 的代码生成能力在 Pass@1 指标上至少下降 13%。此外,LCMs 在不同编程语言上的表现各不相同,例如,Python 和 C++ 之间的性能差距高达 20.9%。

英文摘要:

Code generation aims to synthesize code and fulfill functional requirements based on natural language (NL) specifications, which can greatly improve development efficiency. In the era of large language models (LLMs), large code models (LCMs) have been recently proposed to generate source code. LCMs can generate highly feasible solutions for programming problems described in natural language. Despite the effectiveness, we observe a noticeable multilingual bias in the generation performance of LCMs. Specifically, LCMs demonstrate proficiency in generating solutions when provided with instructions in English, yet may falter when faced with semantically equivalent instructions in other NLs such as Chinese. Moreover, the ability of LCMs to generate code exhibits variety across different programming languages (PLs), such as Python and C++. The observed phenomenon indicates the presence of multi-lingual bias within the generative capabilities of LCMs, which has remained unexplored. In this paper, we aim to investigate the multi-lingual bias that exists in current LCMs. First, we initiate our investigation by constructing the first multi-lingual evaluation benchmark X-HumanEval-X, enabling us to systematically evaluate the extent of multi-lingual bias that exists in current LCMs. In our large-scale experiments on nine popular LCMs, we observe a pronounced multi-lingual bias of LCMs in code generation, including multi-NL and multi-PL bias. Specifically, when using Chinese instructions, the code generation capabilities of LCMs decrease by at least 13% in terms of the Pass@1 metric. Furthermore, LCMs perform variously across different programming languages, e.g., the performance gap between Python and C++ reaches as high as 20.9%. ...

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

↑