mlsanityData to 7 Oct 2026

Towards Better Code Understanding in Decoder-Only Models with Contrastive Learning

arXiv 2406.12326 ↗First posted 18 Jun 2024cs.SE cs.AIcited by 3

Not on the map. Why?

Abstract (arXiv)

Recent advances in large-scale code generation models have led to remarkable progress in producing high-quality code. These models are trained in a self-supervised manner on extensive unlabeled code corpora using a decoder-only architecture. However, despite their generative strength, decoder-only models often exhibit limited performance on code understanding tasks such as code search and clone detection, primarily due to their generation-oriented training objectives. While training large encoder-only models from scratch on massive code datasets can improve understanding ability but remains computationally expensive and time-consuming. In this paper, we explore a more efficient alternative by transferring knowledge from pre-trained decoder-only code generation models to code understanding tasks. We investigate how decoder-only architectures can be effectively adapted to learn discriminative and semantically meaningful code representations. To this end, we propose CL4D, a contrastive learning framework tailored to strengthen the representation capabilities of decoder-only models. Extensive experiments on multiple benchmark datasets demonstrate that CL4D achieves competitive or superior performance compared to existing methods on representative code understanding tasks, including code search and clone detection. Further analysis reveals that CL4D substantially improves the semantic alignment of code representations by reducing the distance between semantically similar code snippets. These findings highlight the feasibility of leveraging decoder-only models as a unified backbone for both code generation and understanding.

Key facts. Cited by 3 papers in the map (data through 7 Oct 2026). Builds on 12 of its 16 references that are in the map. First posted on arXiv 18 Jun 2024.

Builds on

12 of 16 references.

References · 12

  1. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  2. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
  3. 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
  4. 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
  5. 2024CodeGemma: Open Code Models Based on Gemmacited by 145
  6. 2021CoSQA: 20,000+ Web Queries for Code Search and Question Answeringcited by 74
  7. 2021SynCoBERT: Syntax-Guided Multi-Modal Contrastive Pre-Training for Code Representationcited by 63
  8. 2023WaveCoder: Widespread And Versatile Enhancement For Code Large Language Models By Instruction Tuningcited by 42
  9. 2021TreeBERT: A Tree-Based Pre-Trained Model for Programming Languagecited by 40
  10. 2023Contrastive Learning of Sentence Embeddings from Scratchcited by 24
  11. 2022CODE-MVP: Learning to Represent Source Code from Multiple Views with Contrastive Pre-Trainingcited by 15
  12. 2024Scaling Laws Behind Code Understanding Modelcited by 4

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2026: 3.

3 papers.