CLAWSAT: Towards Both Robust and Accurate Code Models
Not on the map. Why?
Abstract (arXiv)
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 underlinetextrmCL with underlinetextrmadversarial vieunderlinetextrmws (CLAW) with underlinetextrmstaggered underlinetextrmadversarial underlinetextrmtraining (SAT). On evaluating three downstream tasks across Python and Java, we show that CLAWSAT consistently yields the best robustness and accuracy (textite.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.
Key facts. Cited by 2 papers in the map (data through 14 Oct 2026). Builds on 40 of its 54 references that are in the map. First posted on arXiv 21 Nov 2022.
Builds on
40 of 54 references.
References · 40
- 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 12,049
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2019Momentum Contrast for Unsupervised Visual Representation Learningcited by 7,513
- 2014Explaining and Harnessing Adversarial Examplescited by 7,364
- 2017Towards Deep Learning Models Resistant to Adversarial Attackscited by 6,415
- 2018Unsupervised Feature Learning via Non-Parametric Instance-level Discriminationcited by 1,845
- 2017Visualizing the Loss Landscape of Neural Netscited by 1,130
- 2018Robustness May Be at Odds with Accuracycited by 880
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 654
- 2020Debiased Contrastive Learningcited by 356
- 2016Adversarial Training Methods for Semi-Supervised Text Classificationcited by 280
28 more
- 2018code2vec: Learning Distributed Representations of Codecited by 250
- 2017Learning to Represent Programs with Graphscited by 220
- 2021Investigating Bi-Level Optimization for Learning and Vision from a Unified Perspective: A Survey and Beyondcited by 153
- 2020Robust Pre-Training by Adversarial Contrastive Learningcited by 144
- 2020Adversarial Self-Supervised Contrastive Learningcited by 139
- 2018Is Robustness the Cost of Accuracy? -- A Comprehensive Study on the Robustness of 18 Deep Image Classification Modelscited by 135
- 2020You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completioncited by 131
- 2021Jigsaw: Large Language Models meet Program Synthesiscited by 103
- 2016A Convolutional Attention Network for Extreme Summarization of Source Codecited by 91
- 2021When Does Contrastive Learning Preserve Adversarial Robustness from Pretraining to Finetuning?cited by 77
- 2020Contrastive Code Representation Learningcited by 76
- 2021Revisiting and Advancing Fast Adversarial Training Through The Lens of Bi-Level Optimizationcited by 76
- 2022Natural Attack for Pre-trained Models of Codecited by 75
- 2020Detecting Code Clones with Graph Neural Networkand Flow-Augmented Abstract Syntax Treecited by 69
- 2019Adversarial Examples for Models of Codecited by 63
- 2021SynCoBERT: Syntax-Guided Multi-Modal Contrastive Pre-Training for Code Representationcited by 63
- 2020Self-Supervised Contrastive Learning for Code Retrieval and Summarization via Semantic-Preserving Transformationscited by 49
- 2020Semantic Robustness of Models of Source Codecited by 45
- 2020Adversarial Robustness for Codecited by 38
- 2019Misleading Authorship Attribution of Source Code using Adversarial Learningcited by 33
- 2018A General Path-Based Representation for Predicting Program Propertiescited by 29
- 2021Generating Adversarial Computer Programs using Optimized Obfuscationscited by 22
- 2020Learning Semantic Program Embeddings with Graph Interval Neural Networkcited by 20
- 2020Unsupervised Representation Learning by InvariancePropagationcited by 18
- 2019Towards Understanding the Transferability of Deep Representationscited by 12
- 2021VarCLR: Variable Semantic Representation Pre-training via Contrastive Learningcited by 11
- 2019COSET: A Benchmark for Evaluating Neural Program Embeddingscited by 10
- 2020Evaluation of Generalizability of Neural Program Analyzers under Semantic-Preserving Transformationscited by 9
Built on by
Citing papers per year: 2023: 1; 2024: 0; 2025: 0; 2026: 1.
2 papers.