Skip to main content
QUICK REVIEW

[论文解读] PanGu-Coder: Program Synthesis with Function-Level Language Modeling

Fenia Christopoulou, Γεράσιμος Λάμπουρας|arXiv (Cornell University)|Jul 22, 2022
Software Engineering Research被引用 23
一句话总结

PanGu-Coder 是一个仅解码器的预训练模型,用于文本到代码生成,采用两阶段训练策略,在对功能正确的代码生成方面在更小的上下文和数据需求下实现具竞争力的表现。它还展示了在域内微调和后处理过滤器方面的提升。

ABSTRACT

We present PanGu-Coder, a pretrained decoder-only language model adopting the PanGu-Alpha architecture for text-to-code generation, i.e. the synthesis of programming language solutions given a natural language problem description. We train PanGu-Coder using a two-stage strategy: the first stage employs Causal Language Modelling (CLM) to pre-train on raw programming language data, while the second stage uses a combination of Causal Language Modelling and Masked Language Modelling (MLM) training objectives that focus on the downstream task of text-to-code generation and train on loosely curated pairs of natural language program definitions and code functions. Finally, we discuss PanGu-Coder-FT, which is fine-tuned on a combination of competitive programming problems and code with continuous integration tests. We evaluate PanGu-Coder with a focus on whether it generates functionally correct programs and demonstrate that it achieves equivalent or better performance than similarly sized models, such as CodeX, while attending a smaller context window and training on less data.

研究动机与目标

  • 以基于 PanGu-α 的仅解码器模型来激发文本到代码生成的研究。
  • 提出两阶段训练策略,以利用原始代码数据和 NL-to-code 对。
  • 探索在领域相关数据上的微调及其对功能性表现的影响。
  • 研究解码策略、训练目标和数据相似性,以改进代码合成。
  • 提出后处理技术,以提升功能基准测试的通过率。

提出的方法

  • 使用带有额外查询层的 PanGu-α 风格的仅解码器 Transformer,用于下一个令牌的预测。
  • 阶段1 在原始代码上通过因果语言建模进行预训练(通过文档字符串/注释中的 NL 信号)。
  • 阶段2 使用 Code-CLM、Docstr-MLM 和 Docstr-MCLM 目标的组合,在对齐的 NL-代码对上进行训练。
  • 在如竞赛编程问题和 CI 测试函数等领域相关数据上对 PanGu-Coder 进行微调(PanGu-Coder -FT)。
  • 在 HumanEval 和 MBPP 基准上评估零样本性能,聚焦于功能正确性。
  • 通过少样本相似性进行数据选择以及后处理过滤器(单元测试、类型检查、语法)来提升通过率的研究。

实验结果

研究问题

  • RQ1仅解码器模型是否能够在功能级别强调下有效地执行文本到代码生成?
  • RQ2两阶段训练目标(CLM 与 MLM 变体)如何影响功能性代码生成质量?
  • RQ3域内微调数据对功能正确性分数有何影响?
  • RQ4基于相似性的数据选择是否可以在保持或提高性能的同时减少训练计算?
  • RQ5后生成过滤器(单元测试、类型检查、语法检查)是否显著提升基准的通过率?

主要发现

  • PanGu-Coder 在功能正确的代码生成方面,其表现与同等规模的模型(如 CodeX)相当甚至更好,且使用更小的上下文窗口和更少的数据。
  • 在域内数据上进行微调(PanGu-Coder -FT)在通过率方面提升更快,特别是在 MBPP 上,相较于域外数据。
  • 提示中的单元测试和后处理过滤器显著提高 MBPP 的通过率,对 HumanEval 的影响则各异。
  • 基于类型的过滤和语法检查可以在减少候选解的同时进一步提升或维持通过率。
  • 基于少样本相似性的数据选择,使用仅 25-50% 的数据即可达到或超过全数据微调的性能,降低计算需求。
  • PanGu-Coder -FT 从域对齐数据中受益,对微调数据中的分布变化表现出敏感性。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

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