paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Hedgecode: A Multi-Task Hedging Contrastive Learning Framework for Code Search

HedgeCode:面向代码搜索的多任务对冲对比学习框架
ICSE 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE)2025匹配度 2/10 · 该论文聚焦代码搜索与代码-自然语言表示对齐,属于软件工程/信息检索与表示学习,不涉及用户关注的核心方向:静态分析、Agentic 程序分析、浮点程序分析、贝叶斯程序分析,也未将 LLM/Agent 用于改进静态分析或形式化验证。引用 0 inbox
Gong Chen, Xiaoyuan Xie, Daniel Tang, Qi Xin, Wenjie Liu
crossref: 2026-09-12

AI 速览

一句话:提出 HedgeCode 两阶段框架,用对冲对比学习对齐代码与自然语言的表示空间,并结合多任务联合学习提升代码搜索效果。

代码搜索旨在根据自然语言查询检索正确的代码片段,现有深度学习方法虽改进了代码与描述的表征,但仍存在两个问题:一是代码与其自然语言描述表示空间之间的一致性缺乏保障,二是未能充分利用代码片段与描述之间的潜在相关性,难以区分相似代码片段的细粒度语义差异。为此,作者提出多任务对冲对比学习框架 HedgeCode,包含两个训练阶段:第一阶段为表示对齐阶段,采用对冲对比学习方法检测代码与自然语言文本之间的细微差异,并通过识别相关性对齐二者的表示空间;第二阶段为多任务联合学习,将前阶段训练好的模型作为编码器,结合监督对比学习与自监督对比学习任务对模型进行优化。该框架在 CodeSearchNet 基准上进行了评估,结果表明其能够缓解上述代码搜索中的局限,取得有效性能。

问题
现有代码搜索方法难以保证代码与自然语言描述表示空间的一致性,且未充分利用二者的相关性,导致难以区分相似代码片段间的细粒度语义差异。
方法
提出两阶段框架 HedgeCode:先以对冲对比学习检测代码与文本的细微差异并对齐表示空间,再以该模型为编码器进行融合监督与自监督对比学习的多任务联合训练。
评估
在 CodeSearchNet 基准数据集上开展实验,验证框架在缓解上述局限方面的有效性。
原文摘要(Abstract)

Code search is a vital activity in software engineering, focused on identifying and retrieving the correct code snippets based on a query provided in natural language. Approaches based on deep learning techniques have been increasingly adopted for this task, enhancing the initial representations of both code and its natural language descriptions. Despite this progress, there remains an unexplored gap in ensuring consistency between the representation spaces of code and its descriptions. Furthermore, existing methods have not fully leveraged the potential relevance between code snippets and their descriptions, presenting a challenge in discerning fine-grained semantic distinctions among similar code snippets. To address these challenges, we introduce a multi-task hedging contrastive Learning framework for Code Search, referred to as HedgeCode. HedgeCode is structured around two primary training phases. The first phase, known as the representation alignment stage, proposes a hedging contrastive learning approach. This method aims to detect subtle differences between code and natural language text, thereby aligning their representation spaces by identifying relevance. The subsequent phase involves multi-task joint learning, wherein the previously trained model serves as the encoder. This stage optimizes the model through a combination of supervised and self-supervised contrastive learning tasks. Our framework's effectiveness is demonstrated through its performance on the CodeSearchNet benchmark, showcasing HedgeCode's ability to address the mentioned limitations in code search tasks.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot8781,
  title = {Hedgecode: A Multi-Task Hedging Contrastive Learning Framework for Code Search},
  author = {Gong Chen and Xiaoyuan Xie and Daniel Tang and Qi Xin and Wenjie Liu},
  booktitle = {ICSE},
  year = {2025},
  doi = {10.1109/icse55347.2025.00008}
}