UniCoR: Modality Collaboration for Robust Cross-Language Hybrid Code Retrieval

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Yang, Yang, Kuang, Li, Liu, Jiakun, Liu, Zhongxin, Xia, Yingjie, Lo, David
Natura: Preprint
Pubblicazione: 2025
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866908869850038272
author Yang, Yang
Kuang, Li
Liu, Jiakun
Liu, Zhongxin
Xia, Yingjie
Lo, David
author_facet Yang, Yang
Kuang, Li
Liu, Jiakun
Liu, Zhongxin
Xia, Yingjie
Lo, David
contents Effective code retrieval is indispensable and it has become an important paradigm to search code in hybrid mode using both natural language and code snippets. Nevertheless, it remains unclear whether existing approaches can effectively leverage such hybrid queries, particularly in cross-language contexts. We conduct a comprehensive empirical study of representative code models and reveal three challenges: (1)insufficient semantic understanding; (2) inefficient fusion in hybrid code retrieval; and (3) weak generalization in cross-language scenarios. To address these challenges, we propose UniCoR, a novel self-supervised framework designed to learn Unified Code Representations that are semantically robust, modally collaborative, and language-agnostic. Firstly, we design a multi-perspective supervised contrastive learning module to enhance semantic understanding and modality fusion. It aligns representations from multiple perspectives, including code-to-code, natural language-to-code, and natural language-to-natural language, enforcing the model to capture a semantic essence among modalities. Secondly, we introduce a representation distribution consistency learning module to improve cross-language generalization, which explicitly aligns the feature distributions of different programming languages, enabling language-agnostic representation learning. Extensive experiments on both an empirical benchmark and a large-scale benchmark show that UniCoR outperforms all baseline models, achieving an average improvement of 8.64% in MRR and 11.54% in MAP over the best-performing baseline. Furthermore, UniCoR exhibits stability in hybrid code retrieval and generalization capability in cross-language scenarios.
format Preprint
id arxiv_https___arxiv_org_abs_2512_10452
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle UniCoR: Modality Collaboration for Robust Cross-Language Hybrid Code Retrieval
Yang, Yang
Kuang, Li
Liu, Jiakun
Liu, Zhongxin
Xia, Yingjie
Lo, David
Software Engineering
Effective code retrieval is indispensable and it has become an important paradigm to search code in hybrid mode using both natural language and code snippets. Nevertheless, it remains unclear whether existing approaches can effectively leverage such hybrid queries, particularly in cross-language contexts. We conduct a comprehensive empirical study of representative code models and reveal three challenges: (1)insufficient semantic understanding; (2) inefficient fusion in hybrid code retrieval; and (3) weak generalization in cross-language scenarios. To address these challenges, we propose UniCoR, a novel self-supervised framework designed to learn Unified Code Representations that are semantically robust, modally collaborative, and language-agnostic. Firstly, we design a multi-perspective supervised contrastive learning module to enhance semantic understanding and modality fusion. It aligns representations from multiple perspectives, including code-to-code, natural language-to-code, and natural language-to-natural language, enforcing the model to capture a semantic essence among modalities. Secondly, we introduce a representation distribution consistency learning module to improve cross-language generalization, which explicitly aligns the feature distributions of different programming languages, enabling language-agnostic representation learning. Extensive experiments on both an empirical benchmark and a large-scale benchmark show that UniCoR outperforms all baseline models, achieving an average improvement of 8.64% in MRR and 11.54% in MAP over the best-performing baseline. Furthermore, UniCoR exhibits stability in hybrid code retrieval and generalization capability in cross-language scenarios.
title UniCoR: Modality Collaboration for Robust Cross-Language Hybrid Code Retrieval
topic Software Engineering
url https://arxiv.org/abs/2512.10452