大規模コード表現学習
Code Representation Learning At Scale
February 2, 2024
著者: Dejiao Zhang, Wasi Ahmad, Ming Tan, Hantian Ding, Ramesh Nallapati, Dan Roth, Xiaofei Ma, Bing Xiang
cs.AI
要旨
最近の研究では、大規模なコード言語モデルが下流タスク(例えばコード生成)において著しい性能向上を示すことが明らかになっています。しかし、既存のコード表現学習に関する研究の多くは、非常に限られた事前学習コーパスを用いて、数億パラメータ規模のモデルを訓練しています。本研究では、2段階の事前学習スキームを通じて、膨大な量のコードデータを用いてコード表現学習を強化します。まず、マスキング言語モデリングのランダム性とプログラミング言語の構造的側面の両方を活用した混合手法でエンコーダを訓練します。次に、教師なしで構築されたハードネガティブとハードポジティブを用いた対照学習によって表現を強化します。これにより、幅広い下流タスクにおいて既存モデルを大きく上回るオフ・ザ・シェルフのエンコーダモデルを確立しました。成功するコード表現学習に寄与する要因を理解するため、詳細なアブレーション研究を行い、(i) ソースコード向けのカスタマイズされた効果的なトークンレベルのノイズ除去スキーム、(ii) ハードネガティブとハードポジティブの重要性、(iii) 提案された双峰型対照学習がどのようにクロスリンガル意味検索の性能を向上させるか、(iv) 事前学習スキームがモデルサイズに応じた下流タスクの性能スケールをどのように決定するか、についての知見を共有します。
English
Recent studies have shown that code language models at scale demonstrate
significant performance gains on downstream tasks, i.e., code generation.
However, most of the existing works on code representation learning train
models at a hundred million parameter scale using very limited pretraining
corpora. In this work, we fuel code representation learning with a vast amount
of code data via a two-stage pretraining scheme. We first train the encoders
via a mix that leverages both randomness in masking language modeling and the
structure aspect of programming language. We then enhance the representations
via contrastive learning with hard negative and hard positive constructed in an
unsupervised manner. We establish an off-the-shelf encoder model that
persistently outperforms the existing models on a wide variety of downstream
tasks by large margins. To comprehend the factors contributing to successful
code representation learning, we conduct detailed ablations and share our
findings on (i) a customized and effective token-level denoising scheme for
source code; (ii) the importance of hard negatives and hard positives; (iii)
how the proposed bimodal contrastive learning boost the cross-lingual semantic
search performance; and (iv) how the pretraining schemes decide the downstream
task performance scales with the model size.