mlsanityData to 7 Oct 2026

Invariant Pretraining for Robust Code Representations

arXiv 2608.15412 ↗First posted 15 Aug 2026cs.LG cs.AI cs.SEcited by 0

Not on the map. Why?

Abstract (arXiv)

Encoder-based code representation models remain widely deployed for discriminative tasks such as clone detection and code classification, where their small size and low inference cost are decisive. Their robustness, however, is fragile: under invariant programs, semantically equivalent code written in different syntactic forms, learned representations degrade substantially even though program behavior is unchanged. We present an empirical study of this robustness gap across four encoder baselines, two downstream tasks, and four datasets, together with a minimal code-only continued pretraining recipe that closes much of it. Our method, invariant pretraining (InvPT), applies semantic-preserving transformations to the corpus and combines masked language modeling with multi-positive supervised contrastive learning that treats all augmentations of the same source function as positives, mixing self-contrast pairs (same code, different masks) with invariant-contrast pairs (transformed code) for positives of varying difficulty. Unlike prior contrastive code encoders, InvPT does not require paired natural-language data. Across our evaluation, InvPT improves robustness on transformed test sets by up to 11 percentage points on clone detection and 19 on code classification while matching or improving standard accuracy, and our ablations isolate multi-positive invariant contrast as the main source of the gains. Our aim is not a new objective but a careful measurement of where encoder robustness breaks and how far a simple, code-only recipe can recover it.

Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 46 of its 59 references that are in the map. First posted on arXiv 15 Aug 2026.

Builds on

46 of 59 references.

References · 46

  1. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  2. 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 11,979
  3. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  4. 2018Representation Learning with Contrastive Predictive Codingcited by 7,662
  5. 2019Momentum Contrast for Unsupervised Visual Representation Learningcited by 7,482
  6. 2016Overcoming catastrophic forgetting in neural networkscited by 4,718
  7. 2020Supervised Contrastive Learningcited by 2,803
  8. 2021SimCSE: Simple Contrastive Learning of Sentence Embeddingscited by 2,168
  9. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  10. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
  11. 2025Qwen3 Embedding: Advancing Text Embedding and Reranking Through Foundation Modelscited by 1,175
  12. 2018The Secret Sharer: Evaluating and Testing Unintended Memorization in Neural Networkscited by 847
34 more
  1. 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
  2. 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
  3. 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
  4. 2024Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inferencecited by 527
  5. 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
  6. 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
  7. 2020A Metric Learning Reality Checkcited by 317
  8. 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 266
  9. 2021CodeNet: A Large-Scale AI for Code Dataset for Learning a Diversity of Coding Taskscited by 199
  10. 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 133
  11. 2025EmbeddingGemma: Powerful and Lightweight Text Representationscited by 128
  12. 2020Contrastive Code Representation Learningcited by 76
  13. 2022Natural Attack for Pre-trained Models of Codecited by 72
  14. 2019Adversarial Examples for Models of Codecited by 61
  15. 2022NatGen: Generative pre-training by "Naturalizing" source codecited by 53
  16. 2020Self-Supervised Contrastive Learning for Code Retrieval and Summarization via Semantic-Preserving Transformationscited by 49
  17. 2024Why Warmup the Learning Rate? Underlying Mechanisms and Improvementscited by 45
  18. 2020Semantic Robustness of Models of Source Codecited by 43
  19. 2021Multilingual training for Software Engineeringcited by 43
  20. 2020On the Generalizability of Neural Program Models with respect to Semantic-Preserving Program Transformationscited by 41
  21. 2024CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Rerankingcited by 37
  22. 2020Adversarial Robustness for Codecited by 36
  23. 2021Bridging Pre-trained Models and Downstream Tasks for Source Code Understandingcited by 27
  24. 2023Prompt Fuzzing for Fuzz Driver Generationcited by 27
  25. 2023Understanding Programs by Exploiting (Fuzzing) Test Casescited by 13
  26. 2025Efficient Code Embeddings from Code Generation Modelscited by 12
  27. 2021VarCLR: Variable Semantic Representation Pre-training via Contrastive Learningcited by 11
  28. 2023Code Representation Pre-training with Complements from Program Executionscited by 8
  29. 2024Large Language Models Are Overparameterized Text Encoderscited by 6
  30. 2024UniTSyn: A Large-Scale Dataset Capable of Enhancing the Prowess of Large Language Models for Program Testingcited by 5
  31. 2024FuzzAug: Data Augmentation by Coverage-guided Fuzzing for Neural Test Generationcited by 3
  32. 2024Towards Better Code Understanding in Decoder-Only Models with Contrastive Learningcited by 3
  33. 2025How the Misuse of a Dataset Harmed Semantic Clone Detectioncited by 3
  34. 2025Making Large Language Models Efficient Dense Retrieverscited by 2

Built on by

Not cited yet.