EMNLP Findings2022
Soft-Labeled Contrastive Pre-Training for Function-Level Code Representation
Xiaonan Li, Daya Guo, Yeyun Gong, Yun Lin, Yelong Shen, Xipeng Qiu, Daxin Jiang, Weizhu Chen, Nan Duan
Abstract
Code contrastive pre-training has recently achieved significant progress on code-related tasks. In this paper, we present SCodeR, a Soft-labeled contrastive pre-training framework with two positive sample construction methods to learn functional-level Code Representation. Considering the relevance between codes in a large-scale code corpus, the soft-labeled contrastive pre-training can obtain fine-grained soft-labels through an iterative adversarial manner and use them to learn better code representation. The positive sample construction is another key for contrastive pretraining. Previous works use transformationbased methods like variable renaming to generate semantically equal positive codes. However, they usually result in the generated code with a highly similar surface form, and thus mislead the model to focus on superficial code structure instead of code semantics. To encourage SCodeR to capture semantic information from the code, we utilize code comments and abstract syntax sub-trees of the code to build positive samples. We conduct experiments on four code-related tasks over seven datasets. Extensive experimental results show that SCodeR achieves new state-of-the-art performance on all of them, which illustrates the effectiveness of the proposed pre-training method.
and work is done during the internship at Microsoft Research Asia.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
6 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code Rewriting cites CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
- Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code Rewriting cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code Rewriting cites GraphCodeBERT: Pre-training Code Representations with Data Flow
- Rewriting the Code: A Simple Method for Large Language Model Augmented Code Search cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Rewriting the Code: A Simple Method for Large Language Model Augmented Code Search cites Rethinking Negative Pairs in Code Search
- Rewriting the Code: A Simple Method for Large Language Model Augmented Code Search cites GraphCodeBERT: Pre-training Code Representations with Data Flow
- Rewriting the Code: A Simple Method for Large Language Model Augmented Code Search cites Language Models are Few-Shot Learners
- CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- CodeRetriever: A Large Scale Contrastive Pre-Training Method for Code Search cites On the Sentence Embeddings from Pre-trained Language Models
- CodeRetriever: A Large Scale Contrastive Pre-Training Method for Code Search cites CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
- CodeRetriever: A Large Scale Contrastive Pre-Training Method for Code Search cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- CodeRetriever: A Large Scale Contrastive Pre-Training Method for Code Search cites GraphCodeBERT: Pre-training Code Representations with Data Flow
- Rethinking Negative Pairs in Code Search cites On the Sentence Embeddings from Pre-trained Language Models
- Rethinking Negative Pairs in Code Search cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Rethinking Negative Pairs in Code Search cites GraphCodeBERT: Pre-training Code Representations with Data Flow
- CoEdPilot: Recommending Code Edits with Learned Prior Edit Relevance, Project-wise Awareness, and Interactive Nature cites CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
- CoEdPilot: Recommending Code Edits with Learned Prior Edit Relevance, Project-wise Awareness, and Interactive Nature cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- CoEdPilot: Recommending Code Edits with Learned Prior Edit Relevance, Project-wise Awareness, and Interactive Nature cites Language Models are Few-Shot Learners
Cited by top-tier papers6
- CodeRetriever: A Large Scale Contrastive Pre-Training Method for Code SearchXiaonan Li, Yeyun Gong, Yelong Shen, Xipeng Qiu et al.EMNLP 2022 · 25 citations
- Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code RewritingTong Ye, Yangkai Du, Tengfei Ma, Lingfei Wu et al.AAAI 2025 · 21 citations
- Rewriting the Code: A Simple Method for Large Language Model Augmented Code SearchHaochen Li, Xin Zhou, Zhiqi ShenACL 2024 · 10 citations
- CoEdPilot: Recommending Code Edits with Learned Prior Edit Relevance, Project-wise Awareness, and Interactive NatureChenyan Liu, Yufan Cai, Yun Lin, Yuhuan Huang et al.ISSTA 2024 · 7 citations
- Rethinking Negative Pairs in Code SearchHaochen Li, Xin Zhou, Anh Tuan Luu, Chunyan MiaoEMNLP 2023 · 6 citations
Builds on12
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan et al.EMNLP Findings 2020 · 2,828 citations
- GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng et al.ICLR 2021 · 1,644 citations
- CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and GenerationYue Wang, Weishi Wang, Shafiq R. Joty, Steven C. H. HoiEMNLP 2021 · 1,224 citations
- On the Sentence Embeddings from Pre-trained Language ModelsBohan Li, Hao Zhou, Junxian He, Mingxuan Wang et al.EMNLP 2020 · 538 citations
Related papers
- Self-Supervised Contrastive Learning for Code Retrieval and Summarization via Semantic-Preserving TransformationsNghi D. Q. Bui, Yijun Yu, Lingxiao JiangSIGIR 2021 · 98 citations
- CoCoSoDa: Effective Contrastive Learning for Code SearchEnsheng Shi, Yanlin Wang, Wenchao Gu, Lun Du et al.ICSE 2023 · 45 citations
- MGS3: A Multi-Granularity Self-Supervised Code Search FrameworkRui Li, Junfeng Kang, Qi Liu, Liyang He et al.KDD 2025
- Code Representation Learning at ScaleDejiao Zhang, Wasi Uddin Ahmad, Ming Tan, Hantian Ding et al.ICLR 2024 · 32 citations
- Contrastive Code Representation LearningParas Jain, Ajay Jain, Tianjun Zhang, Pieter Abbeel et al.EMNLP 2021 · 11 citations
