IRCoder:中间表示使语言模型成为鲁棒的多语言代码生成器
IRCoder: Intermediate Representations Make Language Models Robust Multilingual Code Generators
AI总结:
针对现有代码语言模型多语言能力研究不足、仅依赖源代码预训练的问题,本研究构建含近400万样本的SLTrans并行数据集,利用编译器中间表示对不同规模基础模型进行持续训练,得到的IRCoder在多类代码任务上实现显著一致的性能提升。
摘要:
代码理解与生成已迅速成为语言模型(LM)最受欢迎的应用方向之一。然而,与自然语言领域的同类研究相比,针对代码语言模型(Code-LM,即用于代码生成的语言模型)多语言特性的研究——例如不同编程语言之间的跨语言迁移、特定语言的数据增强、事后模型适配,以及对原始文本内容之外数据源的利用——要稀少得多。尤其是,大多数主流Code-LM仅在源代码文件上进行预训练。在本研究中,我们探讨了利用现成的、跨编程语言共享的编译器中间表示(IR)来提升Code-LM多语言能力、促进跨语言迁移的可行性。\n为此,我们首先构建了SLTrans数据集,这是一个包含近400万个自包含源代码文件及其对应中间表示的并行数据集。接下来,我们以多种不同规模(参数量从11亿到73亿不等)的基础Code-LM为起点,在SLTrans上进行持续的因果语言建模训练,促使Code-LM:(1)学习IR语言,(2)将IR结构与多种编程语言的对应结构进行对齐。我们得到的模型名为IRCoder,在包括提示鲁棒性、多语言代码补全、代码理解和指令遵循在内的各类代码生成任务与指标上,均取得了显著且一致的性能提升。
英文摘要:
Code understanding and generation have fast become some of the most popular applications of language models (LMs). Nonetheless, research on multilingual aspects of Code-LMs (i.e., LMs for code generation) such as cross-lingual transfer between different programming languages, language-specific data augmentation, and post-hoc LM adaptation, alongside exploitation of data sources other than the original textual content, has been much sparser than for their natural language counterparts. In particular, most mainstream Code-LMs have been pre-trained on source code files alone. In this work, we investigate the prospect of leveraging readily available compiler intermediate representations (IR) - shared across programming languages - to improve the multilingual capabilities of Code-LMs and facilitate cross-lingual transfer. To this end, we first compile SLTrans, a parallel dataset consisting of nearly 4M self-contained source code files coupled with respective intermediate representations. Next, starting from various base Code-LMs (ranging in size from 1.1B to 7.3B parameters), we carry out continued causal language modelling training on SLTrans, forcing the Code-LMs to (1) learn the IR language and (2) align the IR constructs with respective constructs of various programming languages. Our resulting models, dubbed IRCoder, display sizeable and consistent gains across a wide variety of code generation tasks and metrics, including prompt robustness, multilingual code completion, code understanding, and instruction following.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。