论文标题
Clawsat:朝着稳健和准确的代码模型迈进
CLAWSAT: Towards Both Robust and Accurate Code Models
论文作者
论文摘要
我们将对比度学习(CL)与对抗性学习相结合,以优化代码模型的鲁棒性和准确性。与现有作品不同,我们表明,代码混淆(一种标准代码转换操作)提供了新的手段来生成代码的互补``视图'',以使我们能够实现强大而准确的代码模型。据我们所知,这是第一项系统的研究,旨在探索和利用代码模型中(多视图)代码混淆的鲁棒性和准确性优势。具体而言,我们首先在自我监管的预训练阶段中,在CL中采用对抗性代码作为稳健性的观点。这可以提高下游任务的鲁棒性和可传递性。接下来,在监督的微调阶段,我们表明,具有适当暂时的对抗代码生成时间表的对抗训练可以进一步提高预训练的代码模型的鲁棒性和准确性。我们开发了基于上述两个模块,我们开发了Clawsat,这是一个新颖的自我观察学习(SSL)代码框架,通过将$ \ USWINELLINE集成{\ textrm {cl}} $与$ \ undesline {\ textrm {a} a}} $ dversarial vie vie $ \ $ \ textrlline { $ \ usewistline {\ textrm {s}} $ taggered $ \ undesline {\ textrm {a}} $ dversarial $ \ usepline {\ textrm {t}} $ raining(sat)。在评估Python和Java中的三个下游任务时,我们表明Clawsat始终产生最佳的鲁棒性和准确性($ \ textit {e.g。} $ 11 $ \%$ \%$ \%$ \%$ \%$ \%$ \%$ \%$的准确性在Python中的代码汇总任务中的准确性)。我们还通过分析预训练模型的损失格局和可解释性的特征来证明对抗性学习在爪中的有效性。
We integrate contrastive learning (CL) with adversarial learning to co-optimize the robustness and accuracy of code models. Different from existing works, we show that code obfuscation, a standard code transformation operation, provides novel means to generate complementary `views' of a code that enable us to achieve both robust and accurate code models. To the best of our knowledge, this is the first systematic study to explore and exploit the robustness and accuracy benefits of (multi-view) code obfuscations in code models. Specifically, we first adopt adversarial codes as robustness-promoting views in CL at the self-supervised pre-training phase. This yields improved robustness and transferability for downstream tasks. Next, at the supervised fine-tuning stage, we show that adversarial training with a proper temporally-staggered schedule of adversarial code generation can further improve robustness and accuracy of the pre-trained code model. Built on the above two modules, we develop CLAWSAT, a novel self-supervised learning (SSL) framework for code by integrating $\underline{\textrm{CL}}$ with $\underline{\textrm{a}}$dversarial vie$\underline{\textrm{w}}$s (CLAW) with $\underline{\textrm{s}}$taggered $\underline{\textrm{a}}$dversarial $\underline{\textrm{t}}$raining (SAT). On evaluating three downstream tasks across Python and Java, we show that CLAWSAT consistently yields the best robustness and accuracy ($\textit{e.g.}$ 11$\%$ in robustness and 6$\%$ in accuracy on the code summarization task in Python). We additionally demonstrate the effectiveness of adversarial learning in CLAW by analyzing the characteristics of the loss landscape and interpretability of the pre-trained models.