一句话:提出 SemSIR,用摘要中间表示构建跨语言监督,并结合分布对齐与对比学习提升跨语言代码检索。
跨语言代码检索对现代软件开发至关重要,但现有对比学习方法受限于监督数据多样性或语义对齐不足,且不同语言编码分布异质会引入相似度偏差。本文提出端到端框架 SemSIR,其核心是以自然语言摘要作为中间表示 Summary IR,桥接跨语言语义鸿沟;SemSIR 从真实代码仓库自动构建可扩展的跨语言监督,并联合分布对齐与 CLIP 式对比训练,学习更具判别性的语言无关代码语义。作者收集 9 种语言、2400 万代码片段,自动构建 700 万语义组,抽样 1000 组人工检查显示 92.7% 完全语义一致、平均组纯度 96.8%。在两个 CLCR 基准上,SemSIR 一致优于所有基线,MRR 最高提升 24.7%,MAP 平均提升 50.1%;跨语言恶意软件改写追踪案例取得 92.20 MRR 和 88.40 MAP。
Cross-language code retrieval (CLCR) is critical to modern software development, and recent studies have shown that contrastive learning is an effective way to learn cross-language code semantics. However, these methods are still limited by two fundamental challenges. First, they rely on online judge platforms or multilingual NL-to-code datasets, which either lack diversity or fail to ensure semantic alignment between code snippets, thereby limiting the effectiveness of cross-language semantic learning. Second, during training, code snippets from different languages are often encoded into heterogeneous representation distributions. This distribution inconsistency introduces similarity bias and weakens the model's ability to capture accurate cross-language semantics. To address these challenges, we propose SemSIR, an end-to-end framework for CLCR. The key insight is to use Summary IR, a natural-language intermediate representation, to bridge semantic gaps across languages. Built on this insight, SemSIR automatically constructs scalable cross-language supervision from real-world repositories, and further combines distribution alignment with CLIP-style contrastive training to learn more discriminative language-independent code semantics. In our evaluation, we collect 24 million real-world code snippets across 9 languages and automatically construct 7 million semantic groups. Manual inspection of 1,000 sampled groups shows that 92.7% are fully semantically coherent, with an average Group Purity of 96.8%. On CLCR, SemSIR consistently outperforms all baselines on two benchmarks, surpassing the state-of-the-art method by up to 24.7% in MRR and 50.1% in MAP on average. In addition, experimental results on a security case study of tracing rewritten malware across languages show that SemSIR achieves 92.20 MRR and 88.40 MAP, highlighting its potential for security-oriented CLCR.
@inproceedings{paperbot12210,
title = {Lost in Translation, Found in Summary: Summary-Driven Supervision for Cross-Language Code Retrieval},
author = {Zhijie Liu and Yisi Liu and Linxi Jiang and Yutian Tang and Lili Xiao and Zhipeng Xue},
booktitle = {ASE},
year = {2026},
doi = {10.1145/3832783.3837444}
}