UNICS: 通过统一伪代码和对比迁移学习实现多语言代码搜索
UNICS: Multilingual Code Search via Unified Pseudocode and Contrastive Transfer Learning
AI总结:
提出UNICS框架,利用伪代码统一表示和两阶段训练策略(预训练+多任务迁移学习),解决多语言代码搜索中的数据不平衡、跨语言语义干扰等问题,在多个基准上取得最优性能。
摘要:
虽然预训练模型在代码搜索中取得了显著成功,但其多语言能力仍然是一个主要障碍,受到数据不平衡、跨语言语义干扰以及现有统一表示(如抽象语法树或中间表示)丢失关键信息的影响。此外,传统的对比学习策略通常依赖于简单的难负样本采样,而忽略了挖掘难正样本以学习代码内在语义不变性的潜力。为了解决这些挑战,我们引入了UNICS,一个基于两阶段训练策略的多语言代码搜索框架。在第一阶段,UNICS在我们构建的新数据集上进行预训练,该数据集使用伪代码作为统一表示来学习跨语言的算法级逻辑,同时保持完整的语义保真度。第二阶段采用多任务迁移学习策略,通过将代码分解为语义片段(例如API调用、函数体)并纳入难正样本挖掘和跨语言动态难负样本采样的任务,将这种通用知识适应到特定语言。实验结果表明,UNICS在多个多语言和跨语言基准测试中达到了最先进的性能,展示了卓越的泛化能力和性能平衡,特别是在对低资源语言的零样本迁移任务中。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。