Synthetic Semantic Supervision for Contrastive Code Representation Learning in Small Transformers: An Empirical Study
Abstract
General-purpose code embeddings power tools for code search, classification, and retrieval. Compact transformer encoders for code typically rely on either human-written docstrings (labor-intensive and inconsistent) or mined structural signals such as execution traces (setting-specific and costly to collect). We empirically study an alternative: contrastive pretraining of small encoders with synthetically generated natural-language descriptions emphasizing code functionality and intent, paired with code in a dual-encoder framework at training and discarded at inference. We benchmark this approach against pretraining-based baselines, generalist LLMs, and embedding-specific models on eight retrieval, classification, and generation tasks across C, C++, and Java. Synthetic semantic supervision yields statistically significant gains over pretraining baselines of the same inference-time size on five of eight tasks, with parity on two more; once fine-tuned, it matches or exceeds zero-shot models two orders of magnitude larger on classification, and it stays on par with execution-aware supervision at matched pretraining data, suggesting a scalable, effective alternative to existing code-representation paradigms.
Create a lesson
Metadata
- Comments
- Accepted in Findings EMNLP 2026
Related papers
Orthogonally Mixed Sign Coding with Progressive Residual Refinement for Transformer Weight Compression
Shared title terminologycs.AIAnindya Roy Chowdhury, Atanu Barai, Nandakishore Santhi
IPGeoAI: Transformer-Based Geolocation with LLM Semantic Fusion
Shared title terminologycs.AIAvinash Kadimisetty, Andy Jinqing Yu, Philip Favaloro et al.
MetaFORGE: A Meta-Learning Framework for Harness Optimization in Automated Code Generation for Parallel Computing
Shared title terminologycs.AIScott Piersall, Yang Gao, Shenyang Liu et al.
Measurement Artifacts in Trustworthiness Evaluations of Quantized Small Language Models
Shared title terminologycs.AITanzeel Abbas, Tehseen Zia, David Windridge
Learning World Models through Contrastive Identification of Actions
Shared title terminologycs.AIHayeong Lee, Youngjun Suh. Byung-Jun Lee
Coding4Games: Can Modern Coding Agents Play Modern Video Games?
Shared title terminologycs.AIShifang Zhao, Haoyu Wang, Yuyang Yin et al.