🤖 AI Summary
This work addresses key challenges in multilingual code search—namely data imbalance, cross-lingual semantic interference, and the loss of critical semantics when using unified representations such as abstract syntax trees (ASTs) or intermediate representations (IRs). To overcome these limitations, the authors propose UNICS, a novel framework that introduces pseudocode as a unified intermediate representation to preserve complete algorithmic logic. UNICS employs a two-stage training strategy to enhance semantic invariance: the first stage pretrains on pseudocode to learn language-agnostic program logic, while the second stage integrates semantic slicing, hard positive mining, and dynamic cross-lingual hard negative sampling within a multitask contrastive transfer learning paradigm. Extensive experiments demonstrate that UNICS achieves state-of-the-art performance across multiple multilingual and cross-lingual code search benchmarks, exhibiting exceptional generalization and performance parity—particularly in zero-shot transfer scenarios involving low-resource languages.
📝 Abstract
While pre-trained models have achieved remarkable success in code search, their multilingual capabilities remain a major hurdle, plagued by data imbalance, cross-lingual semantic interference, and the loss of critical information from existing unified representations like Abstract Syntax Trees (ASTs) or Intermediate Representations (IRs). Furthermore, conventional contrastive learning strategies often rely on simplistic hard negative sampling while overlooking the potential of mining hard positives to learn code's intrinsic semantic invariance. To address these challenges, we introduce UNICS, a framework for multilingual code search built on a two-stage training strategy. In the first stage, UNICS is pre-trained on a novel dataset we constructed, which uses pseudo-code as a unified representation to learn a cross-lingual, algorithm-level logic that preserves full semantic fidelity. The second stage employs a multi-task transfer learning strategy that adapts this general knowledge to specific languages by decomposing code into semantic slices (e.g., API calls, function bodies) and incorporating tasks for hard positive mining and cross-lingual dynamic hard negative sampling. Experimental results demonstrate that UNICS achieves state-of-the-art performance across multiple multilingual and cross-lingual benchmarks, showcasing superior generalization and performance balance, especially in zero-shot transfer tasks to low-resource languages.