文章目录
-
- Pre-trained contextual embedding of source code
- CodeBERT: A Pre-trained model for programming and natural languages
- GraphCodeBert: Pre-training code representations with data flow
- Contrastive code representation learning
- InferCode: Self-Supervised Learning of Code Representations by Predicting Subtrees
- DOBF: A Deobfuscation Pre-Training Objective for Programming Languages
- IntelliCode Compose: Code Generation using Transformer
Pre-trained contextual embedding of source code
ICLR 2020 reject,后改为Learning and Evaluating Contextual Embedding of Source Code,发表在ICML 2020
Google Brain
CuBERT:开源代码和数据链接
和Bert无区别,只是替换了语料和微调的任务。
本文做的是代码预训练,提出了CuBERT(Code Understanding BERT)。在6.6M python files的语料上做训练。数据是public Github repository hosted on Google’s BigQuery platform。
预训练任务
-
Masked language modeling (MLM)
预测mask的token是什么 -
Next Sentence Prediction(NSP)
预测两个代码逻辑行是否为上下句的关系
微调任务
5个分类任务和一个其他任务
- Variable Misuse Classification
- Wrong Binary Operator
- Swapped Operand
- Function-Docstring Mismatch
- Exception type
- Variable Misuse localization and repair
微调的数据集为:
CodeBERT: A Pre-trained model for programming and natural languages
EMNLP findings, 2020
Zhangyin Feng, Daya Guo, Duyu Tang …
哈工大,中山大学,微软亚洲研究院
开源代码和数据
可用:预训练模型;在每种语言上进行微调比在6种语言上一起微调效果更优;
本文做的是代码预训练,提出了CodeBERT(a first large bimodal pre-trained model for natural language and programming language)。
模型架构
Follow Bert,RoBERTa,使用多层双向Transformer作为CodeBERT的模型架构,和RoBERTa-Base中的架构一样,其中的模型参数有125 Million(1.25亿参数)
input: [ C L S ] , w 1 , w 2 , ⋯ , w n , [ S E P ] , c 1 , c 2 , ⋯ , c m , [ E O S ] [CLS], w_1, w_2, \cdots, w_n, [SEP], c_1, c_2, \cdots, c_m, [EOS] [CLS],w1,w2,⋯,wn,[SEP],c1,c2,⋯,cm,[EOS]
其中的 w i w_i wi表示句子的token, c i c_i ci表示代码的token
output: 每一个token基于上下文的表示;[CLS]的表示,代表聚合的序列表示
预训练数据
数据集来自CodeSearchNet,其中的2.4M bimodal data的形式为<individual funciton, documentation>,其中的6.4M unimodal codes表示单独的代码数据。
预训练的任务
-
Masked Language Modeling (MLM)
输入是NL-PL pair,在其中随机选择一些位置mask掉。M