arXiv:2507.20078cs.LG2025-07

提出新损失函数,让代码嵌入更精准区分语义等价的变异代码。

Cluster Purge Loss: Structuring Transformer Embeddings for Equivalent Mutants Detection

  • 用聚类清除损失动态调整类内边界,细化同类间差异。
  • 在等价变异检测任务上超越现有方法,提升准确率。
  • 适合代码分析、程序验证等需要精细语义理解的场景。

近期预训练的Transformer模型在多种代码处理任务中表现优异。然而,尽管在优化决策边界方面有效,常见的微调方法——基于距离的方法或添加分类头——往往未能充分结构化嵌入空间以反映类内细微的语义关系。等价代码变异检测正是此类任务之一,嵌入空间质量直接影响模型性能。本文提出一种新框架,将交叉熵损失与深度度量学习目标结合,称为聚类清除损失(Cluster Purge Loss)。该目标不同于传统方法,专注于调整每类内部的细粒度差异,通过动态调整的边界,促使实例依据语义等价性相对于类中心分离。以UniXCoder为基础模型,本方法在等价变异检测领域达到当前最优性能,并生成更具可解释性的嵌入空间。

原文摘要 · Abstract (English)

Recent pre-trained transformer models achieve superior performance in various code processing objectives. However, although effective at optimizing decision boundaries, common approaches for fine-tuning them for downstream classification tasks - distance-based methods or training an additional classification head - often fail to thoroughly structure the embedding space to reflect nuanced intra-class semantic relationships. Equivalent code mutant detection is one of these tasks, where the quality of the embedding space is crucial to the performance of the models. We introduce a novel framework that integrates cross-entropy loss with a deep metric learning objective, termed Cluster Purge Loss. This objective, unlike conventional approaches, concentrates on adjusting fine-grained differences within each class, encouraging the separation of instances based on semantical equivalency to the class center using dynamically adjusted borders. Employing UniXCoder as the base model, our approach demonstrates state-of-the-art performance in the domain of equivalent mutant detection and produces a more interpretable embedding space.

代码理解嵌入结构度量学习

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。