Skip to main content
QUICK REVIEW

[论文解读] A Systematic Evaluation of Large Language Models of Code

Frank F. Xu, Uri Alon|arXiv (Cornell University)|Feb 26, 2022
Software Engineering Research被引用 16
一句话总结

本文提出 PolyCoder,一个参数量为 27 亿的开源代码语言模型,仅在涵盖 12 种编程语言的 249GB 多语言代码上进行训练。尽管 Codex 在大多数语言中表现更优,但 PolyCoder 在 C 语言上的困惑度更低,表明针对多语言代码的专用预训练可使模型在特定语言上超越专有模型。

ABSTRACT

Large language models (LMs) of code have recently shown tremendous promise in completing code and synthesizing code from natural language descriptions. However, the current state-of-the-art code LMs (e.g., Codex (Chen et al., 2021)) are not publicly available, leaving many questions about their model and data design decisions. We aim to fill in some of these blanks through a systematic evaluation of the largest existing models: Codex, GPT-J, GPT-Neo, GPT-NeoX-20B, and CodeParrot, across various programming languages. Although Codex itself is not open-source, we find that existing open-source models do achieve close results in some programming languages, although targeted mainly for natural language modeling. We further identify an important missing piece in the form of a large open-source model trained exclusively on a multi-lingual corpus of code. We release a new model, PolyCoder, with 2.7B parameters based on the GPT-2 architecture, which was trained on 249GB of code across 12 programming languages on a single machine. In the C programming language, PolyCoder outperforms all models including Codex. Our trained models are open-source and publicly available at https://github.com/VHellendoorn/Code-LMs, which enables future research and application in this area.

研究动机与目标

  • 系统评估现有代码语言模型(包括 Codex 等专有模型,以及 GPT-J、GPT-Neo、GPT-NeoX 和 CodeParrot 等开源模型)在多种编程语言中的表现。
  • 识别当前开源模型的局限性,特别是缺乏大规模、多语言、仅代码训练的模型。
  • 通过训练并发布 PolyCoder 来填补这一空白,该模型参数量为 27 亿,仅在涵盖 12 种语言的 249GB 多语言代码语料上进行训练。
  • 在内在(困惑度)和外在(HumanEval)基准上比较模型性能,分析模型规模、训练数据构成和推理温度的影响。
  • 为 Codex 等专有模型提供一种透明、公开可用的替代方案,以促进代码语言模型研究的广泛可访问性和可复现性。

提出的方法

  • 使用 GPT-2 架构,在单台机器上对 PolyCoder 进行训练,训练数据为从 GitHub 仓库中选取的 249GB 编程代码,涵盖 12 种编程语言。
  • 构建了一个新的 12 种编程语言的评估数据集,用于测量困惑度,确保测试集未在训练中出现,以避免数据泄露。
  • 在 HumanEval 上评估模型的自然语言到代码生成能力,通过不同推理温度测量 Pass@1、Pass@10 和 Pass@100。
  • 在每种语言的相同保留测试集上比较各模型的困惑度,重点关注语言建模质量的内在性能。
  • 分析模型规模(1.6 亿至 200 亿参数)、训练数据构成(自然语言+代码 vs. 仅代码)以及推理温度对生成质量的影响。
  • 在推理过程中使用温度采样,评估多样性与准确性的权衡,并对不同模型规模进行消融研究。

实验结果

研究问题

  • RQ1在多种编程语言中,开源代码语言模型的性能与专有模型 Codex 相比如何?
  • RQ2一个大规模、开源、仅基于多语言代码的模型是否能在特定语言中超越现有开源模型,甚至超越专有模型?
  • RQ3训练数据构成(特别是模型是混合自然语言与代码训练,还是仅在代码上训练)对下游性能有何影响?
  • RQ4模型规模和训练时长如何影响代码生成和语言建模任务的性能?
  • RQ5推理温度如何影响代码生成质量,不同评估指标的最优设置是什么?

主要发现

  • 在 C 语言上,PolyCoder 的困惑度优于 Codex,其困惑度得分低于所有其他测试模型,包括 Codex。
  • 在 HumanEval 基准中,较高的推理温度可提升 Pass@100 分数,而较低温度则带来更好的 Pass@1 结果,表明多样性与置信度之间存在权衡。
  • 对于 Go、Java、Rust、Scala 和 TypeScript 等语言,将模型规模从 27 亿(GPT-Neo)提升至 200 亿(GPT-NeoX)带来的性能增益微乎其微,表明模型容量已趋于饱和。
  • 在 C、JavaScript、Rust、Scala 和 TypeScript 上,PolyCoder 的表现优于同规模的 GPT-Neo 2.7B,表明仅代码预训练在某些语言上可能比混合预训练更有效。
  • 内在评估中的困惑度趋势与 Python 语言的 HumanEval 表现高度相关,表明困惑度是下游代码生成质量的可靠、低成本代理指标。
  • Codex 在多种语言中的优异表现可能被高估,因其确切训练集未知,可能存在数据泄露风险,例如训练数据中包含测试数据。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。