paperbot · PL 论文追踪

全部论文 待读 收藏

P2 NatGen: generative pre-training by “naturalizing” source code

NatGen:通过“自然化”源代码进行生成式预训练
FSE Proceedings of the 30th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2022匹配度 2/10 · 该论文研究代码预训练目标与代码生成/翻译/精化,属于机器学习与程序语言交叉,但与用户核心方向(面向 Agentic/ML 系统的静态分析、LLM 辅助静态分析/形式化验证、浮点或贝叶斯程序分析)没有直接关联。它更偏向提升代码生成模型的预训练方法,而非程序分析或 Agent 场景。引用 103 inbox
Saikat Chakraborty, Toufique Ahmed, Yangruibo Ding, Premkumar T. Devanbu, Baishakhi Ray
crossref: 2026-09-12

AI 速览

一句话:提出“自然化”源代码的预训练目标,用六类语义保持变换生成非自然代码,让模型学会还原开发者书写的自然程序,在多个生成式任务上媲美 CodeT5。

该文关注代码预训练模型中预训练目标的设计问题:现有模型(如 PLBART、CodeT5、SPT-Code)虽在代码生成与翻译等任务上表现优异,但其预训练目标仍有改进空间。作者利用代码兼具形式通道与自然通道的“双模态”特性,提出名为“自然化”的新预训练目标:先定义六类语义保持变换,将原始代码改写为各种“非自然”形式,再强制模型从这些非自然版本还原出开发者书写的更自然的等价程序。该过程在大规模开源代码语料上自监督进行,无需人工标注,使模型同时学习代码的理解与生成。作者用有限的人工标注数据将模型微调到代码生成、代码翻译和代码精化三个生成式软件工程任务上,性能达到与 CodeT5 相当的最先进水平,并在零样本与少样本设置下尤其有竞争力,同时在语法、数据流等代码属性的学习上表现更好。

问题
代码生成式预训练模型的效果高度依赖预训练目标,如何设计能充分利用代码特性的自监督目标仍是一个开放问题。
方法
利用代码形式与自然双通道的特性,定义六类语义保持变换把代码改写为“非自然”形式,再训练模型在大规模语料上还原更自然的原程序。
评估
在代码生成、代码翻译、代码精化三个任务上用有限人工标注数据微调,与 CodeT5 等强基线比较,并考察零样本/少样本表现及语法、数据流等代码属性的学习效果。
原文摘要(Abstract)

Pre-trained Generative Language models (e.g., PLBART, CodeT5, SPT-Code) for source code yielded strong results on several tasks in the past few years, including code generation and translation. These models have adopted varying pre-training objectives to learn statistics of code construction from very large-scale corpora in a self-supervised fashion; the success of pre-trained models largely hinges on these pre-training objectives. This paper proposes a new pre-training objective, “Naturalizing” of source code, exploiting code’s bimodal, dual-channel (formal & natural channels) nature. Unlike natural language, code’s bimodal, dual-channel nature allows us to generate semantically equivalent code at scale. We introduce six classes of semantic preserving transformations to introduce unnatural forms of code, and then force our model to produce more natural original programs written by developers. Learning to generate equivalent, but more natural code, at scale, over large corpora of open-source code, without explicit manual supervision, helps the model learn to both ingest & generate code. We fine-tune our model in three generative Software Engineering tasks: code generation, code translation, and code refinement with limited human-curated labeled data and achieve state-of-the-art performance rivaling CodeT5. We show that our pre-trained model is especially competitive at zero-shot and few-shot learning, and better at learning code properties (e.g., syntax, data flow)

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot7116,
  title = {NatGen: generative pre-training by “naturalizing” source code},
  author = {Saikat Chakraborty and Toufique Ahmed and Yangruibo Ding and Premkumar T. Devanbu and Baishakhi Ray},
  booktitle = {FSE},
  year = {2022},
  doi = {10.1145/3540250.3549162}
}